#168787 - Emmanuel - Sun May 24, 2009 8:45 am
So, I want to save a simple .txt file, but:
1. I try to use EFS, so I have a .txt file with one row per variable with "00000" to have enough space when writing. It reads properly, but it doesn't write. Not on no$gba, not on my R4 in real DS.
2. I try to chdir to FAT, but it says chdir is not defined and I already tried including all sorts of headers, searched some code, and I still can't get it to be included.
Any help/ideas/suggestions? This is my code
All the variables to save are ints except goomba which is a bool. saveFile() is called when you press A, Start or B to exit the options menu.
Here is the file in case it may be my cart or something:
http://www.mediafire.com/file/2mz1d3rnz1m/clash.nds
*Uploaded in mediafire, possible advertising.
1. I try to use EFS, so I have a .txt file with one row per variable with "00000" to have enough space when writing. It reads properly, but it doesn't write. Not on no$gba, not on my R4 in real DS.
2. I try to chdir to FAT, but it says chdir is not defined and I already tried including all sorts of headers, searched some code, and I still can't get it to be included.
Any help/ideas/suggestions? This is my code
Code: |
bool SaveFile::readFile(char * path){ bool wasSuccessful = false; if(save != NULL){ fclose(save); save = NULL; } save = fopen(path, "r"); if(save != NULL) { int line = 0; int value = 0; while(fscanf(save, "%d", &value) != EOF){ switch(line){ case MAXXSCROLL_LINE: this->maxXScroll = value; break; case MAXYSCROLL_LINE: this->maxYScroll = value; break; case XBORDER_LINE: this->xBorder = value; break; case YBORDER_LINE: this->yBorder = value; break; case MAXZOOM_LINE: this->maxZoom = value; break; case MINZOOM_LINE: this->minZoom = value; break; case MAXZOOMCHANGE_LINE: this->maxZoomChange = value; break; case MINZOOMCHANGE_LINE: this->minZoomChange = value; break; case GOOMBA_ON_LINE: this->goomba = value; break; } line++; } fclose(save); save = NULL; }else{ iprintf("File NULL"); } return wasSuccessful; } bool SaveFile::saveFile(){ bool wasSuccessful = false; if(save != NULL){ fclose(save); save = NULL; } chdir("FAT:/"); string path = *efs_path + EFS_SAVE_PATH; save = fopen(path.c_str(), "r"); if(save != NULL){ stringstream saveStream(stringstream::in | stringstream::out); saveStream << maxXScroll << endl << maxYScroll << endl << xBorder << endl << yBorder << endl << maxZoom << endl << minZoom << endl << maxZoomChange << endl << minZoomChange << endl << goomba << endl; int size = sizeof(saveStream.str().c_str()); fwrite(saveStream.str().c_str(), 1, size, save); fclose(save); save = NULL; } return wasSuccessful; } |
All the variables to save are ints except goomba which is a bool. saveFile() is called when you press A, Start or B to exit the options menu.
Here is the file in case it may be my cart or something:
http://www.mediafire.com/file/2mz1d3rnz1m/clash.nds
*Uploaded in mediafire, possible advertising.