Merge pull request #14824 from hrydgard/hide-irrelevant-directories

Hide directories games should not know about
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2021-09-11 15:36:20 +02:00
commit ef7b6ec5ca
3 files changed
+44 -14

No files matched your search

-1
View File
@@ -654,7 +654,6 @@ u64 MetaFileSystem::getDirSize(const std::string &dirPath) {
for (auto file : allFiles) {
if (file.name == "." || file.name == "..")
continue;
_assert_(!file.name.empty());
if (file.type == FILETYPE_DIRECTORY) {
result += getDirSize(dirPath + file.name);
} else {
+34 -1
View File
@@ -2325,6 +2325,39 @@ static u32 sceIoDopen(const char *path) {
dir->index = 0;
dir->name = std::string(path);
// Blacklist some directories that games should not be able to find out about.
// Speeds up directory iteration on slow Android Scoped Storage implementations :(
// Might also want to filter out PSP/GAME if not a homebrew, maybe also irrelevant directories
// in PSP/SAVEDATA, though iffy to know which ones are irrelevant..
if (!strcmp(path, "ms0:/PSP")) {
static const char *const pspFolderBlacklist[] = {
"CHEATS",
"PPSSPP_STATE",
"PLUGINS",
"SYSTEM",
"SCREENSHOT",
"TEXTURES",
"DUMP",
"SHADERS",
};
std::vector<PSPFileInfo> filtered;
for (const auto &entry : dir->listing) {
bool blacklisted = false;
for (auto black : pspFolderBlacklist) {
if (!strcasecmp(entry.name.c_str(), black)) {
blacklisted = true;
break;
}
}
if (!blacklisted) {
filtered.push_back(entry);
}
}
dir->listing = filtered;
}
// TODO: The result is delayed only from the memstick, it seems.
return id;
}
@@ -2349,7 +2382,7 @@ static u32 sceIoDread(int id, u32 dirent_addr) {
SceIoDirEnt *entry = (SceIoDirEnt*) Memory::GetPointer(dirent_addr);
if (dir->index == (int) dir->listing.size()) {
DEBUG_LOG(SCEIO, "sceIoDread( %d %08x ) - end of the line", id, dirent_addr);
DEBUG_LOG(SCEIO, "sceIoDread( %d %08x ) - end", id, dirent_addr);
entry->d_name[0] = '\0';
return 0;
}
+10 -12
View File
@@ -152,12 +152,9 @@ u64 GameInfo::GetSaveDataSizeInBytes() {
for (size_t j = 0; j < saveDataDir.size(); j++) {
std::vector<File::FileInfo> fileInfo;
File::GetFilesInDir(saveDataDir[j], &fileInfo);
// Note: GetFilesInDir does not fill in fileSize properly.
for (size_t i = 0; i < fileInfo.size(); i++) {
File::FileInfo finfo;
File::GetFileInfo(fileInfo[i].fullName, &finfo);
if (!finfo.isDirectory)
filesSizeInDir += finfo.size;
for (auto const &file : fileInfo) {
if (!file.isDirectory)
filesSizeInDir += file.size;
}
if (filesSizeInDir < 0xA00000) {
// HACK: Generally the savedata size in a dir shouldn't be more than 10MB.
@@ -179,12 +176,11 @@ u64 GameInfo::GetInstallDataSizeInBytes() {
for (size_t j = 0; j < saveDataDir.size(); j++) {
std::vector<File::FileInfo> fileInfo;
File::GetFilesInDir(saveDataDir[j], &fileInfo);
// Note: GetFilesInDir does not fill in fileSize properly.
for (size_t i = 0; i < fileInfo.size(); i++) {
File::FileInfo finfo;
File::GetFileInfo(fileInfo[i].fullName, &finfo);
if (!finfo.isDirectory)
filesSizeInDir += finfo.size;
for (auto const &file : fileInfo) {
// TODO: Might want to recurse here? Don't know games that use directories
// for install-data though.
if (!file.isDirectory)
filesSizeInDir += file.size;
}
if (filesSizeInDir >= 0xA00000) {
// HACK: Generally the savedata size in a dir shouldn't be more than 10MB.
@@ -351,7 +347,9 @@ public:
if (!info_->LoadFromPath(gamePath_)) {
return;
}
// In case of a remote file, check if it actually exists before locking.
// This is likely not necessary at a
if (!info_->GetFileLoader()->Exists()) {
return;
}