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

Method processCache

Engine/source/lighting/common/sceneLighting.cpp:928–1028  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

getIntVariableFunction · 0.85
FindByPatternFunction · 0.85
IsFileFunction · 0.85
GetFileNodeFunction · 0.85
dStrstrFunction · 0.85
getVariableFunction · 0.85
dStricmpFunction · 0.85
dQsortFunction · 0.85
PathClass · 0.50
warnfFunction · 0.50
dFileDeleteFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected