From b7ad74d3098c654dabd8709ca8be47f9c4f95337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 24 Feb 2026 15:01:36 +0100 Subject: [PATCH] MetaFileSystem: Turn another argument into string_view --- Core/FileSystems/BlobFileSystem.cpp | 2 +- Core/FileSystems/BlobFileSystem.h | 2 +- Core/FileSystems/DirectoryFileSystem.cpp | 6 +++--- Core/FileSystems/DirectoryFileSystem.h | 4 ++-- Core/FileSystems/FileSystem.h | 4 ++-- Core/FileSystems/ISOFileSystem.cpp | 2 +- Core/FileSystems/ISOFileSystem.h | 4 ++-- Core/FileSystems/MetaFileSystem.cpp | 2 +- Core/FileSystems/MetaFileSystem.h | 2 +- Core/FileSystems/VirtualDiscFileSystem.cpp | 14 +++++++------- Core/FileSystems/VirtualDiscFileSystem.h | 2 +- android/jni/app-android.cpp | 10 ++++++---- 12 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Core/FileSystems/BlobFileSystem.cpp b/Core/FileSystems/BlobFileSystem.cpp index 0843ce440e..1060844bf4 100644 --- a/Core/FileSystems/BlobFileSystem.cpp +++ b/Core/FileSystems/BlobFileSystem.cpp @@ -30,7 +30,7 @@ void BlobFileSystem::DoState(PointerWrap &p) { // Not used in real emulation. } -std::vector BlobFileSystem::GetDirListing(const std::string &path, bool *exists) { +std::vector BlobFileSystem::GetDirListing(std::string_view path, bool *exists) { std::vector listing; listing.push_back(GetFileInfo(alias_)); if (exists) diff --git a/Core/FileSystems/BlobFileSystem.h b/Core/FileSystems/BlobFileSystem.h index 256710d0e5..1d8f96c84d 100644 --- a/Core/FileSystems/BlobFileSystem.h +++ b/Core/FileSystems/BlobFileSystem.h @@ -34,7 +34,7 @@ public: ~BlobFileSystem(); void DoState(PointerWrap &p) override; - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index a459b125dc..3534e301cd 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -873,7 +873,7 @@ bool DirectoryFileSystem::ComputeRecursiveDirSizeIfFast(const std::string &path, } } -std::vector DirectoryFileSystem::GetDirListing(const std::string &path, bool *exists) { +std::vector DirectoryFileSystem::GetDirListing(std::string_view path, bool *exists) { std::vector myVector; std::vector files; @@ -884,7 +884,7 @@ std::vector DirectoryFileSystem::GetDirListing(const std::string &p if (this->flags & FileSystemFlags::CASE_SENSITIVE) { if (!success) { // TODO: Case sensitivity should be checked on a file system basis, right? - std::string fixedPath = path; + std::string fixedPath(path); if (FixPathCase(basePath, fixedPath, FPC_FILE_MUST_EXIST)) { // May have failed due to case sensitivity, try again localPath = GetLocalPath(fixedPath); @@ -1204,7 +1204,7 @@ size_t VFSFileSystem::SeekFile(u32 handle, s32 position, FileMove type) { } } -std::vector VFSFileSystem::GetDirListing(const std::string &path, bool *exists) { +std::vector VFSFileSystem::GetDirListing(std::string_view path, bool *exists) { std::vector myVector; // TODO if (exists) diff --git a/Core/FileSystems/DirectoryFileSystem.h b/Core/FileSystems/DirectoryFileSystem.h index ffac242911..6761d48e52 100644 --- a/Core/FileSystems/DirectoryFileSystem.h +++ b/Core/FileSystems/DirectoryFileSystem.h @@ -67,7 +67,7 @@ public: void CloseAll(); void DoState(PointerWrap &p) override; - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; @@ -115,7 +115,7 @@ public: ~VFSFileSystem(); void DoState(PointerWrap &p) override; - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; diff --git a/Core/FileSystems/FileSystem.h b/Core/FileSystems/FileSystem.h index 90dfc50649..90cae79131 100644 --- a/Core/FileSystems/FileSystem.h +++ b/Core/FileSystems/FileSystem.h @@ -134,7 +134,7 @@ public: virtual ~IFileSystem() {} virtual void DoState(PointerWrap &p) = 0; - virtual std::vector GetDirListing(const std::string &path, bool *exists = nullptr) = 0; + virtual std::vector GetDirListing(std::string_view path, bool *exists = nullptr) = 0; virtual int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) = 0; virtual void CloseFile(u32 handle) = 0; virtual size_t ReadFile(u32 handle, u8 *pointer, s64 size) = 0; @@ -161,7 +161,7 @@ public: class EmptyFileSystem : public IFileSystem { public: void DoState(PointerWrap &p) override {} - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override { + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override { if (exists) *exists = false; std::vector vec; diff --git a/Core/FileSystems/ISOFileSystem.cpp b/Core/FileSystems/ISOFileSystem.cpp index 38e2c7b8b5..dc1c640d43 100644 --- a/Core/FileSystems/ISOFileSystem.cpp +++ b/Core/FileSystems/ISOFileSystem.cpp @@ -659,7 +659,7 @@ PSPFileInfo ISOFileSystem::GetFileInfoByHandle(u32 handle) { return x; } -std::vector ISOFileSystem::GetDirListing(const std::string &path, bool *exists) { +std::vector ISOFileSystem::GetDirListing(std::string_view path, bool *exists) { std::vector myVector; const TreeEntry *entry = GetFromPath(path); if (!entry) { diff --git a/Core/FileSystems/ISOFileSystem.h b/Core/FileSystems/ISOFileSystem.h index c07a5616af..0cc4a1f1a5 100644 --- a/Core/FileSystems/ISOFileSystem.h +++ b/Core/FileSystems/ISOFileSystem.h @@ -32,7 +32,7 @@ public: ~ISOFileSystem(); void DoState(PointerWrap &p) override; - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; @@ -114,7 +114,7 @@ public: isoFileSystem_->DoState(p); } - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override { + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override { if (exists) *exists = true; return std::vector(); diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index a0b2a56e63..12053c1851 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -364,7 +364,7 @@ PSPFileInfo MetaFileSystem::GetFileInfoByHandle(u32 handle) { return PSPFileInfo(); } -std::vector MetaFileSystem::GetDirListing(const std::string &path, bool *exists) { +std::vector MetaFileSystem::GetDirListing(std::string_view path, bool *exists) { std::lock_guard guard(lock); std::string of; IFileSystem *system; diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index 4ae4dd5d50..c0362be8e9 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -109,7 +109,7 @@ public: std::string NormalizePrefix(std::string_view prefix) const; - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index 35e4164523..baa5dcdacc 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -652,7 +652,7 @@ static void tmFromFiletime(tm &dest, const FILETIME &src) } #endif -std::vector VirtualDiscFileSystem::GetDirListing(const std::string &path, bool *exists) { +std::vector VirtualDiscFileSystem::GetDirListing(std::string_view pathStr, bool *exists) { std::vector myVector; // TODO(scoped): Switch this over to GetFilesInDir! @@ -663,7 +663,7 @@ std::vector VirtualDiscFileSystem::GetDirListing(const std::string // TODO: Handler files that are virtual might not be listed. - std::wstring w32path = GetLocalPath(path).ToWString() + L"\\*.*"; + std::wstring w32path = GetLocalPath(pathStr).ToWString() + L"\\*.*"; #if PPSSPP_PLATFORM(UWP) hFind = FindFirstFileExFromAppW(w32path.c_str(), FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0); @@ -700,7 +700,7 @@ std::vector VirtualDiscFileSystem::GetDirListing(const std::string tmFromFiletime(entry.mtime, findData.ftLastWriteTime); entry.isOnSectorSystem = true; - std::string fullRelativePath = path + "/" + entry.name; + std::string fullRelativePath = std::string(pathStr) + "/" + entry.name; int fileIndex = getFileListIndex(fullRelativePath); if (fileIndex != -1) entry.startSector = fileList[fileIndex].firstBlock; @@ -709,11 +709,11 @@ std::vector VirtualDiscFileSystem::GetDirListing(const std::string FindClose(hFind); #else dirent *dirp; - Path localPath = GetLocalPath(path); + Path localPath = GetLocalPath(pathStr); DIR *dp = opendir(localPath.c_str()); #if HOST_IS_CASE_SENSITIVE - std::string fixedPath = path; + std::string fixedPath(pathStr); if(dp == NULL && FixPathCase(basePath, fixedPath, FPC_FILE_MUST_EXIST)) { // May have failed due to case sensitivity, try again localPath = GetLocalPath(fixedPath); @@ -722,7 +722,7 @@ std::vector VirtualDiscFileSystem::GetDirListing(const std::string #endif if (dp == NULL) { - ERROR_LOG(Log::FileSystem,"Error opening directory %s\n", path.c_str()); + ERROR_LOG(Log::FileSystem,"Error opening directory %.*s\n", STR_VIEW(pathStr)); if (exists) *exists = false; return myVector; @@ -753,7 +753,7 @@ std::vector VirtualDiscFileSystem::GetDirListing(const std::string localtime_r((time_t*)&s.st_mtime,&entry.mtime); entry.isOnSectorSystem = true; - std::string fullRelativePath = path + "/" + entry.name; + std::string fullRelativePath = std::string(pathStr) + "/" + entry.name; int fileIndex = getFileListIndex(fullRelativePath); if (fileIndex != -1) entry.startSector = fileList[fileIndex].firstBlock; diff --git a/Core/FileSystems/VirtualDiscFileSystem.h b/Core/FileSystems/VirtualDiscFileSystem.h index 987ea01ffa..00fb4ada5d 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.h +++ b/Core/FileSystems/VirtualDiscFileSystem.h @@ -43,7 +43,7 @@ public: bool OwnsHandle(u32 handle) override; int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override; PSPDevType DevType(u32 handle) override; - std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; + std::vector GetDirListing(std::string_view path, bool *exists = nullptr) override; FileSystemFlags Flags() const override { return FileSystemFlags::UMD; } u64 FreeDiskSpace(const std::string &path) override { return 0; } diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index cefeaa6a00..d511aa5554 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -125,9 +125,8 @@ static std::atomic emuThreadState((int)EmuThreadState::DISABLED); AndroidAudioState *g_audioState; struct FrameCommand { - FrameCommand() {} - FrameCommand(std::string cmd, std::string prm) : command(cmd), params(prm) {} - + FrameCommand() = default; + FrameCommand(std::string_view cmd, std::string_view param) : command(cmd), params(param) {} std::string command; std::string params; }; @@ -354,7 +353,7 @@ static void PushCommand(std::string_view cmd, std::string_view param) { // Android implementation of callbacks to the Java part of the app void System_Toast(std::string_view text) { - PushCommand("toast", std::string(text)); + PushCommand("toast", text); } void System_ShowKeyboard() { @@ -372,6 +371,9 @@ void System_LaunchUrl(LaunchUrlType urlType, std::string_view url) { case LaunchUrlType::BROWSER_URL: PushCommand("launchBrowser", url); break; case LaunchUrlType::MARKET_URL: PushCommand("launchMarket", url); break; case LaunchUrlType::EMAIL_ADDRESS: PushCommand("launchEmail", url); break; + // Can't really support the below well on Android... + case LaunchUrlType::LOCAL_FOLDER: break; + case LaunchUrlType::LOCAL_FILE: break; } }