| 881 | } |
| 882 | |
| 883 | static void collectGameInfo(JNIEnv *env, jlong progressId, |
| 884 | const std::vector<std::string> &rootDirs) { |
| 885 | std::vector<std::string> paths; |
| 886 | for (auto &&rootDir : rootDirs) { |
| 887 | collectGamePaths(paths, rootDir); |
| 888 | |
| 889 | rpcsx_android.notice("collectGameInfo: processed %s", rootDir); |
| 890 | } |
| 891 | |
| 892 | rpcsx_android.notice("collectGameInfo: found %d paths", paths.size()); |
| 893 | |
| 894 | Progress progress(env, progressId); |
| 895 | progress.report(0, paths.size()); |
| 896 | |
| 897 | std::vector<GameInfo> gameInfos; |
| 898 | gameInfos.reserve(10); |
| 899 | std::size_t processed = 0; |
| 900 | |
| 901 | auto submit = [&] { |
| 902 | if (gameInfos.empty()) { |
| 903 | return; |
| 904 | } |
| 905 | |
| 906 | sendGameInfo(env, progressId, gameInfos); |
| 907 | progress.report(processed, paths.size()); |
| 908 | gameInfos.clear(); |
| 909 | }; |
| 910 | |
| 911 | for (auto &&path : paths) { |
| 912 | processed++; |
| 913 | |
| 914 | if (!std::filesystem::is_regular_file(path + "/PARAM.SFO")) { |
| 915 | continue; |
| 916 | } |
| 917 | |
| 918 | const auto psf = psf::load_object(path + "/PARAM.SFO"); |
| 919 | |
| 920 | rpcsx_android.notice("collectGameInfo: sfo at %s", path); |
| 921 | |
| 922 | if (auto gameInfo = fetchGameInfo(psf, path)) { |
| 923 | gameInfos.push_back(std::move(*gameInfo)); |
| 924 | |
| 925 | if (gameInfos.size() >= 10) { |
| 926 | submit(); |
| 927 | } |
| 928 | } |
| 929 | } |
| 930 | |
| 931 | submit(); |
| 932 | |
| 933 | progress.success(processed); |
| 934 | } |
| 935 | |
| 936 | class MainThreadProcessor { |
| 937 | std::mutex mutex; |
no test coverage detected