gtk, unix: fixes to unbreak build and loading ROMs

This commit is contained in:
Ari Sundholm 2017-09-09 14:10:56 +03:00
parent 7455501db8
commit 4080eef6a7
3 changed files with 47 additions and 25 deletions

View File

@ -33,6 +33,7 @@ _splitpath (const char *path, char *drive, char *dir, char *fname, char *ext)
char *slash = strrchr ((char *) path, SLASH_CHAR);
char *dot = strrchr ((char *) path, '.');
if (drive)
*drive = '\0';
if (dot && slash && dot < slash)
@ -42,32 +43,43 @@ _splitpath (const char *path, char *drive, char *dir, char *fname, char *ext)
if (!slash)
{
if (dir)
*dir = '\0';
if (fname)
strcpy (fname, path);
if (dot)
{
if (fname)
fname[dot - path] = '\0';
if (ext)
strcpy (ext, dot + 1);
}
else
{
if (ext)
*ext = '\0';
}
}
else
{
if (dir) {
strcpy (dir, path);
dir[slash - path] = '\0';
}
if (fname)
strcpy (fname, slash + 1);
if (dot)
{
if (fname)
fname[(dot - slash) - 1] = '\0';
if (ext)
strcpy (ext, dot + 1);
}
else
{
if (ext)
*ext = '\0';
}
}

View File

@ -388,7 +388,7 @@ bool S9xMSU1ROMExists(void)
}
#ifdef UNZIP_SUPPORT
char ext[_MAX_EXT + 1];
_splitpath(Memory.ROMFilename, nullptr, nullptr, nullptr, ext);
_splitpath(Memory.ROMFilename, NULL, NULL, NULL, ext);
if (!strcasecmp(ext, ".msu1"))
return true;

View File

@ -354,6 +354,7 @@ static void ReadJoysticks (void);
void _splitpath (const char *path, char *drive, char *dir, char *fname, char *ext)
{
if (drive)
*drive = 0;
const char *slash = strrchr(path, SLASH_CHAR),
@ -364,31 +365,40 @@ void _splitpath (const char *path, char *drive, char *dir, char *fname, char *ex
if (!slash)
{
if (dir)
*dir = 0;
if (fname)
strcpy(fname, path);
if (dot)
{
if (fname)
fname[dot - path] = 0;
if (ext)
strcpy(ext, dot + 1);
}
else
else if (ext)
*ext = 0;
}
else
{
if (dir) {
strcpy(dir, path);
dir[slash - path] = 0;
}
if (fname)
strcpy(fname, slash + 1);
if (dot)
{
if (fname)
fname[dot - slash - 1] = 0;
if (ext)
strcpy(ext, dot + 1);
}
else
else if (ext)
*ext = 0;
}
}