Game Development Community

Deleting a file?

by Vern Jensen · in Torque Game Builder · 05/07/2009 (6:28 pm) · 6 replies

Surely there is a way to delete files, right? My game creates "player profiles" but also allows them to be deleted. Each profile is stored in a new file in a special folder. How do I delete a file?

#1
05/07/2009 (8:07 pm)
I can't find anything, either. Also, different platforms have different places to store program-specific config/savegames, and that doesn't seem to have a simple function, either. A couple of resources need to be written. I'll consider it once I see what's missing in iTGB 1.2 :)
#2
05/08/2009 (11:14 am)
An alternative approach would be for me to stuff all the profile data in one file... from your post it sounds like I should do that? Or is there hope of finding a "deleteFile" method somewhere?
#3
05/08/2009 (11:53 am)
Writing one isn't hard. You just need to do it once for each platform, using the platform's best methods for finding the correct directory to store data. I know at least the iTGB code needs some tweaks for userdata.

You need to write a deleteFile() function, and one to find the user's config directory. In other words, read up a bit on core OS methods :/

I'm still baffled there isn't already a delete function.
#4
05/08/2009 (1:58 pm)
As far as I know there isn't a delete function in TGB. One alternative that I used is to simply wipe the file, do a single writeline with nothing in it. It will still leave the file behind but then you just do a check to not read in an empty file. It may save you time rather then writing a function in c++;
#5
05/08/2009 (2:29 pm)
That's what we call a bandaid solution :P

I'll see what I can do about a delete() transplant.
#6
11/27/2009 (1:45 am)
woooot? try fileDelete()

fileSystemFunctions.cpp

ConsoleFunction(fileDelete, bool, 2,2, "(fileName)\n"
"@param fileName Name of the file to remove"
"@return Returns true on success and flase on failure")