Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

I've read around and a thousand and one people have had problems with writing files in the 6000. Now, here is my situation.

I can create a new file update the file, whatever, as long as the file system isn't full.

If I use the max file count utility, it created about 368 files (either 10, or 1000 byte files). This successfully fills the MAX FILE COUNT. So the phone isn't full on memory but there is no room to create any more files.

If once I make the max file count I try to start a new game and save the information it works fine. My save algorithm deletes the previous file first before trying to write again, so there is no problems with temp files. This all seems to work fine because full file system - 1 file = enough room to make one more file.

Ok thats cool.

Next, I instead fill up the filesystem by size instead of number of files. So now there IS room to create files but there is no room for any information.

If I do the same thing (the file is already created in the game) and try to start a a new game, and save the data, now it instead deletes the file as per normal (I think?) and then tries to create the new file. Ok that works, but when I go to write to the file it writes 0 bytes, since there is no room.... but wait? There should be room because I just deleted the file that would be taking up room.

Does anyone know whats going on? here is the code for what I am doing...mind you, this is debug code cause I've been pounding away at this for a while :

//-x- DBGPRINTF("IOManager Saving: %s", filename);
IFile * pIFile = NULL;

if (!m_pIFileMgr) {
//-x- DBGPRINTF("IOManager constructor failed to create instance of FILEMGR");
return 1;//false;

// check if the file we want to write exists and, if so, remove it
if (SUCCESS == IFILEMGR_Test(m_pIFileMgr, filename)) {
// file exists; remove it
if (SUCCESS != IFILEMGR_Remove(m_pIFileMgr, filename)) {
//-x- DBGPRINTF("ERROR: Couldn't remove existing file '%s' (%s:%d)", filename, __FILE__, __LINE__);
return 2;//false;
}

// if we are here, we know the file we want to create does not exist; try to create
uint32 pdwTotal = 0;
uint32 pdwLeft = 0;
if ( (pdwLeft=IFILEMGR_GetFreeSpace( m_pIFileMgr, &pdwTotal )) < iostructSize ) {
return 10 + pdwLeft;

pIFile = IFILEMGR_OpenFile(m_pIFileMgr, filename, _OFM_CREATE);

if (!pIFile) {
return 3;
//-x- DBGPRINTF("ERROR: Couldn't create file '%s' (%s:%d)", filename, __FILE__, __LINE__);

// if we are here, write to the file
const uint32 bytesWritten = IFILE_Write(pIFile, iostruct, iostructSize);
if (bytesWritten != iostructSize) {
//-x- DBGPRINTF("ERROR: Attempt to write %d bytes only wrote %d (%s:%d)", iostructSize, bytesWritten, __FILE__, __LINE__);
IFILE_Release(pIFile);

return 4;

else {
//-x- DBGPRINTF("INFO: File '%s' successfully written.", filename);
IFILE_Release(pIFile);
return -26;

Currently it ends up reaching "return 4" when the file system is full...shouldn't it have stopped when I hit the check again filesystem space left?...Hmmm

Would appreciate any help.

Depending on how the OEM has implemented the file system on the device, a file marked for deletion may not actually be cleaned up until later.
Assuming that it was not your application that filled up the EFS in the first place, a much better practice is to simply inform the user that their memory is full and they should free up some space. Trying to operate at the very limits of the EFS is just asking for trouble.

Depending on how the OEM has implemented the file system on the device, a file marked for deletion may not actually be cleaned up until later.
Assuming that it was not your application that filled up the EFS in the first place, a much better practice is to simply inform the user that their memory is full and they should free up some space. Trying to operate at the very limits of the EFS is just asking for trouble.