summaryrefslogtreecommitdiff
path: root/src/citra_qt/game_list.cpp
diff options
context:
space:
mode:
authorGravatar Emmanuel Gil Peyrot2015-09-06 07:59:04 +0100
committerGravatar Emmanuel Gil Peyrot2016-05-21 16:41:02 +0100
commit8ab6f26c09e5b77a051fa545570ca2986c45bf4a (patch)
treea0664d2b9bb548cbd7f78ed60b846a88c09f90f4 /src/citra_qt/game_list.cpp
parentAppveyor: Restore working directory after test_script (#1835) (diff)
downloadyuzu-8ab6f26c09e5b77a051fa545570ca2986c45bf4a.tar.gz
yuzu-8ab6f26c09e5b77a051fa545570ca2986c45bf4a.tar.xz
yuzu-8ab6f26c09e5b77a051fa545570ca2986c45bf4a.zip
Common: Make recursive FileUtil functions take a maximum recursion
Fixes #1115. Also improves the performances of DiskArchive’s directory implementation a lot, simply by not going through the entire tree instead of just listing the first level files. Thanks to JayRoxFox for rebasing this on current master!
Diffstat (limited to 'src/citra_qt/game_list.cpp')
-rw-r--r--src/citra_qt/game_list.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp
index d4ac9c96e..adbcf24e8 100644
--- a/src/citra_qt/game_list.cpp
+++ b/src/citra_qt/game_list.cpp
@@ -118,19 +118,20 @@ void GameList::LoadInterfaceLayout()
118 item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder()); 118 item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder());
119} 119}
120 120
121void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, bool deep_scan) 121void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsigned int recursion)
122{ 122{
123 const auto callback = [&](unsigned* num_entries_out, 123 const auto callback = [&](unsigned* num_entries_out,
124 const std::string& directory, 124 const std::string& directory,
125 const std::string& virtual_name) -> bool { 125 const std::string& virtual_name,
126 unsigned int recursion) -> bool {
126 127
127 std::string physical_name = directory + DIR_SEP + virtual_name; 128 std::string physical_name = directory + DIR_SEP + virtual_name;
128 129
129 if (stop_processing) 130 if (stop_processing)
130 return false; // Breaks the callback loop. 131 return false; // Breaks the callback loop.
131 132
132 if (deep_scan && FileUtil::IsDirectory(physical_name)) { 133 if (recursion > 0 && FileUtil::IsDirectory(physical_name)) {
133 AddFstEntriesToGameList(physical_name, true); 134 AddFstEntriesToGameList(physical_name, recursion - 1);
134 } else { 135 } else {
135 std::string filename_filename, filename_extension; 136 std::string filename_filename, filename_extension;
136 Common::SplitPath(physical_name, nullptr, &filename_filename, &filename_extension); 137 Common::SplitPath(physical_name, nullptr, &filename_filename, &filename_extension);
@@ -169,7 +170,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, bool d
169void GameListWorker::run() 170void GameListWorker::run()
170{ 171{
171 stop_processing = false; 172 stop_processing = false;
172 AddFstEntriesToGameList(dir_path.toStdString(), deep_scan); 173 AddFstEntriesToGameList(dir_path.toStdString(), deep_scan ? 256 : 0);
173 emit Finished(); 174 emit Finished();
174} 175}
175 176