Loaders: Look for PSP/GAME/ not /PSP/GAME/.

Because upcoming Path changes will affect path string comparisons.
This commit is contained in:
Henrik Rydgård 2021-05-09 17:50:59 -07:00 committed by Unknown W. Brackets
parent ac68dac029
commit cc3868db97
3 changed files with 12 additions and 6 deletions

View file

@ -337,7 +337,7 @@ bool DirectoryFileHandle::Open(const std::string &basePath, std::string &fileNam
#endif
// Try to detect reads/writes to PSP/GAME to avoid them in replays.
if (fullName.find("/PSP/GAME/") != fullName.npos || fullName.find("\\PSP\\GAME\\") != fullName.npos) {
if (fullName.find("PSP/GAME/") != fullName.npos || fullName.find("PSP\\GAME\\") != fullName.npos) {
inGameDir_ = true;
}

View file

@ -177,7 +177,7 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader) {
// If so we just move up and return the directory itself as the game.
std::string path = File::GetDir(fileLoader->GetPath());
// If loading from memstick...
size_t pos = path.find("/PSP/GAME/");
size_t pos = path.find("PSP/GAME/");
if (pos != std::string::npos) {
return IdentifiedFileType::PSP_PBP_DIRECTORY;
}
@ -260,10 +260,10 @@ bool LoadFile(FileLoader **fileLoaderPtr, std::string *error_string) {
return false;
}
std::string path = fileLoader->GetPath();
size_t pos = path.find("/PSP/GAME/");
size_t pos = path.find("PSP/GAME/");
if (pos != std::string::npos) {
path = ResolvePBPDirectory(path);
pspFileSystem.SetStartingDirectory("ms0:" + path.substr(pos));
pspFileSystem.SetStartingDirectory("ms0:/" + path.substr(pos));
}
return Load_PSP_ELF_PBP(fileLoader, error_string);
} else {

View file

@ -374,11 +374,17 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) {
std::string full_path = fileLoader->GetPath();
std::string path, file, extension;
SplitPath(ReplaceAll(full_path, "\\", "/"), &path, &file, &extension);
if (!path.empty() && path.back() == '/')
path.resize(path.size() - 1);
#ifdef _WIN32
if (!path.empty() && path.back() == '\\')
path.resize(path.size() - 1);
#endif
size_t pos = path.find("/PSP/GAME/");
size_t pos = path.find("PSP/GAME/");
std::string ms_path;
if (pos != std::string::npos) {
ms_path = "ms0:" + path.substr(pos);
ms_path = "ms0:/" + path.substr(pos) + "/";
} else {
// This is wrong, but it's better than not having a working directory at all.
// Note that umd0:/ is actually the writable containing directory, in this case.