| 705 | } |
| 706 | |
| 707 | static void collectGamePaths(std::vector<std::string> &paths, |
| 708 | const std::string &rootDir) { |
| 709 | std::error_code ec; |
| 710 | std::vector<std::filesystem::path> workList; |
| 711 | workList.reserve(32); |
| 712 | if (!std::filesystem::is_directory(rootDir)) { |
| 713 | auto rootPath = std::filesystem::path(rootDir).parent_path(); |
| 714 | if (rootPath.filename() == "USRDIR") { |
| 715 | rootPath = rootPath.parent_path(); |
| 716 | } |
| 717 | if (rootPath.filename() == "PS3_GAME") { |
| 718 | rootPath = rootPath.parent_path(); |
| 719 | } |
| 720 | |
| 721 | workList.push_back(rootPath); |
| 722 | } else { |
| 723 | workList.push_back(rootDir); |
| 724 | } |
| 725 | |
| 726 | while (!workList.empty()) { |
| 727 | auto dir = std::move(workList.back()); |
| 728 | workList.pop_back(); |
| 729 | |
| 730 | for (auto &entry : std::filesystem::directory_iterator(dir, ec)) { |
| 731 | if (entry.is_directory()) { |
| 732 | if (entry.path().filename() != "C00") { |
| 733 | workList.push_back(entry.path()); |
| 734 | } |
| 735 | |
| 736 | continue; |
| 737 | } |
| 738 | |
| 739 | if (entry.is_regular_file() && entry.path().filename() == "PARAM.SFO") { |
| 740 | paths.push_back(entry.path().parent_path().string()); |
| 741 | continue; |
| 742 | } |
| 743 | } |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | static std::string locateEbootPath(std::string_view root) { |
| 748 | if (std::filesystem::is_regular_file(root)) { |