| 822 | } |
| 823 | |
| 824 | void StudioApp::scanFilesThread() |
| 825 | { |
| 826 | std::vector<FileEntry> localOs; |
| 827 | std::vector<FileEntry> localVfs; |
| 828 | std::vector<FileEntry> pboFiles; |
| 829 | |
| 830 | { |
| 831 | std::lock_guard<std::mutex> lk(scanStatusMutex); |
| 832 | scanStatusText = "Scanning filesystem..."; |
| 833 | } |
| 834 | |
| 835 | try |
| 836 | { |
| 837 | std::error_code ec; |
| 838 | for (auto it = std::filesystem::recursive_directory_iterator( |
| 839 | gamePath, std::filesystem::directory_options::skip_permission_denied, ec); |
| 840 | it != std::filesystem::recursive_directory_iterator(); it.increment(ec)) |
| 841 | { |
| 842 | if (ec) |
| 843 | { |
| 844 | ec.clear(); |
| 845 | continue; |
| 846 | } |
| 847 | |
| 848 | if (it->is_directory()) |
| 849 | continue; |
| 850 | |
| 851 | FileEntry fe; |
| 852 | fe.fullPath = it->path().string(); |
| 853 | fe.name = std::filesystem::relative(it->path(), gamePath).string(); |
| 854 | fe.isDirectory = false; |
| 855 | fe.extension = it->path().extension().string(); |
| 856 | |
| 857 | std::error_code szEc; |
| 858 | fe.size = static_cast<int64_t>(std::filesystem::file_size(it->path(), szEc)); |
| 859 | if (szEc) |
| 860 | fe.size = 0; |
| 861 | |
| 862 | for (auto& c : fe.name) |
| 863 | if (c == '\\') |
| 864 | c = '/'; |
| 865 | |
| 866 | std::string extLower = fe.extension; |
| 867 | std::transform(extLower.begin(), extLower.end(), extLower.begin(), ::tolower); |
| 868 | fe.isPbo = (extLower == ".pbo"); |
| 869 | |
| 870 | localOs.push_back(fe); |
| 871 | |
| 872 | if (fe.isPbo) |
| 873 | pboFiles.push_back(fe); |
| 874 | } |
| 875 | } |
| 876 | catch (...) |
| 877 | { |
| 878 | } |
| 879 | |
| 880 | { |
| 881 | std::lock_guard<std::mutex> lk(scanStatusMutex); |