mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-24 19:36:17 +00:00
* Added recursive game scan and only using game directories * Added recursion depth limit to scan directories * Added recursive search by ID in cli mode * Added recursive search to pkg installing
This commit is contained in:
parent
8057ed408c
commit
f3c33b29dd
6 changed files with 117 additions and 20 deletions
|
@ -7,6 +7,33 @@
|
|||
#include "compatibility_info.h"
|
||||
#include "game_info.h"
|
||||
|
||||
// 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);
|
||||
|
||||
for (const auto& entry : entries) {
|
||||
if (entry.fileName().endsWith("-UPDATE")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if this directory contains a PS4 game (has sce_sys/param.sfo)
|
||||
if (QFile::exists(entry.filePath() + "/sce_sys/param.sfo")) {
|
||||
filePaths.append(entry.absoluteFilePath());
|
||||
} else {
|
||||
// If not a game directory, recursively scan it with increased depth
|
||||
ScanDirectoryRecursively(entry.absoluteFilePath(), filePaths, current_depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GameInfoClass::GameInfoClass() = default;
|
||||
GameInfoClass::~GameInfoClass() = default;
|
||||
|
||||
|
@ -15,13 +42,7 @@ void GameInfoClass::GetGameInfo(QWidget* parent) {
|
|||
for (const auto& installLoc : Config::getGameInstallDirs()) {
|
||||
QString installDir;
|
||||
Common::FS::PathToQString(installDir, installLoc);
|
||||
QDir parentFolder(installDir);
|
||||
QFileInfoList fileList = parentFolder.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (const auto& fileInfo : fileList) {
|
||||
if (fileInfo.isDir() && !fileInfo.filePath().endsWith("-UPDATE")) {
|
||||
filePaths.append(fileInfo.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
ScanDirectoryRecursively(installDir, filePaths, 0);
|
||||
}
|
||||
|
||||
m_games = QtConcurrent::mapped(filePaths, [&](const QString& path) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue