Merge pull request #737 from jraby/fix-relative-paths-savestates

gtk: fix handling of relative paths for save states
This commit is contained in:
bearoso 2022-02-18 13:57:00 -06:00 committed by GitHub
commit 32347eb6a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 32 deletions

View File

@ -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)
{

View File

@ -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());