From 1910be0b47c1bea743fef16e656a34d7f0eda390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 20 Aug 2026 00:53:47 +0200 Subject: [PATCH] Fix booting from extracted directories specified on the command line, reported by Kotcrab --- Core/FileLoaders/LocalFileLoader.cpp | 17 +++++++++-------- Core/FileLoaders/LocalFileLoader.h | 5 ++++- Core/System.cpp | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Core/FileLoaders/LocalFileLoader.cpp b/Core/FileLoaders/LocalFileLoader.cpp index f359e42c84..889c30d47e 100644 --- a/Core/FileLoaders/LocalFileLoader.cpp +++ b/Core/FileLoaders/LocalFileLoader.cpp @@ -63,6 +63,12 @@ LocalFileLoader::LocalFileLoader(const Path &filename) return; } + isDirectory_ = File::IsDirectory(filename); + if (isDirectory_) { + // Don't need to continue. + return; + } + #if PPSSPP_PLATFORM(ANDROID) && !defined(HAVE_LIBRETRO_VFS) if (filename.Type() == PathType::CONTENT_URI) { int fd = Android_OpenContentUriFd(filename.ToString(), Android_OpenContentUriMode::READ); @@ -150,6 +156,9 @@ LocalFileLoader::~LocalFileLoader() { } bool LocalFileLoader::Exists() { + if (isDirectory_) { + return true; + } // If we opened it for reading, it must exist. Done. #if defined(HAVE_LIBRETRO_VFS) return file_ != nullptr; @@ -162,14 +171,6 @@ bool LocalFileLoader::Exists() { #endif } -bool LocalFileLoader::IsDirectory() { - File::FileInfo info; - if (File::GetFileInfo(filename_, &info)) { - return info.exists && info.isDirectory; - } - return false; -} - s64 LocalFileLoader::FileSize() { return filesize_; } diff --git a/Core/FileLoaders/LocalFileLoader.h b/Core/FileLoaders/LocalFileLoader.h index f72a003d29..ae0cb60cd8 100644 --- a/Core/FileLoaders/LocalFileLoader.h +++ b/Core/FileLoaders/LocalFileLoader.h @@ -28,13 +28,15 @@ typedef void *HANDLE; #endif +// This one accepts directories as well as files. +// Later we handle the discrepancy in MountGameISO. class LocalFileLoader : public FileLoader { public: LocalFileLoader(const Path &filename); ~LocalFileLoader(); bool Exists() override; - bool IsDirectory() override; + bool IsDirectory() override { return isDirectory_; } s64 FileSize() override; Path GetPath() const override { return filename_; @@ -52,5 +54,6 @@ private: #endif u64 filesize_ = 0; Path filename_; + bool isDirectory_ = false; std::mutex readLock_; }; diff --git a/Core/System.cpp b/Core/System.cpp index 721b41e6d0..b1b4064bef 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -357,7 +357,7 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin case IdentifiedFileType::PSP_ISO: case IdentifiedFileType::PSP_ISO_NP: case IdentifiedFileType::PSP_DISC_DIRECTORY: - // Doesn't seem to take ownership of fileLoader? + // Doesn't take ownership of fileLoader. We store it in g_loadedFile later. if (!MountGameISO(fileLoader, errorString)) { *errorString = "Failed to mount ISO file: " + *errorString; return false;