diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index f8046a8344..aa2404447b 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -15,13 +15,14 @@ std::vector simplify_path_blocks(const std::string& path) // fmt::tolower() removed std::vector path_blocks = std::move(fmt::split(path, { "/", "\\" })); - for (size_t i = 0; i < path_blocks.size(); ++i) + for (s32 i = 0; i < path_blocks.size(); ++i) { - if (path_blocks[i] == ".") + if (path_blocks[i] == "." || (i > 0 && path_blocks[i].empty())) { - path_blocks.erase(path_blocks.begin() + i--); + path_blocks.erase(path_blocks.begin() + i); + i--; } - else if (i && path_blocks[i] == "..") + else if (i > 0 && path_blocks[i] == "..") { path_blocks.erase(path_blocks.begin() + (i - 1), path_blocks.begin() + (i + 1)); i--; @@ -493,7 +494,6 @@ void VFS::SaveLoadDevices(std::vector& res, bool is_load) res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_flash/", "/dev_flash/"); res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_usb000/", "/dev_usb000/"); res.emplace_back(vfsDevice_LocalFile, "$(EmulatorDir)/dev_usb000/", "/dev_usb/"); - res.emplace_back(vfsDevice_LocalFile, "$(GameDir)/../../", "/dev_bdvd/"); res.emplace_back(vfsDevice_LocalFile, "", "/host_root/"); return; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index fe2f9edc80..eee6d1025b 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -222,6 +222,29 @@ void Emulator::Load() GetInfo().Reset(); GetVFS().Init(elf_dir); + // /dev_bdvd/ mounting + vfsFile f("/app_home/../dev_bdvd.path"); + if (f.IsOpened()) + { + // load specified /dev_bdvd/ directory and mount it + std::string bdvd; + bdvd.resize(f.GetSize()); + f.Read(&bdvd[0], bdvd.size()); + + Emu.GetVFS().Mount("/dev_bdvd/", bdvd, new vfsDeviceLocalFile()); + } + else if (rIsFile(elf_dir + "../../PS3_DISC.SFB")) // guess loading disc game + { + const auto dir_list = fmt::split(elf_dir, { "/", "\\" }); + + // check latest two directories + if (dir_list.size() >= 2 && dir_list.back() == "USRDIR" && *(dir_list.end() - 2) == "PS3_GAME") + { + // mount detected /dev_bdvd/ directory + Emu.GetVFS().Mount("/dev_bdvd/", elf_dir.substr(0, elf_dir.length() - 17), new vfsDeviceLocalFile()); + } + } + LOG_NOTICE(LOADER, " "); //used to be skip_line LOG_NOTICE(LOADER, "Mount info:"); for (uint i = 0; i < GetVFS().m_devices.size(); ++i) @@ -230,7 +253,7 @@ void Emulator::Load() } LOG_NOTICE(LOADER, " "); //used to be skip_line - vfsFile f("/app_home/../PARAM.SFO"); + f.Open("/app_home/../PARAM.SFO"); const PSFLoader psf(f); std::string title = psf.GetString("TITLE"); std::string title_id = psf.GetString("TITLE_ID"); @@ -240,23 +263,13 @@ void Emulator::Load() title.length() ? SetTitle(title) : SetTitle(m_path); SetTitleID(title_id); - // bdvd inserting imitation - f.Open("/app_home/../dev_bdvd.path"); - if (f.IsOpened()) - { - std::string bdvd; - bdvd.resize(f.GetSize()); - f.Read(&bdvd[0], bdvd.size()); - - // load desired /dev_bdvd/ real directory and remount - Emu.GetVFS().Mount("/dev_bdvd/", bdvd, new vfsDeviceLocalFile()); - LOG_NOTICE(LOADER, "/dev_bdvd/ remounted into %s", bdvd.c_str()); - } - LOG_NOTICE(LOADER, " "); //used to be skip_line - if (m_elf_path.empty()) { - GetVFS().GetDeviceLocal(m_path, m_elf_path); + if (!GetVFS().GetDeviceLocal(m_path, m_elf_path)) + { + m_elf_path = "/host_root/" + m_path; // should be probably app_home + } + LOG_NOTICE(LOADER, "Elf path: %s", m_elf_path); }