I save game data in a file like this:
Bfile_DeleteFile(FILE_NAME); Bfile_CreateFile(FILE_NAME, FILE_SIZE); a = Bfile_OpenFile(FILE_NAME, _OPENMODE_WRITE); if (a >= 0) { Bfile_WriteFile(a, buffer, sizeof(buffer)); Bfile_CloseFile(a); }This is done every time user presses 'Save'. Notice the delete/create.. This seems to be eating up space in storage memory. Each time user saves, the memory keeps going down (even though the file size is constant).
But I'm able to reclaim this space by going to memory and pressing F5 (optimization).
How do I prevent this from happening?
I tried the following, but couldn't make it work. i.e. I couldn't figure out a way of emptying the file..
a = Bfile_OpenFile(FILE_NAME, _OPENMODE_WRITE); if (a >= 0) { /* EMPTY CONTENTS OF FILE */ Bfile_WriteFile(a, buffer, sizeof(buffer)); Bfile_CloseFile(a); } else { Bfile_CreateFile(FILE_NAME, FILE_SIZE); a = Bfile_OpenFile(FILE_NAME, _OPENMODE_WRITE); if (a >= 0) { Bfile_WriteFile(a, buffer, sizeof(buffer)); Bfile_CloseFile(a); } }Help!