From e9d5e451fbce563b3336be9a90fb8305c82fc41d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 31 May 2026 22:29:03 +0200 Subject: [PATCH] Avoid some unnecessary error reporting while loading ISOs for the file browser --- Core/FileSystems/BlockDevices.cpp | 5 +++++ Core/FileSystems/ISOFileSystem.cpp | 16 ++++++++++------ Core/FileSystems/ISOFileSystem.h | 11 +++++++---- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Core/FileSystems/BlockDevices.cpp b/Core/FileSystems/BlockDevices.cpp index ed3083f6ad..8d16bb57d3 100644 --- a/Core/FileSystems/BlockDevices.cpp +++ b/Core/FileSystems/BlockDevices.cpp @@ -411,6 +411,11 @@ ISOContainerFileBlockDevice::ISOContainerFileBlockDevice(FileLoader *fileLoader) SequentialHandleAllocator alloc; ISOFileSystem iso(&alloc, outerBlockDevice_); + if (!iso.Error().empty()) { + errorString_ = iso.Error(); + outerBlockDevice_.reset(); + return; + } PSPFileInfo layer0Info = iso.GetFileInfo("/USER_L0.IMG"); if (!layer0Info.exists) { diff --git a/Core/FileSystems/ISOFileSystem.cpp b/Core/FileSystems/ISOFileSystem.cpp index e051503664..cb77c57076 100644 --- a/Core/FileSystems/ISOFileSystem.cpp +++ b/Core/FileSystems/ISOFileSystem.cpp @@ -154,8 +154,17 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, std::shared_ptrReadBlock(16, (u8*)&desc)) + if (!blockDevice->ReadBlock(16, (u8*)&desc)) { + // TODO: This is kinda wacky. blockDevice->NotifyReadError(); + errorString_ = "ISO: error reading volume descriptor"; + return; + } + + if (memcmp(desc.cd001, "CD001", 5)) { + errorString_ = "ISO: missing CD001 signature"; + return; + } entireISO.name.clear(); entireISO.isDirectory = false; @@ -172,11 +181,6 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, std::shared_ptrparent = NULL; treeroot->valid = false; - if (memcmp(desc.cd001, "CD001", 5)) { - ERROR_LOG(Log::FileSystem, "ISO looks bogus, expected CD001 signature not present? Giving up..."); - return; - } - treeroot->startsector = desc.root.firstDataSector; treeroot->dirsize = desc.root.dataLength; } diff --git a/Core/FileSystems/ISOFileSystem.h b/Core/FileSystems/ISOFileSystem.h index f94746ebc2..c59c6d884a 100644 --- a/Core/FileSystems/ISOFileSystem.h +++ b/Core/FileSystems/ISOFileSystem.h @@ -58,6 +58,8 @@ public: void Describe(char *buf, size_t size) const override { snprintf(buf, size, "ISO"); } // TODO: Ask the fileLoader about the origins std::shared_ptr GetBlockDevice() override { return blockDevice; } + + const std::string &Error() const { return errorString_; } private: struct TreeEntry { ~TreeEntry(); @@ -91,12 +93,13 @@ private: typedef std::map EntryMap; EntryMap entries; - IHandleAllocator *hAlloc; - TreeEntry *treeroot; + IHandleAllocator *hAlloc = nullptr; + TreeEntry *treeroot = nullptr; std::shared_ptr blockDevice; - mutable u32 lastReadBlock_; + mutable u32 lastReadBlock_ = 0; - TreeEntry entireISO; + TreeEntry entireISO{}; + std::string errorString_; void ReadDirectory(TreeEntry *root) const; const TreeEntry *GetFromPath(std::string_view path, bool catchError = true);