diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index ae150c4f79..c17d374fe5 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -137,14 +137,17 @@ std::vector fmt::split(const std::string& source, std::initializer_ std::string fmt::merge(std::vector source, const std::string& separator) { + if (!source.size()) + return ""; + std::string result; - for (auto &s : source) + for (int i = 0; i < source.size() - 1; ++i) { - result += s + separator; + result += source[i] + separator; } - return result; + return result + source[source.size() - 1]; } std::string fmt::merge(std::initializer_list> sources, const std::string& separator) diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index d963d9c91f..01489759a6 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -32,21 +32,12 @@ std::string simplify_path(const std::string& path, bool is_dir) { std::vector path_blocks = simplify_path_blocks(path); - std::string result; - if (path_blocks.empty()) - return result; + return ""; - if (is_dir) - { - result = fmt::merge(path_blocks, "/"); - } - else - { - result = fmt::merge(std::vector(path_blocks.begin(), path_blocks.end() - 1), "/") + path_blocks[path_blocks.size() - 1]; - } + std::string result = fmt::merge(path_blocks, "/"); - return result; + return is_dir ? result + "/" : result; } VFS::~VFS() diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index 227d43ca96..30fdb0533d 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -30,7 +30,7 @@ int cellGameBootCheck(vm::ptr type, vm::ptr attributes, vm::ptrsysSizeKB = 0; } - vfsFile f("/app_home/../PARAM.SFO"); + vfsFile f("/app_home/../../PARAM.SFO"); if (!f.IsOpened()) { cellGame->Error("cellGameBootCheck(): CELL_GAME_ERROR_ACCESS_ERROR (cannot open PARAM.SFO)"); @@ -100,7 +100,7 @@ int cellGamePatchCheck(vm::ptr size, u32 reserved_addr) size->sysSizeKB = 0; } - vfsFile f("/app_home/../PARAM.SFO"); + vfsFile f("/app_home/../../PARAM.SFO"); if (!f.IsOpened()) { cellGame->Error("cellGamePatchCheck(): CELL_GAME_ERROR_ACCESS_ERROR (cannot open PARAM.SFO)"); @@ -335,7 +335,7 @@ int cellGameGetParamInt(u32 id, vm::ptr value) cellGame->Warning("cellGameGetParamInt(id=%d, value_addr=0x%x)", id, value.addr()); // TODO: Access through cellGame***Check functions - vfsFile f("/app_home/../PARAM.SFO"); + vfsFile f("/app_home/../../PARAM.SFO"); PSFLoader psf(f); if(!psf.Load(false)) return CELL_GAME_ERROR_FAILURE; @@ -358,7 +358,7 @@ int cellGameGetParamString(u32 id, vm::ptr buf, u32 bufsize) cellGame->Warning("cellGameGetParamString(id=%d, buf_addr=0x%x, bufsize=%d)", id, buf.addr(), bufsize); // TODO: Access through cellGame***Check functions - vfsFile f("/app_home/../PARAM.SFO"); + vfsFile f("/app_home/../../PARAM.SFO"); PSFLoader psf(f); if(!psf.Load(false)) return CELL_GAME_ERROR_FAILURE; diff --git a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp index 0cfbcf4f75..0b2f5331de 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNpTrophy.cpp @@ -96,7 +96,7 @@ int sceNpTrophyCreateContext(vm::ptr context, vm::ptr // TODO: There are other possible errors // TODO: Is the TROPHY.TRP file necessarily located in this path? - vfsDir dir("/app_home/../TROPDIR/"); + vfsDir dir("/app_home/../../TROPDIR/"); if(!dir.IsOpened()) return SCE_NP_TROPHY_ERROR_CONF_DOES_NOT_EXIST; @@ -105,7 +105,7 @@ int sceNpTrophyCreateContext(vm::ptr context, vm::ptr { if (entry->flags & DirEntry_TypeDir) { - vfsStream* stream = Emu.GetVFS().OpenFile("/app_home/../TROPDIR/" + entry->name + "/TROPHY.TRP", vfsRead); + vfsStream* stream = Emu.GetVFS().OpenFile("/app_home/../../TROPDIR/" + entry->name + "/TROPHY.TRP", vfsRead); if (stream && stream->IsOpened()) {