Merge pull request #1751 from linkmauve/no-recursive-readdir
Make recursive FileUtil functions take a maximum recursion
This commit is contained in:
commit
08e09184df
4 changed files with 43 additions and 30 deletions
|
@ -118,19 +118,20 @@ void GameList::LoadInterfaceLayout()
|
|||
item_model->sort(header->sortIndicatorSection(), header->sortIndicatorOrder());
|
||||
}
|
||||
|
||||
void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, bool deep_scan)
|
||||
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) -> bool {
|
||||
const std::string& virtual_name,
|
||||
unsigned int recursion) -> bool {
|
||||
|
||||
std::string physical_name = directory + DIR_SEP + virtual_name;
|
||||
|
||||
if (stop_processing)
|
||||
return false; // Breaks the callback loop.
|
||||
|
||||
if (deep_scan && FileUtil::IsDirectory(physical_name)) {
|
||||
AddFstEntriesToGameList(physical_name, true);
|
||||
if (recursion > 0 && FileUtil::IsDirectory(physical_name)) {
|
||||
AddFstEntriesToGameList(physical_name, recursion - 1);
|
||||
} else {
|
||||
std::unique_ptr<Loader::AppLoader> loader = Loader::GetLoader(physical_name);
|
||||
if (!loader)
|
||||
|
@ -155,7 +156,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, bool d
|
|||
void GameListWorker::run()
|
||||
{
|
||||
stop_processing = false;
|
||||
AddFstEntriesToGameList(dir_path.toStdString(), deep_scan);
|
||||
AddFstEntriesToGameList(dir_path.toStdString(), deep_scan ? 256 : 0);
|
||||
emit Finished();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue