mirror of
https://github.com/sanni/cartreader.git
synced 2024-12-27 05:21:53 +01:00
use common function to create file/folder and increment foldern counter
This commit is contained in:
parent
22e06d8ec1
commit
ad69abdf57
@ -48,9 +48,6 @@ String CRC2 = "";
|
||||
unsigned long flashSize;
|
||||
#endif
|
||||
|
||||
static const char N64_EEP_FILENAME_FMT[] PROGMEM = "%s.eep";
|
||||
static const char N64_SAVE_DIRNAME_FMT[] PROGMEM = "N64/SAVE/%s/%d";
|
||||
|
||||
/******************************************
|
||||
Menu
|
||||
*****************************************/
|
||||
@ -2281,22 +2278,7 @@ boolean readEepromPageList(byte* output, byte page_number, byte page_count) {
|
||||
void readEeprom() {
|
||||
if ((saveType == 5) || (saveType == 6)) {
|
||||
// Get name, add extension and convert to char array for sd lib
|
||||
snprintf_P(fileName, sizeof(fileName), N64_EEP_FILENAME_FMT, romName);
|
||||
|
||||
// create a new folder for the save file
|
||||
EEPROM_readAnything(0, foldern);
|
||||
snprintf_P(folder, sizeof(folder), N64_SAVE_DIRNAME_FMT, romName, foldern);
|
||||
sd.mkdir(folder, true);
|
||||
sd.chdir(folder);
|
||||
|
||||
// write new folder number back to eeprom
|
||||
foldern = foldern + 1;
|
||||
EEPROM_writeAnything(0, foldern);
|
||||
|
||||
// Open file on sd card
|
||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||
print_FatalError(create_file_STR);
|
||||
}
|
||||
createFolderAndOpenFile("N64", "SAVE", romName, "eep");
|
||||
|
||||
for (int i = 0; i < eepPages; i += sizeof(sdBuffer) / 8) {
|
||||
// If any missing bytes error out
|
||||
@ -2421,16 +2403,7 @@ void readSram(unsigned long sramSize, byte flashramType) {
|
||||
} else {
|
||||
print_FatalError(F("Savetype Error"));
|
||||
}
|
||||
createFolder("N64", "SAVE", romName, suffix);
|
||||
|
||||
// write new folder number back to eeprom
|
||||
foldern = foldern + 1;
|
||||
EEPROM_writeAnything(0, foldern);
|
||||
|
||||
// Open file on sd card
|
||||
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
|
||||
print_FatalError(sd_error_STR);
|
||||
}
|
||||
createFolderAndOpenFile("N64", "SAVE", romName, suffix);
|
||||
|
||||
for (unsigned long currByte = sramBase; currByte < (sramBase + (sramSize / flashramType)); currByte += offset) {
|
||||
// Set the address
|
||||
|
Loading…
Reference in New Issue
Block a user