power panic: simplify recovering SD filename

We can just read the whole EEPROM block since short filenames
are always null terminated. strcat_P will then apply the file extension
at the correct position.

Change in memory:
Flash: -24 bytes
SRAM: 0 bytes
This commit is contained in:
gudnimg 2023-10-14 13:41:22 +00:00
parent dec5e2c1b4
commit 21d0130626
1 changed files with 3 additions and 5 deletions

View File

@ -438,11 +438,9 @@ void restore_file_from_sd()
card.chdir(dir_name, false);
}
for (uint8_t i = 0; i < 8; i++) {
const char c = eeprom_read_byte((uint8_t*)EEPROM_FILENAME + i);
filename[i] = c;
if (c == '\0') break; // Filename is shorter than 8 characters
}
// Recover DOS 8.3 filename without extension.
// Short filenames are always null terminated.
eeprom_read_block(filename, (const char *)EEPROM_FILENAME, 8);
// Add null delimiter in case all 8 characters were not NULL
filename[8] = '\0';