Fix mounting bdvd when elf in subdirectory

Causes MGS4 to boot further
This commit is contained in:
Cornee Traas 2017-03-16 23:04:43 +01:00 committed by Ivan
parent 0fba38f691
commit 901f503a3a

View File

@ -226,8 +226,8 @@ void Emulator::Load()
// Mount all devices
const std::string emu_dir_ = g_cfg_vfs_emulator_dir;
const std::string emu_dir = emu_dir_.empty() ? fs::get_config_dir() : emu_dir_;
const std::string bdvd_dir = g_cfg_vfs_dev_bdvd;
const std::string home_dir = g_cfg_vfs_app_home;
std::string bdvd_dir = g_cfg_vfs_dev_bdvd;
vfs::mount("dev_hdd0", fmt::replace_all(g_cfg_vfs_dev_hdd0, "$(EmulatorDir)", emu_dir));
vfs::mount("dev_hdd1", fmt::replace_all(g_cfg_vfs_dev_hdd1, "$(EmulatorDir)", emu_dir));
@ -237,25 +237,18 @@ void Emulator::Load()
vfs::mount("app_home", home_dir.empty() ? elf_dir + '/' : fmt::replace_all(home_dir, "$(EmulatorDir)", emu_dir));
// Mount /dev_bdvd/ if necessary
if (bdvd_dir.empty() && fs::is_file(elf_dir + "/../../PS3_DISC.SFB"))
if (bdvd_dir.empty())
{
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")
{
vfs::mount("dev_bdvd", elf_dir.substr(0, elf_dir.length() - 15));
size_t pos = elf_dir.rfind("PS3_GAME");
std::string temp = elf_dir.substr(0, pos);
if ((pos != std::string::npos) && fs::is_file(temp + "/PS3_DISC.SFB")) {
bdvd_dir = temp;
}
else
{
vfs::mount("dev_bdvd", elf_dir + "/../../");
}
LOG_NOTICE(LOADER, "Disc: %s", vfs::get("/dev_bdvd"));
}
else if (bdvd_dir.size())
if (!bdvd_dir.empty() && fs::is_dir(bdvd_dir))
{
vfs::mount("dev_bdvd", fmt::replace_all(bdvd_dir, "$(EmulatorDir)", emu_dir));
LOG_NOTICE(LOADER, "Disc: %s", vfs::get("/dev_bdvd"));
}
// Mount /host_root/ if necessary