From 287b1bb0481c79f7891a9fc204cb81bbd395ca1f Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Tue, 4 Feb 2020 17:45:38 +0100 Subject: [PATCH] use sorted scandir instead of readdir Signed-off-by: Vincent-FK --- RetroFE/Source/Collection/CollectionInfoBuilder.cpp | 12 +++++++++--- RetroFE/Source/RetroFE.cpp | 2 -- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp index 4f1fe1a..09c2a72 100644 --- a/RetroFE/Source/Collection/CollectionInfoBuilder.cpp +++ b/RetroFE/Source/Collection/CollectionInfoBuilder.cpp @@ -449,9 +449,10 @@ void CollectionInfoBuilder::ImportRomDirectory(std::string path, CollectionInfo { DIR *dp; - struct dirent *dirp; + struct dirent **dirp; std::vector extensions; std::vector::iterator extensionsIt; + int n; info->extensionList(extensions); @@ -464,9 +465,12 @@ void CollectionInfoBuilder::ImportRomDirectory(std::string path, CollectionInfo return; } - while(dp != NULL && (dirp = readdir(dp)) != NULL) + printf("ImportRomDirectory\n"); + n = scandir(path.c_str(), &dirp, NULL, alphasort); + + while(dp != NULL && n-- > 0) { - std::string file = dirp->d_name; + std::string file = dirp[n]->d_name; // Check if the file is a directory or a file struct stat sb; @@ -478,6 +482,8 @@ void CollectionInfoBuilder::ImportRomDirectory(std::string path, CollectionInfo { size_t position = file.find_last_of("."); std::string basename = (std::string::npos == position)? file : file.substr(0, position); + + printf(" File: %s, basename :%s\n", file.c_str(), basename.c_str()); // if there is an include list, only include roms that are found and are in the include list // if there is an exclude list, exclude those roms diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index ff1a231..466b535 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -705,9 +705,7 @@ void RetroFE::run( ) } currentPage_->onNewItemSelected( ); - printf("\nbefore currentPage_->reallocateMenuSpritePoints()\n"); currentPage_->reallocateMenuSpritePoints( ); - printf("after currentPage_->reallocateMenuSpritePoints()\n\n"); state = RETROFE_NEXT_PAGE_MENU_LOAD_ART;