| 414 | } |
| 415 | |
| 416 | error_code cellHddGameCheck(ppu_thread& ppu, u32 version, |
| 417 | vm::cptr<char> dirName, u32 errDialog, |
| 418 | vm::ptr<CellHddGameStatCallback> funcStat, |
| 419 | u32 container) |
| 420 | { |
| 421 | cellGame.warning("cellHddGameCheck(version=%d, dirName=%s, errDialog=%d, " |
| 422 | "funcStat=*0x%x, container=%d)", |
| 423 | version, dirName, errDialog, funcStat, container); |
| 424 | |
| 425 | if (version != CELL_GAMEDATA_VERSION_CURRENT || !dirName || !funcStat || |
| 426 | sysutil_check_name_string(dirName.get_ptr(), 1, CELL_GAME_DIRNAME_SIZE) != |
| 427 | 0) |
| 428 | { |
| 429 | return CELL_HDDGAME_ERROR_PARAM; |
| 430 | } |
| 431 | |
| 432 | std::string game_dir = dirName.get_ptr(); |
| 433 | |
| 434 | // TODO: Find error code |
| 435 | ensure(game_dir.size() == 9); |
| 436 | |
| 437 | const std::string dir = "/dev_hdd0/game/" + game_dir; |
| 438 | |
| 439 | auto [sfo, psf_error] = psf::load(vfs::get(dir + "/PARAM.SFO")); |
| 440 | |
| 441 | const u32 new_data = psf_error == psf::error::stream ? CELL_GAMEDATA_ISNEWDATA_YES : CELL_GAMEDATA_ISNEWDATA_NO; |
| 442 | |
| 443 | if (!new_data) |
| 444 | { |
| 445 | const auto cat = psf::get_string(sfo, "CATEGORY", ""); |
| 446 | if (!psf::is_cat_hdd(cat)) |
| 447 | { |
| 448 | return {CELL_GAMEDATA_ERROR_BROKEN, "CATEGORY='%s'", cat}; |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | const std::string usrdir = dir + "/USRDIR"; |
| 453 | |
| 454 | auto& get = g_stat_get; |
| 455 | auto& set = g_stat_set; |
| 456 | auto& result = g_cb_result; |
| 457 | |
| 458 | std::memset(get.get_ptr(), 0, sizeof(*get)); |
| 459 | std::memset(set.get_ptr(), 0, sizeof(*set)); |
| 460 | std::memset(result.get_ptr(), 0, sizeof(*result)); |
| 461 | |
| 462 | const std::string local_dir = vfs::get(dir); |
| 463 | |
| 464 | // 40 GB - 256 kilobytes. The reasoning is that many games take this number |
| 465 | // and multiply it by 1024, to get the amount of bytes. With 40GB exactly, |
| 466 | // this will result in an overflow, and the size would be 0, preventing the |
| 467 | // game from running. By reducing 256 kilobytes, we make sure that even after |
| 468 | // said overflow, the number would still be high enough to contain the game's |
| 469 | // data. |
| 470 | get->hddFreeSizeKB = 40 * 1024 * 1024 - 256; |
| 471 | get->isNewData = CELL_HDDGAME_ISNEWDATA_EXIST; |
| 472 | get->sysSizeKB = 0; // TODO |
| 473 | get->st_atime_ = 0; // TODO |
no test coverage detected