MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / ClearCache

Function ClearCache

Source/Internal/filesystem.cpp:978–1141  ·  view source on GitHub ↗

* Smart-ish cache clearer, removes files of known types from the local write dir. Intended to function as a sort of sanitation fallback. */

Source from the content-addressed store, hash-verified

976 * Smart-ish cache clearer, removes files of known types from the local write dir. Intended to function as a sort of sanitation fallback.
977 */
978void ClearCache(bool dry_run) {
979 if (write_path_set == false) {
980 LOGE << "Write path is not set, will not clear cache" << endl;
981 return;
982 }
983
984 if (!dry_run) {
985 LOGI << "Clearing Cache Data (For Real)..." << endl;
986 } else {
987 LOGI << "Clearing Cache Data (Dry Run)..." << endl;
988 }
989
990 vector<ModID> modids;
991#if !(defined(OGDA) || defined(OG_WORKER))
992 modids = ModLoading::Instance().GetModsSid();
993#endif
994 modids.push_back(CoreGameModID);
995 for (auto& modid : modids) {
996 stringstream write_data_path;
997 write_data_path << GetWritePath(modid);
998 write_data_path << "Data/";
999
1000 vector<string> write_dir_files;
1001
1002 vector<pair<string, string> > exclude_with_ending;
1003
1004 exclude_with_ending.push_back(pair<string, string>("Mods", ""));
1005
1006 vector<pair<string, string> > remove_with_ending;
1007 // Clearly cache files
1008 remove_with_ending.push_back(pair<string, string>("", ".mcache"));
1009 remove_with_ending.push_back(pair<string, string>("", ".cache"));
1010 remove_with_ending.push_back(pair<string, string>("", ".lod_cache"));
1011 remove_with_ending.push_back(pair<string, string>("", ".tga_image_sample_cache"));
1012 remove_with_ending.push_back(pair<string, string>("", ".tga_avg_color_cache"));
1013 remove_with_ending.push_back(pair<string, string>("", ".png_image_sample_cache"));
1014 remove_with_ending.push_back(pair<string, string>("", ".png_hmcache"));
1015 remove_with_ending.push_back(pair<string, string>("", ".png_hmcache_scaled"));
1016
1017 // Probably cache files
1018 remove_with_ending.push_back(pair<string, string>("", ".tga_converted.dds"));
1019 remove_with_ending.push_back(pair<string, string>("", ".png_converted.dds"));
1020 remove_with_ending.push_back(pair<string, string>("", ".jpg_converted.dds"));
1021
1022 // Specific subcategories
1023 remove_with_ending.push_back(pair<string, string>("Prototypes", "weights.png"));
1024 remove_with_ending.push_back(pair<string, string>("Textures", "weights.png"));
1025
1026 remove_with_ending.push_back(pair<string, string>("Prototypes", "cube.dds"));
1027 remove_with_ending.push_back(pair<string, string>("Textures", "cube.dds"));
1028
1029 remove_with_ending.push_back(pair<string, string>("Prototypes", "cube_blur.dds"));
1030 remove_with_ending.push_back(pair<string, string>("Textures", "cube_blur.dds"));
1031
1032 remove_with_ending.push_back(pair<string, string>("Prototypes", ".png_normal.png"));
1033 remove_with_ending.push_back(pair<string, string>("Textures", ".png_normal.png"));
1034
1035 remove_with_ending.push_back(pair<string, string>("Prototypes", ".png.obj"));

Callers 2

GameMainFunction · 0.85
DrawSettingsImGuiFunction · 0.85

Calls 15

GetWritePathFunction · 0.85
GenerateManifestFunction · 0.85
hasBeginningFunction · 0.85
hasEndingFunction · 0.85
deletefileFunction · 0.85
SplitPathFileNameFunction · 0.85
GetModsSidMethod · 0.80
sortFunction · 0.70
push_backMethod · 0.45
c_strMethod · 0.45
strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected