Util_ROM/Reset() : Use strrchr()

Signed-off-by: Madhav Kanbur <abcdjdj@gmail.com>
This commit is contained in:
Madhav Kanbur 2021-01-22 11:47:21 +05:30
parent 0258677af2
commit c8af6f066f
1 changed files with 8 additions and 8 deletions

View File

@ -536,11 +536,11 @@ int Reset()
char romfilename[1024] = {0}, sramfilename[1024];
strncpy(sramfilename, SRAMPath[ROMSlot_NDS], 1024); // Use existing SRAMPath
int pos = strlen(sramfilename) - 1;
while(pos > 0 && sramfilename[pos] != '/' && sramfilename[pos] != '\\')
--pos;
char *pos = strrchr(sramfilename, '/');
if(!pos)
pos = strrchr(sramfilename, '\\');
strncpy(romfilename, &sramfilename[pos + 1], 1024);
strncpy(romfilename, pos + 1, 1024);
strncpy(&romfilename[strlen(romfilename) - 3], NDSROMExtension, 3); // extension could be nds, srl or dsi
printf("RESET loading from archive : %s\n", romfilename);
romlen = Archive::ExtractFileFromArchive(ROMPath[ROMSlot_NDS], romfilename, &romdata);
@ -572,11 +572,11 @@ int Reset()
char romfilename[1024] = {0}, sramfilename[1024];
strncpy(sramfilename, SRAMPath[ROMSlot_GBA], 1024); // Use existing SRAMPath
int pos = strlen(sramfilename) - 1;
while(pos > 0 && sramfilename[pos] != '/' && sramfilename[pos] != '\\')
--pos;
char *pos = strrchr(sramfilename, '/');
if(!pos)
pos = strrchr(sramfilename, '\\');
strncpy(romfilename, &sramfilename[pos + 1], 1024);
strncpy(romfilename, pos + 1, 1024);
strncpy(&romfilename[strlen(romfilename) - 3], "gba", 3);
printf("RESET loading from archive : %s\n", romfilename);
romlen = Archive::ExtractFileFromArchive(ROMPath[ROMSlot_GBA], romfilename, &romdata);