Small flash refactor

This commit is contained in:
Simone
2024-05-13 17:49:14 +02:00
committed by Simone
parent b45491ddc0
commit 5ebb36e3fa

View File

@@ -22,9 +22,7 @@ void Flash::Load(SaveType saveType, const std::string& path) {
FILE *f = fopen(flashPath.c_str(), "rb"); FILE *f = fopen(flashPath.c_str(), "rb");
if (!f) { if (!f) {
f = fopen(flashPath.c_str(), "wb"); Util::panic("Could not open {}", flashPath);
u8* dummy = (u8*)calloc(FLASH_SIZE, 1);
fwrite(dummy, 1, FLASH_SIZE, f);
} }
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
@@ -37,7 +35,7 @@ void Flash::Load(SaveType saveType, const std::string& path) {
saveData = mio::make_mmap_sink( saveData = mio::make_mmap_sink(
flashPath, 0, mio::map_entire_file, error); flashPath, 0, mio::map_entire_file, error);
if (error) { Util::panic("Could not open {}", path); } if (error) { Util::panic("Could not make mmap {}", flashPath); }
} }
} }