Little thingi'd added to fileDelete ConsoleFunction
by Karen Ho · in Technical Issues · 07/03/2007 (8:39 pm) · 0 replies
Recently i'm working with TGE fileDelete consoleFunction, i'd found a defect in this function, after deleting a file from filesystem, the deleted file still keep in TGE's ResourceManager, hence next file listing it'll still show up even though it is not longer there. my quick fix for this problem is as follow:
in consoleFunction.cc, line ~ 1501 change
to
any other people have faced similar problem, will this solution breaks any other TGE compoents? so far it works perfect for me.
in consoleFunction.cc, line ~ 1501 change
ConsoleFunction(fileDelete, bool, 2,2, "fileDelete('path')")
{
static char fileName[1024];
static char sandboxFileName[1024];
Con::expandScriptFilename( fileName, sizeof( fileName ), argv[1] );
dSprintf( sandboxFileName, 1024, "%s/%s", Platform::getWorkingDirectory(), fileName );
return dFileDelete(sandboxFileName);
}to
ConsoleFunction(fileDelete, bool, 2,2, "fileDelete('path')")
{
static char fileName[1024];
static char sandboxFileName[1024];
ResourceObject * delFile = NULL;
const char *fn;
if (Con::expandScriptFilename( fileName, sizeof( fileName ), argv[1] ))
{
delFile = ResourceManager->findMatch(fileName, &fn, NULL);
if(delFile) ResourceManager->freeResource(delFile);
dSprintf( sandboxFileName, 1024, "%s/%s", Platform::getWorkingDirectory(), fileName );
return dFileDelete(sandboxFileName);
}
return false;
}any other people have faced similar problem, will this solution breaks any other TGE compoents? so far it works perfect for me.