This commit is contained in:
shenweip 2020-01-04 09:11:15 +08:00
parent 44660bd9ae
commit 9fa4ae7b15
7 changed files with 25 additions and 23 deletions

View File

@ -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<std::recursive_mutex> 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) {

View File

@ -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);

View File

@ -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) {

View File

@ -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;

View File

@ -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;
}

View File

@ -159,4 +159,4 @@ void RegisterFileLoaderFactory(std::string name, std::unique_ptr<FileLoaderFacto
// Can modify the string filename, as it calls IdentifyFile above.
bool LoadFile(FileLoader **fileLoaderPtr, std::string *error_string);
bool UmdReplace(std::string filepath, char* error);
bool UmdReplace(std::string filepath, std::string &error);

View File

@ -83,7 +83,7 @@ void InitMemoryForGameISO(FileLoader *fileLoader) {
IFileSystem *fileSystem = nullptr;
IFileSystem *blockSystem = nullptr;
//bool actualIso = false;
if (fileLoader->IsDirectory()) {
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;
}