| 683 | } |
| 684 | |
| 685 | void GameList::ScanDirectory(const char* path, bool recursive, bool only_cache, const std::vector<std::string>& excluded_paths, |
| 686 | const PlayedTimeMap& played_time_map, const INISettingsInterface& custom_attributes_ini, ProgressCallback* progress) |
| 687 | { |
| 688 | Console.WriteLn("Scanning %s%s", path, recursive ? " (recursively)" : ""); |
| 689 | |
| 690 | progress->PushState(); |
| 691 | |
| 692 | if (recursive) |
| 693 | progress->SetStatusText( |
| 694 | fmt::format(TRANSLATE_FS("GameList", "Scanning directory {} (recursively)..."), path).c_str()); |
| 695 | else |
| 696 | progress->SetStatusText( |
| 697 | fmt::format(TRANSLATE_FS("GameList", "Scanning directory {}..."), path).c_str()); |
| 698 | |
| 699 | FileSystem::FindResultsArray files; |
| 700 | FileSystem::FindFiles(path, "*", |
| 701 | recursive ? (FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES | FILESYSTEM_FIND_RECURSIVE) : |
| 702 | (FILESYSTEM_FIND_FILES | FILESYSTEM_FIND_HIDDEN_FILES), |
| 703 | &files, progress); |
| 704 | |
| 705 | u32 files_scanned = 0; |
| 706 | progress->SetProgressRange(static_cast<u32>(files.size())); |
| 707 | progress->SetProgressValue(0); |
| 708 | |
| 709 | for (FILESYSTEM_FIND_DATA& ffd : files) |
| 710 | { |
| 711 | files_scanned++; |
| 712 | |
| 713 | if (progress->IsCancelled() || !GameList::IsScannableFilename(ffd.FileName) || IsPathExcluded(excluded_paths, ffd.FileName)) |
| 714 | { |
| 715 | continue; |
| 716 | } |
| 717 | |
| 718 | std::unique_lock lock(s_mutex); |
| 719 | if (GetEntryForPath(ffd.FileName.c_str()) || AddFileFromCache(ffd.FileName, ffd.ModificationTime, played_time_map) || only_cache) |
| 720 | { |
| 721 | continue; |
| 722 | } |
| 723 | |
| 724 | const std::string_view filename = Path::GetFileName(ffd.FileName); |
| 725 | progress->SetStatusText(fmt::format(TRANSLATE_FS("GameList", "Scanning {}..."), filename.data()).c_str()); |
| 726 | ScanFile(std::move(ffd.FileName), ffd.ModificationTime, lock, played_time_map, custom_attributes_ini); |
| 727 | progress->SetProgressValue(files_scanned); |
| 728 | } |
| 729 | |
| 730 | progress->SetProgressValue(files_scanned); |
| 731 | progress->PopState(); |
| 732 | } |
| 733 | |
| 734 | bool GameList::AddFileFromCache(const std::string& path, std::time_t timestamp, const PlayedTimeMap& played_time_map) |
| 735 | { |
nothing calls this directly
no test coverage detected