Having a little trouble with C++..
by XD · in Torque Game Engine Advanced · 07/10/2009 (6:59 pm) · 4 replies
I'm still new to C++, but this code seems to return that the file was "renamed" when the file was not actually renamed.
Any help?
ConsoleFunction(fileRename, bool, 3, 3, "(target file, new name)")
{
argc;
int result;
static char oldfileName[1024],newfileName[1024],oFileName[1024],nFileName[1024];
Con::expandScriptFilename( oldfileName, sizeof( oldfileName ), argv[1] );
Platform::makeFullPathName(oldfileName, oFileName, sizeof(oFileName));
Con::expandScriptFilename( newfileName, sizeof( newfileName ), argv[2] );
Platform::makeFullPathName(oldfileName, nFileName, sizeof(nFileName));
result = rename((const char *) oFileName, (const char *) nFileName );
if( result == 0)
return 1; // File successfully renamed
else
return 0; // Permission denied
}Any help?
About the author
#2
07/11/2009 (11:42 am)
I'm trying to rename a file within within torque's directory. I think?
#3
when torque starts up,
it walks the local filesystem and builds an internal map of all the files which are present. this is why if you add a file to the filesystem after torque has started up, torque won't see it. (unless you do something like setModPaths(getModPaths());) so i'm wondering if maybe torque has renamed the file in its own internal map of the FS, but not actually renamed it on disk.
it might be interesting to try opening the file from within torque using the new name.
07/11/2009 (12:02 pm)
sorry, i was unclear.when torque starts up,
it walks the local filesystem and builds an internal map of all the files which are present. this is why if you add a file to the filesystem after torque has started up, torque won't see it. (unless you do something like setModPaths(getModPaths());) so i'm wondering if maybe torque has renamed the file in its own internal map of the FS, but not actually renamed it on disk.
it might be interesting to try opening the file from within torque using the new name.
#4
07/11/2009 (8:05 pm)
Nope.
Associate Orion Elenzil
Real Life Plus
possibly it's only been renamed within torque's directory of the filesystem, but not on the actual filesystem ?