MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / processCache

Method processCache

Engine/source/lighting/common/sceneLighting.cpp:927–1027  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

925}
926
927void SceneLighting::processCache()
928{
929 // get size in kb
930 S32 quota = Con::getIntVariable("$sceneLighting::cacheSize", -1);
931
932 Vector<CacheEntry> files;
933
934 Vector<String> fileNames;
935 Torque::FS::FindByPattern(Torque::Path(Platform::getMainDotCsDir()), "*.ml", true, fileNames);
936
937 S32 curCacheSize = 0;
938
939 for(S32 i = 0;i < fileNames.size();++i)
940 {
941 if(! Torque::FS::IsFile(fileNames[i]))
942 continue;
943
944 Torque::FS::FileNodeRef fileNode = Torque::FS::GetFileNode(fileNames[i]);
945 if(fileNode == NULL)
946 continue;
947
948 if(dStrstr(fileNames[i], mFileName) == 0)
949 {
950 // Don't allow the current file to be removed
951 CacheEntry entry;
952 entry.mFileObject = fileNode;
953 entry.mFileName = StringTable->insert(fileNames[i]);
954 files.push_back(entry);
955 }
956 else
957 curCacheSize += fileNode->getSize();
958 }
959
960 // remove old files
961 for(S32 i = files.size() - 1; i >= 0; i--)
962 {
963 FileStream *stream;
964 if((stream = FileStream::createAndOpen( files[i].mFileObject->getName(), Torque::FS::File::Read )) == NULL)
965 continue;
966
967 // read in the version
968 U32 version;
969 bool ok = (stream->read(&version) && (version == PersistInfo::smFileVersion));
970 delete stream;
971
972 // ok?
973 if(ok)
974 continue;
975
976 // no sneaky names
977 if(!dStrstr(files[i].mFileName, ".."))
978 {
979 Con::warnf("Removing old lighting file '%s'.", files[i].mFileName);
980 dFileDelete(files[i].mFileName);
981 }
982
983 files.pop_back();
984 }

Callers

nothing calls this directly

Calls 15

getIntVariableFunction · 0.85
FindByPatternFunction · 0.85
IsFileFunction · 0.85
GetFileNodeFunction · 0.85
dStrstrFunction · 0.85
warnfFunction · 0.85
getVariableFunction · 0.85
dStricmpFunction · 0.85
dQsortFunction · 0.85
lastMethod · 0.80
PathClass · 0.50
dFileDeleteFunction · 0.50

Tested by

no test coverage detected