Merge pull request #737 from jraby/fix-relative-paths-savestates
gtk: fix handling of relative paths for save states
This commit is contained in:
commit
32347eb6a9
@ -178,38 +178,8 @@ static int file_exists(const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
bool8 S9xOpenSnapshotFile(const char *fname, bool8 read_only, STREAM *file)
|
||||
bool8 S9xOpenSnapshotFile(const char *filename, bool8 read_only, STREAM *file)
|
||||
{
|
||||
char filename[PATH_MAX + 1];
|
||||
char drive[_MAX_DRIVE + 1];
|
||||
char dir[_MAX_DIR + 1];
|
||||
char ext[_MAX_EXT + 1];
|
||||
|
||||
_splitpath(fname, drive, dir, filename, ext);
|
||||
|
||||
if (*drive || *dir == '/' || (*dir == '.' && (*(dir + 1) == '/')))
|
||||
{
|
||||
snprintf(filename, PATH_MAX + 1, "%s", fname);
|
||||
|
||||
if (!file_exists(filename))
|
||||
{
|
||||
if (!*ext)
|
||||
strcat(filename, ".s9x");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(filename, S9xGetDirectory(SNAPSHOT_DIR));
|
||||
strcat(filename, SLASH_STR);
|
||||
strcat(filename, fname);
|
||||
|
||||
if (!file_exists(filename))
|
||||
{
|
||||
if (!*ext)
|
||||
strcat(filename, ".s9x");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ZLIB
|
||||
if (read_only)
|
||||
{
|
||||
|
@ -838,7 +838,7 @@ void Snes9xWindow::save_state_dialog()
|
||||
dialog.add_button(Gtk::StockID("gtk-cancel"), Gtk::RESPONSE_CANCEL);
|
||||
dialog.add_button(Gtk::StockID("gtk-save"), Gtk::RESPONSE_ACCEPT);
|
||||
dialog.set_current_folder(S9xGetDirectory(SNAPSHOT_DIR));
|
||||
dialog.set_current_name(S9xGetFilename(".sst", SNAPSHOT_DIR));
|
||||
dialog.set_current_name(S9xBasename(S9xGetFilename(".sst", SNAPSHOT_DIR)));
|
||||
dialog.add_filter(get_save_states_file_filter());
|
||||
dialog.add_filter(get_all_files_filter());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user