Jump to content



Photo
- - - - -

Help With File Management


  • Please log in to reply
2 replies to this topic

#1 happy

happy

    Newbie

  • Members
  • Pip
  • 13 posts

Posted 17 November 2011 - 08:08 PM

Hello all,

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!

#2 JosJuice

JosJuice

    Casio Addict

  • Members
  • PipPipPip
  • 75 posts
  • Gender:Not Telling
  • Location:Sweden

  • Calculators:
    Casio Prizm fx-CG10
    TI-84 Plus Silver Edition

Posted 18 November 2011 - 03:36 PM

Deleted files taking up space is not a bug. It's a side effect of how Flash memory works. happy's workarounds are good ways to reduce the problems, but there unfortunately is no way to get rid of them completely.

#3 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 02 February 2012 - 09:20 PM

If there is a way to optimize the memory (remove deleted files basically), then you could run that after editing a file. However, this would be slow.

What game are you making? Why don't you post about it? ;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users