Automatic DSO cleaning
by Marcelo Oliveira · 01/21/2004 (6:25 pm) · 1 comments
Download Code File
Download the .patch or do it manually:
At core/resManager.cc:
Modify @ line 123
Add at the bottom:
At core/resManager.h:
Modify @ line 469:
Download the .patch or do it manually:
At core/resManager.cc:
Modify @ line 123
ResManager::~ResManager ()
{
cleanDSO(); // Add this
purge ();
...Add at the bottom:
struct CacheEntry {
ResourceObject * mFileObject;
const char * mFileName;
CacheEntry() {
mFileObject = 0;
mFileName = 0;
};
};
bool ResManager::cleanDSO()
{
ResourceObject *match = NULL;
const char *name;
Vector<CacheEntry> files;
match = ResourceManager->findMatch("*.dso", &name, NULL);
while (match)
{
if(match->flags & ResourceObject::File)
{
CacheEntry entry;
entry.mFileObject = match;
// get out of vfs...
char fileName[1024];
dSprintf(fileName, sizeof(fileName), "%s/%s", match->path, match->name);
entry.mFileName = StringTable->insert(fileName);
files.push_back(entry);
}
match = ResourceManager->findMatch("*.dso", &name, match);
}
for(S32 i = files.size() - 1; i >= 0; i--)
{
char buf[1024];
dSprintf(buf, sizeof(buf), "%s/%s", files[i].mFileObject->path, files[i].mFileObject->name);
// delete the file
ResourceManager->freeResource(files[i].mFileObject);
// no sneaky names
if(!dStrstr(files[i].mFileName, ".."))
{
dFileDelete(files[i].mFileName);
}
files.pop_back();
}
return true;
}At core/resManager.h:
Modify @ line 469:
bool openFileForWrite(FileStream &fs, const char *fileName, U32 accessMode = 1); bool cleanDSO(); // Add this
About the author

Torque Owner BrokeAss Games
BrokeAss Games
With some wrenching I got this in.
Works great on the latest HEAD.
Nice work, can't imagine coding without this.
This resource has been assimilated!
Ari Rule (Programmer and Modeller)