MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / Refresh

Method Refresh

pcsx2/GameList.cpp:865–926  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

863}
864
865void GameList::Refresh(bool invalidate_cache, bool only_cache, ProgressCallback* progress /* = nullptr */)
866{
867 if (!progress)
868 progress = ProgressCallback::NullProgressCallback;
869
870 Error cdvd_lock_error;
871 if (!cdvdLock(&cdvd_lock_error))
872 {
873 progress->DisplayError(cdvd_lock_error.GetDescription().c_str());
874 return;
875 }
876
877 ScopedGuard unlock_cdvd = &cdvdUnlock;
878
879 if (invalidate_cache)
880 DeleteCacheFile();
881 else
882 LoadCache();
883
884 // don't delete the old entries, since the frontend might still access them
885 std::vector<Entry> old_entries;
886 {
887 std::unique_lock lock(s_mutex);
888 old_entries.swap(s_entries);
889 }
890
891 const std::vector<std::string> excluded_paths(Host::GetBaseStringListSetting("GameList", "ExcludedPaths"));
892 const std::vector<std::string> dirs(Host::GetBaseStringListSetting("GameList", "Paths"));
893 const std::vector<std::string> recursive_dirs(Host::GetBaseStringListSetting("GameList", "RecursivePaths"));
894 const PlayedTimeMap played_time(LoadPlayedTimeMap(GetPlayedTimeFile()));
895 INISettingsInterface custom_attributes_ini(GetCustomPropertiesFile());
896 custom_attributes_ini.Load();
897
898 if (!dirs.empty() || !recursive_dirs.empty())
899 {
900 progress->SetProgressRange(static_cast<u32>(dirs.size() + recursive_dirs.size()));
901 progress->SetProgressValue(0);
902
903 // we manually count it here, because otherwise pop state updates it itself
904 int directory_counter = 0;
905 for (const std::string& dir : dirs)
906 {
907 if (progress->IsCancelled())
908 break;
909
910 ScanDirectory(dir.c_str(), false, only_cache, excluded_paths, played_time, custom_attributes_ini, progress);
911 progress->SetProgressValue(++directory_counter);
912 }
913 for (const std::string& dir : recursive_dirs)
914 {
915 if (progress->IsCancelled())
916 break;
917
918 ScanDirectory(dir.c_str(), true, only_cache, excluded_paths, played_time, custom_attributes_ini, progress);
919 progress->SetProgressValue(++directory_counter);
920 }
921 }
922

Callers

nothing calls this directly

Calls 12

cdvdLockFunction · 0.85
GetDescriptionMethod · 0.80
DisplayErrorMethod · 0.45
c_strMethod · 0.45
swapMethod · 0.45
LoadMethod · 0.45
emptyMethod · 0.45
SetProgressRangeMethod · 0.45
sizeMethod · 0.45
SetProgressValueMethod · 0.45
IsCancelledMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected