diff options
author | bunnei <bunneidev@gmail.com> | 2016-06-22 22:27:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-22 22:27:12 +0200 |
commit | 4d31874c7c028f18c5336fe2f9d1edc934473c23 (patch) | |
tree | ee295fae7d41b782df99b1d15ad13f5da0c2c325 | |
parent | Merge pull request #1922 from yuriks/microprofile-dpi-fix (diff) | |
parent | Fix recursive scanning of directories (diff) | |
download | yuzu-4d31874c7c028f18c5336fe2f9d1edc934473c23.tar yuzu-4d31874c7c028f18c5336fe2f9d1edc934473c23.tar.gz yuzu-4d31874c7c028f18c5336fe2f9d1edc934473c23.tar.bz2 yuzu-4d31874c7c028f18c5336fe2f9d1edc934473c23.tar.lz yuzu-4d31874c7c028f18c5336fe2f9d1edc934473c23.tar.xz yuzu-4d31874c7c028f18c5336fe2f9d1edc934473c23.tar.zst yuzu-4d31874c7c028f18c5336fe2f9d1edc934473c23.zip |
Diffstat (limited to '')
-rw-r--r-- | src/citra_qt/game_list.cpp | 8 | ||||
-rw-r--r-- | src/common/file_util.cpp | 22 | ||||
-rw-r--r-- | src/common/file_util.h | 7 |
3 files changed, 15 insertions, 22 deletions
diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index 15484fae3..1910da3ac 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -120,11 +120,9 @@ void GameList::LoadInterfaceLayout() void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion) { - const auto callback = [&](unsigned* num_entries_out, - const std::string& directory, - const std::string& virtual_name, - unsigned int recursion) -> bool { - + const auto callback = [this, recursion](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) diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 17af7c385..84fe95c8c 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -434,7 +434,7 @@ bool CreateEmptyFile(const std::string &filename) } -bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directory, DirectoryEntryCallable callback, unsigned int recursion) +bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directory, DirectoryEntryCallable callback) { LOG_TRACE(Common_Filesystem, "directory %s", directory.c_str()); @@ -472,7 +472,7 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo continue; unsigned ret_entries = 0; - if (!callback(&ret_entries, directory, virtual_name, recursion)) { + if (!callback(&ret_entries, directory, virtual_name)) { callback_error = true; break; } @@ -497,10 +497,9 @@ bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directo unsigned ScanDirectoryTree(const std::string &directory, FSTEntry& parent_entry, unsigned int recursion) { - const auto callback = [&parent_entry](unsigned* num_entries_out, - const std::string& directory, - const std::string& virtual_name, - unsigned int recursion) -> bool { + const auto callback = [recursion, &parent_entry](unsigned* num_entries_out, + const std::string& directory, + const std::string& virtual_name) -> bool { FSTEntry entry; entry.virtualName = virtual_name; entry.physicalName = directory + DIR_SEP + virtual_name; @@ -526,16 +525,15 @@ unsigned ScanDirectoryTree(const std::string &directory, FSTEntry& parent_entry, }; unsigned num_entries; - return ForeachDirectoryEntry(&num_entries, directory, callback, recursion) ? num_entries : 0; + return ForeachDirectoryEntry(&num_entries, directory, callback) ? num_entries : 0; } bool DeleteDirRecursively(const std::string &directory, unsigned int recursion) { - const static auto callback = [](unsigned* num_entries_out, - const std::string& directory, - const std::string& virtual_name, - unsigned int recursion) -> bool { + const auto callback = [recursion](unsigned* num_entries_out, + const std::string& directory, + const std::string& virtual_name) -> bool { std::string new_path = directory + DIR_SEP_CHR + virtual_name; if (IsDirectory(new_path)) { @@ -546,7 +544,7 @@ bool DeleteDirRecursively(const std::string &directory, unsigned int recursion) return Delete(new_path); }; - if (!ForeachDirectoryEntry(nullptr, directory, callback, recursion)) + if (!ForeachDirectoryEntry(nullptr, directory, callback)) return false; // Delete the outermost directory diff --git a/src/common/file_util.h b/src/common/file_util.h index 32ae2dc57..7ad7ee829 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -105,13 +105,11 @@ bool CreateEmptyFile(const std::string &filename); * @param num_entries_out to be assigned by the callable with the number of iterated directory entries, never null * @param directory the path to the enclosing directory * @param virtual_name the entry name, without any preceding directory info - * @param recursion Number of children directory to read before giving up * @return whether handling the entry succeeded */ using DirectoryEntryCallable = std::function<bool(unsigned* num_entries_out, const std::string& directory, - const std::string& virtual_name, - unsigned int recursion)>; + const std::string& virtual_name)>; /** * Scans a directory, calling the callback for each file/directory contained within. @@ -119,10 +117,9 @@ using DirectoryEntryCallable = std::function<bool(unsigned* num_entries_out, * @param num_entries_out assigned by the function with the number of iterated directory entries, can be null * @param directory the directory to scan * @param callback The callback which will be called for each entry - * @param recursion Number of children directories to read before giving up * @return whether scanning the directory succeeded */ -bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directory, DirectoryEntryCallable callback, unsigned int recursion = 0); +bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directory, DirectoryEntryCallable callback); /** * Scans the directory tree, storing the results. |