diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index 2a3ec02f7b..19bddf251e 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -286,15 +286,25 @@ void MetaFileSystem::Unmount(std::string prefix, IFileSystem *system) { fileSystems.erase(std::remove(fileSystems.begin(), fileSystems.end(), x), fileSystems.end()); } -void MetaFileSystem::Remount(std::string prefix, IFileSystem *newSystem, bool delOldSystem) { +void MetaFileSystem::Remount(std::string prefix, IFileSystem *newSystem) { std::lock_guard guard(lock); + IFileSystem *oldSystem = nullptr; for (auto &it : fileSystems) { if (it.prefix == prefix) { - if (delOldSystem) - delete it.system; + oldSystem = it.system; it.system = newSystem; } } + + bool delOldSystem = true; + for (auto &it : fileSystems) { + if (it.system == oldSystem) { + delOldSystem = false; + } + } + + if (delOldSystem) + delete oldSystem; } IFileSystem *MetaFileSystem::GetSystemFromFilename(const std::string &filename) { diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index 3fa2d16063..c4bfd8d37f 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -52,7 +52,7 @@ public: void Mount(std::string prefix, IFileSystem *system); void Unmount(std::string prefix, IFileSystem *system); - void Remount(std::string prefix, IFileSystem *newSystem, bool delOldSystem = true); + void Remount(std::string prefix, IFileSystem *newSystem); IFileSystem *GetSystem(const std::string &prefix); IFileSystem *GetSystemFromFilename(const std::string &filename); diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index ef4ca333e2..d200bb4e0f 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -1977,9 +1977,6 @@ static int sceIoChangeAsyncPriority(int id, int priority) { return hleLogSuccessI(SCEIO, 0); } - if (priority == -1) - priority = KernelCurThreadPriority(); - u32 error; FileNode *f = __IoGetFd(id, error); if (!f) { diff --git a/Core/HLE/sceUmd.cpp b/Core/HLE/sceUmd.cpp index dcdfd88d93..3ebbaef092 100644 --- a/Core/HLE/sceUmd.cpp +++ b/Core/HLE/sceUmd.cpp @@ -495,7 +495,7 @@ static u32 sceUmdGetErrorStat() } void __UmdReplace(std::string filepath) { - char *error = ""; + std::string error = ""; if (!UmdReplace(filepath, error)) { ERROR_LOG(SCEIO, "UMD Replace failed: %s", error); return; diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index dd898f4ac9..a4d102e122 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -356,7 +356,7 @@ bool LoadFile(FileLoader **fileLoaderPtr, std::string *error_string) { return false; } -bool UmdReplace(std::string filepath, char *error) { +bool UmdReplace(std::string filepath, std::string &error) { IFileSystem* currentUMD = pspFileSystem.GetSystem("disc0:"); if (!currentUMD) { @@ -368,7 +368,7 @@ bool UmdReplace(std::string filepath, char *error) { if (!loadedFile->Exists()) { delete loadedFile; - sprintf(error, "%s doesn't exist", loadedFile->Path().c_str()); + error = loadedFile->Path() + " doesn't exist"; return false; } UpdateLoadedFile(loadedFile); @@ -387,7 +387,7 @@ bool UmdReplace(std::string filepath, char *error) { break; default: - sprintf(error, "Unsupported file type: %i", type); + error = "Unsupported file type:" + std::to_string((int)type); return false; break; } diff --git a/Core/Loaders.h b/Core/Loaders.h index 9d114b446d..a076cfa675 100644 --- a/Core/Loaders.h +++ b/Core/Loaders.h @@ -159,4 +159,4 @@ void RegisterFileLoaderFactory(std::string name, std::unique_ptrIsDirectory()) { fileSystem = new VirtualDiscFileSystem(&pspFileSystem, fileLoader->Path()); blockSystem = fileSystem; @@ -155,8 +155,7 @@ bool ReInitMemoryForGameISO(FileLoader *fileLoader) { if (fileLoader->IsDirectory()) { fileSystem = new VirtualDiscFileSystem(&pspFileSystem, fileLoader->Path()); blockSystem = fileSystem; - } - else { + } else { auto bd = constructBlockDevice(fileLoader); if (!bd) return false; @@ -166,15 +165,11 @@ bool ReInitMemoryForGameISO(FileLoader *fileLoader) { blockSystem = new ISOBlockSystem(iso); } - if (pspFileSystem.GetSystem("disc0:") != pspFileSystem.GetSystem("umd0:")) { - // We mounted an ISO block system separately. - pspFileSystem.Remount("umd0:", blockSystem, false); - pspFileSystem.Remount("umd1:", blockSystem, false); + pspFileSystem.Remount("umd0:", blockSystem); + pspFileSystem.Remount("umd1:", blockSystem); pspFileSystem.Remount("umd:", blockSystem); - } - - pspFileSystem.Remount("disc0:", fileSystem); - + pspFileSystem.Remount("disc0:", fileSystem); + return true; }