diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index 6ecd36226c..173cf4a863 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -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 { diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 0c4dcf20e1..d290d540b0 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -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 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; } diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index 3d8db8fd7c..803315aa77 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -152,12 +152,9 @@ u64 GameInfo::GetSaveDataSizeInBytes() { for (size_t j = 0; j < saveDataDir.size(); j++) { std::vector 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 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; }