mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 00:42:48 +00:00
Added recursion depth limit to scan directories
This commit is contained in:
parent
abafd68a3d
commit
be46e4c103
@ -7,7 +7,15 @@
|
||||
#include "compatibility_info.h"
|
||||
#include "game_info.h"
|
||||
|
||||
void ScanDirectoryRecursively(const QString& dir, QStringList& filePaths) {
|
||||
// Maximum depth to search for games in subdirectories
|
||||
const int max_recursion_depth = 5;
|
||||
|
||||
void ScanDirectoryRecursively(const QString& dir, QStringList& filePaths, int current_depth = 0) {
|
||||
// Stop recursion if we've reached the maximum depth
|
||||
if (current_depth >= max_recursion_depth) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDir directory(dir);
|
||||
QFileInfoList entries = directory.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
|
||||
@ -20,8 +28,8 @@ void ScanDirectoryRecursively(const QString& dir, QStringList& filePaths) {
|
||||
if (QFile::exists(entry.filePath() + "/sce_sys/param.sfo")) {
|
||||
filePaths.append(entry.absoluteFilePath());
|
||||
} else {
|
||||
// If not a game directory, recursively scan it
|
||||
ScanDirectoryRecursively(entry.absoluteFilePath(), filePaths);
|
||||
// If not a game directory, recursively scan it with increased depth
|
||||
ScanDirectoryRecursively(entry.absoluteFilePath(), filePaths, current_depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -34,7 +42,7 @@ void GameInfoClass::GetGameInfo(QWidget* parent) {
|
||||
for (const auto& installLoc : Config::getGameInstallDirs()) {
|
||||
QString installDir;
|
||||
Common::FS::PathToQString(installDir, installLoc);
|
||||
ScanDirectoryRecursively(installDir, filePaths);
|
||||
ScanDirectoryRecursively(installDir, filePaths, 0);
|
||||
}
|
||||
|
||||
m_games = QtConcurrent::mapped(filePaths, [&](const QString& path) {
|
||||
|
Loading…
Reference in New Issue
Block a user