Game Development Community

File Objects - More support needed

by Gellyware · in Torque Game Builder · 01/19/2007 (11:41 am) · 3 replies

IsFile - needed!

DeleteFile - needed!


I understand the argument for the deletefile and malicious programmers... however it really makes some tasks such as creating a profile system a pain since the easiest way is to keep a file for each player who plays the game and store their info in that file. One could simply check IsFile("~/playerProfiles/Charles.dat") and delete that file if the user would like to delete that profile! Or the system could use the IsFile to make sure that duplicate profiles dont exist. This seems like the easiest way to handle profiles.... however without IsFile or DeleteFile ...... I'm not sure where to even begin without a complex file full of flags and values.

#1
01/19/2007 (2:50 pm)
IsFile() and fileDelete() console functions are provided already, they're just not methods of the file object. They do exactly what you're wanting.

if (isFile ("~/playerProfiles/Charles.dat"))
   fileDelete ("~/playerProfiles/Charles.dat"));
#2
01/19/2007 (3:38 pm)
Thanks Richard :) Didn't think to look in console functions in the docs.

I appreciate it!
#3
01/22/2007 (4:01 pm)
Thanks for posting the info Richard...

another "gotcha" is if delete and add files quite a bit in Torque you may run into the Torque internal file system not recognizing a file and/or paths... the easiest way to reset the file system (and ensure it adds all existing files) is this:

setModPaths(getModPaths());

Keep that in mind in case you run into any files not registering (or not registering as deleted).

I am planning to update the reference in the future and hopefully can have some cross-referencing as well as better organization, though very busy at the moment so no promises. Fortunately we have a great and helpful community :)