Use splitpath in CheckForAnyPatch (fixes extensions != 3 characters)

This commit is contained in:
OV2 2023-03-12 14:11:31 +01:00
parent eaaf1ad779
commit c654caed32
1 changed files with 3 additions and 8 deletions

View File

@ -3807,15 +3807,10 @@ void CMemory::CheckForAnyPatch(const char *rom_filename, bool8 header, int32 &ro
int ret; int ret;
bool flag = false; bool flag = false;
int rom_filename_length = strlen(rom_filename); auto path = splitpath(rom_filename);
const char *ext = NULL;
if (rom_filename_length < 4)
return;
if (rom_filename[rom_filename_length - 4] == '.')
ext = &rom_filename[rom_filename_length - 3];
#ifdef UNZIP_SUPPORT #ifdef UNZIP_SUPPORT
if (!strcasecmp(ext, "zip") || !strcasecmp(ext, ".zip")) if (path.ext_is(".zip"))
{ {
unzFile file = unzOpen(rom_filename); unzFile file = unzOpen(rom_filename);
if (file) if (file)
@ -3872,7 +3867,7 @@ void CMemory::CheckForAnyPatch(const char *rom_filename, bool8 header, int32 &ro
} }
// Mercurial Magic (MSU-1 distribution pack) // Mercurial Magic (MSU-1 distribution pack)
if (strcasecmp(ext, "msu1") && strcasecmp(ext, ".msu1")) // ROM was *NOT* loaded from a .msu1 pack if (path.ext_is(".msu1")) // ROM was *NOT* loaded from a .msu1 pack
{ {
Stream *s = S9xMSU1OpenFile("patch.bps", TRUE); Stream *s = S9xMSU1OpenFile("patch.bps", TRUE);
if (s) if (s)