From bc85e0b16523ec5b7a52a8e4a6d03bf4c1ae5c72 Mon Sep 17 00:00:00 2001 From: colton5007 Date: Sun, 29 May 2022 01:04:42 -0500 Subject: [PATCH] Fixed GBA SRAMPath in posix CLI --- desmume/src/frontend/posix/cli/main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/desmume/src/frontend/posix/cli/main.cpp b/desmume/src/frontend/posix/cli/main.cpp index 9e16f53ea..f748233c2 100644 --- a/desmume/src/frontend/posix/cli/main.cpp +++ b/desmume/src/frontend/posix/cli/main.cpp @@ -388,11 +388,10 @@ int main(int argc, char ** argv) { //set the GBA rom and sav paths GBACartridge_RomPath = my_config.gbaslot_rom.c_str(); - if(toupper(strright(GBACartridge_RomPath,4)) == ".GBA") - GBACartridge_SRAMPath = strright(GBACartridge_RomPath,4) + ".sav"; - else - //what to do? lets just do the same thing for now - GBACartridge_SRAMPath = strright(GBACartridge_RomPath,4) + ".sav"; + // finds the index of the file extension separator + int RomPath_ExtIdx = GBACartridge_RomPath.find_last_of("."); + // checks if file has extension, if so replaces extension with .sav for SRAM Path, otherwise append .sav + GBACartridge_SRAMPath = GBACartridge_RomPath.substr(0, RomPath_ExtIdx) + ".sav"; // Check if the file exists and can be opened FILE * test = fopen(GBACartridge_RomPath.c_str(), "rb");