diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index b4fc833452..1695e4c0c1 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -561,7 +561,7 @@ int DirectoryFileSystem::OpenFile(std::string filename, FileAccess access, const OpenFileEntry entry; entry.hFile.fileSystemFlags_ = flags; u32 err = 0; - bool success = entry.hFile.Open(basePath, filename, access, err); + bool success = entry.hFile.Open(basePath, filename, (FileAccess)(access & FILEACCESS_PSP_FLAGS), err); if (err == 0 && !success) { err = SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND; } @@ -577,7 +577,9 @@ int DirectoryFileSystem::OpenFile(std::string filename, FileAccess access, const #else logError = (int)errno; #endif - ERROR_LOG(FILESYS, "DirectoryFileSystem::OpenFile('%s'): FAILED, %d - access = %d '%s'", filename.c_str(), logError, (int)access, errorString.c_str()); + if (!(access & FILEACCESS_PPSSPP_QUIET)) { + ERROR_LOG(FILESYS, "DirectoryFileSystem::OpenFile('%s'): FAILED, %d - access = %d '%s'", filename.c_str(), logError, (int)(access & FILEACCESS_PSP_FLAGS), errorString.c_str()); + } return err; } else { #ifdef _WIN32 @@ -589,7 +591,7 @@ int DirectoryFileSystem::OpenFile(std::string filename, FileAccess access, const u32 newHandle = hAlloc->GetNewHandle(); entry.guestFilename = filename; - entry.access = access; + entry.access = (FileAccess)(access & FILEACCESS_PSP_FLAGS); entries[newHandle] = entry; diff --git a/Core/FileSystems/FileSystem.h b/Core/FileSystems/FileSystem.h index d2eeca6651..9e64d16f20 100644 --- a/Core/FileSystems/FileSystem.h +++ b/Core/FileSystems/FileSystem.h @@ -34,6 +34,11 @@ enum FileAccess { FILEACCESS_CREATE = 8, FILEACCESS_TRUNCATE = 16, FILEACCESS_EXCL = 32, + + FILEACCESS_PSP_FLAGS = 63, // Sum of all the above. + + // Non-PSP flags + FILEACCESS_PPSSPP_QUIET = 128, }; enum FileMove { diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index 49ddcc892b..26c2824f50 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -581,8 +581,12 @@ size_t MetaFileSystem::SeekFile(u32 handle, s32 position, FileMove type) return 0; } -int MetaFileSystem::ReadEntireFile(const std::string &filename, std::vector &data) { - int handle = OpenFile(filename, FILEACCESS_READ); +int MetaFileSystem::ReadEntireFile(const std::string &filename, std::vector &data, bool quiet) { + FileAccess access = FILEACCESS_READ; + if (quiet) { + access = (FileAccess)(access | FILEACCESS_PPSSPP_QUIET); + } + int handle = OpenFile(filename, access); if (handle < 0) return handle; diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index e574423dd6..bd18bfaf22 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -129,7 +129,7 @@ public: u64 FreeSpace(const std::string &path) override; // Convenience helper - returns < 0 on failure. - int ReadEntireFile(const std::string &filename, std::vector &data); + int ReadEntireFile(const std::string &filename, std::vector &data, bool quiet = false); void SetStartingDirectory(const std::string &dir) { std::lock_guard guard(lock); diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index 5c5a6714e2..e02184ad81 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -340,7 +340,7 @@ int VirtualDiscFileSystem::OpenFile(std::string filename, FileAccess access, con return newHandle; } - if (filename.compare(0,8,"/sce_lbn") == 0) + if (filename.compare(0, 8, "/sce_lbn") == 0) { u32 sectorStart = 0xFFFFFFFF, readSize = 0xFFFFFFFF; parseLBN(filename, §orStart, &readSize); @@ -365,11 +365,13 @@ int VirtualDiscFileSystem::OpenFile(std::string filename, FileAccess access, con bool success = entry.Open(basePath, fileList[entry.fileIndex].fileName, FILEACCESS_READ); if (!success) { + if (!(access & FILEACCESS_PPSSPP_QUIET)) { #ifdef _WIN32 - ERROR_LOG(FILESYS, "VirtualDiscFileSystem::OpenFile: FAILED, %i", (int)GetLastError()); + ERROR_LOG(FILESYS, "VirtualDiscFileSystem::OpenFile: FAILED, %i", (int)GetLastError()); #else - ERROR_LOG(FILESYS, "VirtualDiscFileSystem::OpenFile: FAILED"); + ERROR_LOG(FILESYS, "VirtualDiscFileSystem::OpenFile: FAILED"); #endif + } return 0; } @@ -388,15 +390,16 @@ int VirtualDiscFileSystem::OpenFile(std::string filename, FileAccess access, con if (entry.fileIndex != (u32)-1 && fileList[entry.fileIndex].handler != NULL) { entry.handler = fileList[entry.fileIndex].handler; } - bool success = entry.Open(basePath, filename, access); + bool success = entry.Open(basePath, filename, (FileAccess)(access & FILEACCESS_PSP_FLAGS)); if (!success) { + if (!(access & FILEACCESS_PPSSPP_QUIET)) { #ifdef _WIN32 - ERROR_LOG(FILESYS, "VirtualDiscFileSystem::OpenFile: FAILED, %i - access = %i", (int)GetLastError(), (int)access); + ERROR_LOG(FILESYS, "VirtualDiscFileSystem::OpenFile: FAILED, %i - access = %i", (int)GetLastError(), (int)access); #else - ERROR_LOG(FILESYS, "VirtualDiscFileSystem::OpenFile: FAILED, access = %i", (int)access); + ERROR_LOG(FILESYS, "VirtualDiscFileSystem::OpenFile: FAILED, access = %i", (int)access); #endif - //wwwwaaaaahh!! + } return SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND; } else { u32 newHandle = hAlloc->GetNewHandle(); diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp index d0b23ece26..48e612f9fa 100644 --- a/Core/HLE/sceFont.cpp +++ b/Core/HLE/sceFont.cpp @@ -891,12 +891,12 @@ static void __LoadInternalFonts() { bool bufferRead = false; std::string fontFilename = gameFontPath + entry.fileName; - bufferRead = pspFileSystem.ReadEntireFile(fontFilename, buffer) >= 0; + bufferRead = pspFileSystem.ReadEntireFile(fontFilename, buffer, true) >= 0; if (!bufferRead) { // No game font, let's try override path. fontFilename = fontOverridePath + entry.fileName; - bufferRead = pspFileSystem.ReadEntireFile(fontFilename, buffer) >= 0; + bufferRead = pspFileSystem.ReadEntireFile(fontFilename, buffer, true) >= 0; } if (!bufferRead) {