MetaFileSystem: Turn another argument into string_view

This commit is contained in:
Henrik Rydgård
2026-02-24 15:01:36 +01:00
parent 22bfa0087c
commit b7ad74d309
12 changed files with 28 additions and 26 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ void BlobFileSystem::DoState(PointerWrap &p) {
// Not used in real emulation.
}
std::vector<PSPFileInfo> BlobFileSystem::GetDirListing(const std::string &path, bool *exists) {
std::vector<PSPFileInfo> BlobFileSystem::GetDirListing(std::string_view path, bool *exists) {
std::vector<PSPFileInfo> listing;
listing.push_back(GetFileInfo(alias_));
if (exists)
+1 -1
View File
@@ -34,7 +34,7 @@ public:
~BlobFileSystem();
void DoState(PointerWrap &p) override;
std::vector<PSPFileInfo> GetDirListing(const std::string &path, bool *exists = nullptr) override;
std::vector<PSPFileInfo> 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;
+3 -3
View File
@@ -873,7 +873,7 @@ bool DirectoryFileSystem::ComputeRecursiveDirSizeIfFast(const std::string &path,
}
}
std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(const std::string &path, bool *exists) {
std::vector<PSPFileInfo> DirectoryFileSystem::GetDirListing(std::string_view path, bool *exists) {
std::vector<PSPFileInfo> myVector;
std::vector<File::FileInfo> files;
@@ -884,7 +884,7 @@ std::vector<PSPFileInfo> 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<PSPFileInfo> VFSFileSystem::GetDirListing(const std::string &path, bool *exists) {
std::vector<PSPFileInfo> VFSFileSystem::GetDirListing(std::string_view path, bool *exists) {
std::vector<PSPFileInfo> myVector;
// TODO
if (exists)
+2 -2
View File
@@ -67,7 +67,7 @@ public:
void CloseAll();
void DoState(PointerWrap &p) override;
std::vector<PSPFileInfo> GetDirListing(const std::string &path, bool *exists = nullptr) override;
std::vector<PSPFileInfo> 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<PSPFileInfo> GetDirListing(const std::string &path, bool *exists = nullptr) override;
std::vector<PSPFileInfo> 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;
+2 -2
View File
@@ -134,7 +134,7 @@ public:
virtual ~IFileSystem() {}
virtual void DoState(PointerWrap &p) = 0;
virtual std::vector<PSPFileInfo> GetDirListing(const std::string &path, bool *exists = nullptr) = 0;
virtual std::vector<PSPFileInfo> 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<PSPFileInfo> GetDirListing(const std::string &path, bool *exists = nullptr) override {
std::vector<PSPFileInfo> GetDirListing(std::string_view path, bool *exists = nullptr) override {
if (exists)
*exists = false;
std::vector<PSPFileInfo> vec;
+1 -1
View File
@@ -659,7 +659,7 @@ PSPFileInfo ISOFileSystem::GetFileInfoByHandle(u32 handle) {
return x;
}
std::vector<PSPFileInfo> ISOFileSystem::GetDirListing(const std::string &path, bool *exists) {
std::vector<PSPFileInfo> ISOFileSystem::GetDirListing(std::string_view path, bool *exists) {
std::vector<PSPFileInfo> myVector;
const TreeEntry *entry = GetFromPath(path);
if (!entry) {
+2 -2
View File
@@ -32,7 +32,7 @@ public:
~ISOFileSystem();
void DoState(PointerWrap &p) override;
std::vector<PSPFileInfo> GetDirListing(const std::string &path, bool *exists = nullptr) override;
std::vector<PSPFileInfo> 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<PSPFileInfo> GetDirListing(const std::string &path, bool *exists = nullptr) override {
std::vector<PSPFileInfo> GetDirListing(std::string_view path, bool *exists = nullptr) override {
if (exists)
*exists = true;
return std::vector<PSPFileInfo>();
+1 -1
View File
@@ -364,7 +364,7 @@ PSPFileInfo MetaFileSystem::GetFileInfoByHandle(u32 handle) {
return PSPFileInfo();
}
std::vector<PSPFileInfo> MetaFileSystem::GetDirListing(const std::string &path, bool *exists) {
std::vector<PSPFileInfo> MetaFileSystem::GetDirListing(std::string_view path, bool *exists) {
std::lock_guard<std::recursive_mutex> guard(lock);
std::string of;
IFileSystem *system;
+1 -1
View File
@@ -109,7 +109,7 @@ public:
std::string NormalizePrefix(std::string_view prefix) const;
std::vector<PSPFileInfo> GetDirListing(const std::string &path, bool *exists = nullptr) override;
std::vector<PSPFileInfo> 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;
+7 -7
View File
@@ -652,7 +652,7 @@ static void tmFromFiletime(tm &dest, const FILETIME &src)
}
#endif
std::vector<PSPFileInfo> VirtualDiscFileSystem::GetDirListing(const std::string &path, bool *exists) {
std::vector<PSPFileInfo> VirtualDiscFileSystem::GetDirListing(std::string_view pathStr, bool *exists) {
std::vector<PSPFileInfo> myVector;
// TODO(scoped): Switch this over to GetFilesInDir!
@@ -663,7 +663,7 @@ std::vector<PSPFileInfo> 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<PSPFileInfo> 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<PSPFileInfo> 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<PSPFileInfo> 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<PSPFileInfo> 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;
+1 -1
View File
@@ -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<PSPFileInfo> GetDirListing(const std::string &path, bool *exists = nullptr) override;
std::vector<PSPFileInfo> 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; }
+6 -4
View File
@@ -125,9 +125,8 @@ static std::atomic<int> 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;
}
}