Customizable saves path

This commit is contained in:
Simone Coco
2024-05-20 10:33:52 +02:00
parent 8cb30838ed
commit 315a522dbf
7 changed files with 54 additions and 3 deletions

View File

@@ -38,6 +38,9 @@ void Mem::Reset() {
void Mem::LoadSRAM(SaveType save_type, fs::path path) {
if(save_type == SAVE_SRAM_256k) {
std::error_code error;
if (!savePath.empty()) {
path = savePath / path.filename();
}
sramPath = path.replace_extension(".sram").string();
if(saveData.is_mapped()) {
saveData.sync(error);

View File

@@ -12,7 +12,11 @@ void Flash::Reset() {
void Flash::Load(SaveType saveType, const std::string& path) {
if(saveType == SAVE_FLASH_1m) {
flashPath = fs::path(path).replace_extension(".flash").string();
fs::path flashPath_ = path;
if (!savePath.empty()) {
flashPath_ = savePath / flashPath_.filename();
}
flashPath = flashPath_.replace_extension(".flash").string();
std::error_code error;
if (saveData.is_mapped()) {
saveData.sync(error);

View File

@@ -30,7 +30,11 @@ void PIF::Reset() {
void PIF::MaybeLoadMempak() {
if(!mempakOpen) {
mempakPath = fs::path(mempakPath).replace_extension(".mempak").string();
fs::path mempakPath_ = mempakPath;
if (!savePath.empty()) {
mempakPath_ = savePath / mempakPath_.filename();
}
mempakPath = mempakPath_.replace_extension(".mempak").string();
std::error_code error;
if (mempak.is_mapped()) {
mempak.sync(error);
@@ -74,7 +78,11 @@ FORCE_INLINE size_t GetSaveSize(SaveType saveType) {
void PIF::LoadEeprom(SaveType saveType, const std::string& path) {
if(saveType == SAVE_EEPROM_16k || saveType == SAVE_EEPROM_4k) {
eepromPath = fs::path(path).replace_extension(".eeprom").string();
fs::path eepromPath_ = path;
if (!savePath.empty()) {
eepromPath_ = savePath / eepromPath_.filename();
}
eepromPath = eepromPath_.replace_extension(".eeprom").string();
std::error_code error;
if (eeprom.is_mapped()) {
eeprom.sync(error);