Warn when progress can't be saved

This commit is contained in:
Lior Halphon 2022-07-24 13:23:50 +03:00
parent 4b03cc05c1
commit 5cd65f845d
2 changed files with 17 additions and 7 deletions

View File

@ -1071,6 +1071,11 @@ static unsigned *multiplication_table_for_frequency(unsigned frequency)
else {
ret = GB_load_rom(&gb, [fileName UTF8String]);
}
if (GB_save_battery_size(&gb)) {
if (access(self.savPath.UTF8String, W_OK)) {
GB_log(&gb, "The save path for this ROM is not writeable, progress will not be saved.\n");
}
}
GB_load_battery(&gb, self.savPath.UTF8String);
GB_load_cheats(&gb, self.chtPath.UTF8String);
[self.cheatWindowController cheatsUpdated];

View File

@ -737,6 +737,18 @@ restart:
else {
GB_load_rom(&gb, filename);
}
/* Configure battery */
char battery_save_path[path_length + 5]; /* At the worst case, size is strlen(path) + 4 bytes for .sav + NULL */
replace_extension(filename, path_length, battery_save_path, ".sav");
battery_save_path_ptr = battery_save_path;
GB_load_battery(&gb, battery_save_path);
if (GB_save_battery_size(&gb)) {
if (access(battery_save_path, W_OK)) {
GB_log(&gb, "The save path for this ROM is not writeable, progress will not be saved.\n");
}
}
end_capturing_logs(true, error, SDL_MESSAGEBOX_WARNING, "Warning");
static char start_text[64];
@ -745,13 +757,6 @@ restart:
sprintf(start_text, "SameBoy v" GB_VERSION "\n%s\n%08X", title, GB_get_rom_crc32(&gb));
show_osd_text(start_text);
/* Configure battery */
char battery_save_path[path_length + 5]; /* At the worst case, size is strlen(path) + 4 bytes for .sav + NULL */
replace_extension(filename, path_length, battery_save_path, ".sav");
battery_save_path_ptr = battery_save_path;
GB_load_battery(&gb, battery_save_path);
/* Configure symbols */
GB_debugger_load_symbol_file(&gb, resource_path("registers.sym"));