MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / cellGameDataCheck

Function cellGameDataCheck

ps3fw/cellGame.cpp:937–1022  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

935}
936
937error_code cellGameDataCheck(u32 type, vm::cptr<char> dirName,
938 vm::ptr<CellGameContentSize> size)
939{
940 cellGame.warning("cellGameDataCheck(type=%d, dirName=%s, size=*0x%x)", type,
941 dirName, size);
942
943 if ((type - 1) >= 3 || (type != CELL_GAME_GAMETYPE_DISC && !dirName))
944 {
945 return {CELL_GAME_ERROR_PARAM, type};
946 }
947
948 std::string name;
949
950 if (type != CELL_GAME_GAMETYPE_DISC)
951 {
952 name = dirName.get_ptr();
953 }
954
955 const std::string dir = type == CELL_GAME_GAMETYPE_DISC ? "/dev_bdvd/PS3_GAME"s : "/dev_hdd0/game/" + name;
956
957 // TODO: not sure what should be checked there
958
959 auto& perm = g_fxo->get<content_permission>();
960
961 auto init = acquire_lock(perm.init);
962
963 if (!init)
964 {
965 lv2_sleep(300);
966 return CELL_GAME_ERROR_BUSY;
967 }
968
969 // This function is incredibly slow, slower for DISC type and even if the
970 // game/disc data does not exist Null size does not change it
971 lv2_sleep(type == CELL_GAME_GAMETYPE_DISC ? 300000 : 120000);
972
973 auto [sfo, psf_error] = psf::load(vfs::get(dir + "/PARAM.SFO"));
974
975 if (const std::string_view cat = psf::get_string(sfo, "CATEGORY"); [&]()
976 {
977 switch (type)
978 {
979 case CELL_GAME_GAMETYPE_HDD:
980 return !psf::is_cat_hdd(cat);
981 case CELL_GAME_GAMETYPE_GAMEDATA:
982 return cat != "GD"sv;
983 case CELL_GAME_GAMETYPE_DISC:
984 return cat != "DG"sv;
985 default:
986 fmt::throw_exception("Unreachable");
987 }
988 }())
989 {
990 if (psf_error != psf::error::stream)
991 {
992 init.cancel();
993 return {CELL_GAME_ERROR_BROKEN,
994 "psf::error='%s', type='%d' CATEGORY='%s'", psf_error, type, cat};

Callers

nothing calls this directly

Calls 10

acquire_lockFunction · 0.85
lv2_sleepFunction · 0.85
getFunction · 0.85
get_stringFunction · 0.85
is_cat_hddFunction · 0.85
throw_exceptionClass · 0.85
loadFunction · 0.50
get_ptrMethod · 0.45
cancelMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected