Improve boot dir access

Add Emu.GetDir() method
This commit is contained in:
Nekotekina 2018-03-11 02:35:41 +03:00
parent c8a6bc6e24
commit f4d2fccdfe
5 changed files with 23 additions and 13 deletions

View file

@ -198,7 +198,7 @@ s32 cellHddGameGetSizeKB(vm::ptr<u32> size)
{
cellGame.warning("cellHddGameGetSizeKB(size=*0x%x)", size);
const std::string local_dir = vfs::get("/dev_hdd0/game/" + Emu.GetTitleID());
const std::string local_dir = vfs::get(Emu.GetDir());
if (!fs::is_dir(local_dir))
{
@ -226,7 +226,7 @@ s32 cellGameDataGetSizeKB(vm::ptr<u32> size)
{
cellGame.warning("cellGameDataGetSizeKB(size=*0x%x)", size);
const std::string local_dir = vfs::get("/dev_hdd0/game/" + Emu.GetTitleID());
const std::string local_dir = vfs::get(Emu.GetDir());
if (!fs::is_dir(local_dir))
{
@ -275,7 +275,7 @@ error_code cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr
*attributes = 0; // TODO
// TODO: dirName might be a read only string when BootCheck is called on a disc game. (e.g. Ben 10 Ultimate Alien: Cosmic Destruction)
if (!fxm::make<content_permission>("", psf::load_object(fs::file(vfs::get("/dev_bdvd/PS3_GAME/PARAM.SFO")))))
if (!fxm::make<content_permission>("", psf::load_object(fs::file(vfs::get(Emu.GetDir() + "PARAM.SFO")))))
{
return CELL_GAME_ERROR_BUSY;
}
@ -286,7 +286,7 @@ error_code cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr
*attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO
if (dirName) strcpy_trunc(*dirName, Emu.GetTitleID()); // ???
if (!fxm::make<content_permission>("", psf::load_object(fs::file(vfs::get("/dev_hdd0/game/" + Emu.GetTitleID() + "/PARAM.SFO")))))
if (!fxm::make<content_permission>("", psf::load_object(fs::file(vfs::get(Emu.GetDir() + "PARAM.SFO")))))
{
return CELL_GAME_ERROR_BUSY;
}
@ -297,7 +297,7 @@ error_code cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr
*attributes = 0; // TODO
if (dirName) strcpy_trunc(*dirName, Emu.GetTitleID());
if (!fxm::make<content_permission>(Emu.GetTitleID(), psf::load_object(fs::file(vfs::get("/dev_hdd0/game/" + Emu.GetTitleID() + "/PARAM.SFO")))))
if (!fxm::make<content_permission>(Emu.GetTitleID(), psf::load_object(fs::file(vfs::get(Emu.GetDir() + "PARAM.SFO")))))
{
return CELL_GAME_ERROR_BUSY;
}
@ -325,7 +325,7 @@ error_code cellGamePatchCheck(vm::ptr<CellGameContentSize> size, vm::ptr<void> r
return CELL_GAME_ERROR_NOTPATCH;
}
if (!fxm::make<content_permission>(Emu.GetTitleID(), psf::load_object(fs::file(vfs::get("/dev_hdd0/game/" + Emu.GetTitleID() + "/PARAM.SFO")))))
if (!fxm::make<content_permission>(Emu.GetTitleID(), psf::load_object(fs::file(vfs::get(Emu.GetDir() + "PARAM.SFO")))))
{
return CELL_GAME_ERROR_BUSY;
}
@ -360,7 +360,7 @@ error_code cellGameDataCheck(u32 type, vm::cptr<char> dirName, vm::ptr<CellGameC
return CELL_GAME_ERROR_BUSY;
}
const std::string dir = prm->dir.empty() ? "/dev_bdvd/PS3_GAME"s : "/dev_hdd0/game/" + prm->dir;
const std::string dir = prm->dir.empty() ? Emu.GetDir() : "/dev_hdd0/game/" + prm->dir;
if (!fs::is_dir(vfs::get(dir)))
{
@ -389,7 +389,7 @@ error_code cellGameContentPermit(vm::ptr<char[CELL_GAME_PATH_MAX]> contentInfoPa
return CELL_GAME_ERROR_FAILURE;
}
const std::string dir = prm->dir.empty() ? "/dev_bdvd/PS3_GAME"s : "/dev_hdd0/game/" + prm->dir;
const std::string dir = prm->dir.empty() ? Emu.GetDir() : "/dev_hdd0/game/" + prm->dir;
if (!prm->temp.empty())
{
@ -460,7 +460,7 @@ error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr<char>
cbGet->sizeKB = CELL_GAMEDATA_SIZEKB_NOTCALC;
cbGet->sysSizeKB = 0;
psf::registry sfo = psf::load_object(fs::file(vfs::get(Emu.GetCat() == "DG" ? "/dev_bdvd/PS3_GAME/PARAM.SFO"s : "/dev_hdd0/game/" + Emu.GetTitleID() + "/PARAM.SFO")));
psf::registry sfo = psf::load_object(fs::file(vfs::get(Emu.GetDir() + "PARAM.SFO")));
cbGet->getParam.attribute = CELL_GAMEDATA_ATTR_NORMAL;
cbGet->getParam.parentalLevel = psf::get_integer(sfo, "PARENTAL_LEVEL", 0);

View file

@ -196,9 +196,9 @@ error_code sceNpTrophyCreateContext(vm::ptr<u32> context, vm::cptr<SceNpCommunic
}
// open trophy pack file
fs::file stream(vfs::get("/dev_hdd0/game/" + Emu.GetTitleID() + "/TROPDIR/" + name + "/TROPHY.TRP"));
fs::file stream(vfs::get(Emu.GetDir() + "TROPDIR/" + name + "/TROPHY.TRP"));
if (!stream && (Emu.GetCat() == "DG" || Emu.GetCat() == "GD"))
if (!stream && Emu.GetCat() == "GD")
{
stream.open(vfs::get("/dev_bdvd/PS3_GAME/TROPDIR/" + name + "/TROPHY.TRP"));
}

View file

@ -290,8 +290,8 @@ void _sys_process_exit2(ppu_thread& ppu, s32 status, vm::ptr<sys_exit2_param> ar
if (Emu.GetCat() == "DG" || Emu.GetCat() == "GD")
disc = vfs::get("/dev_bdvd/");
else if (Emu.GetTitleID().size())
disc = vfs::get("/dev_hdd0/game/" + Emu.GetTitleID() + "/");
if (disc.empty() && Emu.GetTitleID().size())
disc = vfs::get(Emu.GetDir());
vm::temporary_unlock(ppu);

View file

@ -681,17 +681,21 @@ void Emulator::Load(bool add_only)
if (m_path.find(hdd0_game) != -1)
{
argv[0] = "/dev_hdd0/game/" + m_path.substr(hdd0_game.size());
m_dir = "/dev_hdd0/game/" + m_path.substr(hdd0_game.size(), 10);
LOG_NOTICE(LOADER, "Boot path: %s", m_dir);
}
else if (!bdvd_dir.empty() && fs::is_dir(bdvd_dir))
{
// Disc games are on /dev_bdvd/
const std::size_t pos = m_path.rfind("PS3_GAME");
argv[0] = "/dev_bdvd/" + m_path.substr(pos);
m_dir = "/dev_bdvd/PS3_GAME/";
}
else
{
// For homebrew
argv[0] = "/host_root/" + m_path;
m_dir = "/host_root/" + elf_dir + '/';
}
LOG_NOTICE(LOADER, "Elf path: %s", argv[0]);

View file

@ -178,6 +178,7 @@ class Emulator final
std::string m_title_id;
std::string m_title;
std::string m_cat;
std::string m_dir;
bool m_force_boot = false;
@ -241,6 +242,11 @@ public:
return m_cache_path;
}
const std::string& GetDir() const
{
return m_dir;
}
u64 GetPauseTime()
{
return m_pause_amend_time;