From b3cfcf55ead41d0458f83d26d7258a1701356e3b Mon Sep 17 00:00:00 2001 From: archshift Date: Thu, 26 Nov 2015 00:34:26 -0800 Subject: Refactor ScanDirectoryTreeAndCallback to separate errors and retvals ScanDirectoryTreeAndCallback, before this change, coupled error/return codes and actual return values (number of entries found). This caused confusion and difficulty interpreting the precise way the function worked. Supersedes, and closes #1255. --- src/citra_qt/game_list.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/citra_qt') diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index e925f08a7..1f8d69a03 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -119,13 +119,14 @@ void GameList::LoadInterfaceLayout(QSettings& settings) void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, bool deep_scan) { - const auto callback = [&](const std::string& directory, - const std::string& virtual_name) -> int { + const auto callback = [&](unsigned* num_entries_out, + const std::string& directory, + const std::string& virtual_name) -> bool { std::string physical_name = directory + DIR_SEP + virtual_name; if (stop_processing) - return -1; // A negative return value breaks the callback loop. + return false; // Breaks the callback loop. if (deep_scan && FileUtil::IsDirectory(physical_name)) { AddFstEntriesToGameList(physical_name, true); @@ -135,11 +136,11 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, bool d Loader::FileType guessed_filetype = Loader::GuessFromExtension(filename_extension); if (guessed_filetype == Loader::FileType::Unknown) - return 0; + return true; Loader::FileType filetype = Loader::IdentifyFile(physical_name); if (filetype == Loader::FileType::Unknown) { LOG_WARNING(Frontend, "File %s is of indeterminate type and is possibly corrupted.", physical_name.c_str()); - return 0; + return true; } if (guessed_filetype != filetype) { LOG_WARNING(Frontend, "Filetype and extension of file %s do not match.", physical_name.c_str()); @@ -152,9 +153,10 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, bool d }); } - return 0; // We don't care about the found entries + return true; }; - FileUtil::ScanDirectoryTreeAndCallback(dir_path, callback); + + FileUtil::ForeachDirectoryEntry(nullptr, dir_path, callback); } void GameListWorker::run() -- cgit v1.2.3