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,7 +33,8 @@ _splitpath (const char *path, char *drive, char *dir, char *fname, char *ext)
char *slash = strrchr ((char *) path, SLASH_CHAR);
char *dot = strrchr ((char *) path, '.');
*drive = '\0';
if (drive)
*drive = '\0';
if (dot && slash && dot < slash)
{
@ -42,33 +43,44 @@ _splitpath (const char *path, char *drive, char *dir, char *fname, char *ext)
if (!slash)
{
*dir = '\0';
strcpy (fname, path);
if (dir)
*dir = '\0';
if (fname)
strcpy (fname, path);
if (dot)
{
fname[dot - path] = '\0';
strcpy (ext, dot + 1);
if (fname)
fname[dot - path] = '\0';
if (ext)
strcpy (ext, dot + 1);
}
else
{
*ext = '\0';
if (ext)
*ext = '\0';
}
}
else
{
strcpy (dir, path);
dir[slash - path] = '\0';
strcpy (fname, slash + 1);
if (dir) {
strcpy (dir, path);
dir[slash - path] = '\0';
}
if (fname)
strcpy (fname, slash + 1);
if (dot)
{
fname[(dot - slash) - 1] = '\0';
strcpy (ext, dot + 1);
if (fname)
fname[(dot - slash) - 1] = '\0';
if (ext)
strcpy (ext, dot + 1);
}
else
{
*ext = '\0';
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,7 +354,8 @@ static void ReadJoysticks (void);
void _splitpath (const char *path, char *drive, char *dir, char *fname, char *ext)
{
*drive = 0;
if (drive)
*drive = 0;
const char *slash = strrchr(path, SLASH_CHAR),
*dot = strrchr(path, '.');
@ -364,31 +365,40 @@ void _splitpath (const char *path, char *drive, char *dir, char *fname, char *ex
if (!slash)
{
*dir = 0;
if (dir)
*dir = 0;
strcpy(fname, path);
if (fname)
strcpy(fname, path);
if (dot)
{
fname[dot - path] = 0;
strcpy(ext, dot + 1);
if (fname)
fname[dot - path] = 0;
if (ext)
strcpy(ext, dot + 1);
}
else
else if (ext)
*ext = 0;
}
else
{
strcpy(dir, path);
dir[slash - path] = 0;
if (dir) {
strcpy(dir, path);
dir[slash - path] = 0;
}
strcpy(fname, slash + 1);
if (fname)
strcpy(fname, slash + 1);
if (dot)
{
fname[dot - slash - 1] = 0;
strcpy(ext, dot + 1);
if (fname)
fname[dot - slash - 1] = 0;
if (ext)
strcpy(ext, dot + 1);
}
else
else if (ext)
*ext = 0;
}
}