Should fix path issues with UPS patching.

When filename had two dots ('.') in it,
using fill_pathname on g_extern.basename was wrong.
Added fill_pathname_noext to countermeasure this.
This commit is contained in:
Themaister 2011-04-03 21:43:25 +02:00
parent f5fb113563
commit b2d214ee79
2 changed files with 11 additions and 5 deletions

2
file.c
View File

@ -164,7 +164,7 @@ static ssize_t read_rom_file(FILE* file, void** buf)
}
}
else if (*g_extern.ups_name)
SSNES_LOG("Could not find UPS patch.\n");
SSNES_LOG("Could not find UPS patch in: \"%s\".\n", g_extern.ups_name);
// Remove SMC header if present.
if ((ret & 0x7fff) == 512)

14
ssnes.c
View File

@ -220,7 +220,7 @@ static int16_t input_state(bool port, unsigned device, unsigned index, unsigned
return res;
}
static void fill_pathname(char *out_path, char *in_path, const char *replace)
static void fill_pathname(char *out_path, const char *in_path, const char *replace)
{
char tmp_path[strlen(in_path) + 1];
strcpy(tmp_path, in_path);
@ -232,6 +232,12 @@ static void fill_pathname(char *out_path, char *in_path, const char *replace)
strcat(out_path, replace);
}
static void fill_pathname_noext(char *out_path, const char *in_path, const char *replace)
{
strcpy(out_path, in_path);
strcat(out_path, replace);
}
#ifdef _WIN32
#define SSNES_DEFAULT_CONF_PATH_STR "\n\tDefaults to ssnes.cfg in same directory as ssnes.exe"
#elif defined(__APPLE__)
@ -530,9 +536,9 @@ static void parse_input(int argc, char *argv[])
}
// strl* would be nice :D
if (!g_extern.has_set_save_path)
fill_pathname(g_extern.savefile_name_srm, g_extern.basename, ".srm");
fill_pathname_noext(g_extern.savefile_name_srm, g_extern.basename, ".srm");
if (!g_extern.has_set_state_path)
fill_pathname(g_extern.savestate_name, g_extern.basename, ".state");
fill_pathname_noext(g_extern.savestate_name, g_extern.basename, ".state");
}
else if (strlen(g_extern.savefile_name_srm) == 0)
{
@ -881,7 +887,7 @@ static void fill_pathnames(void)
fill_pathname(g_extern.bsv_movie_path, g_extern.savefile_name_srm, "");
if (!(*g_extern.ups_name) && *g_extern.basename)
fill_pathname(g_extern.ups_name, g_extern.basename, ".ups");
fill_pathname_noext(g_extern.ups_name, g_extern.basename, ".ups");
}
// Save or load state here.