[gnome-games] retro-runner: Ensure save directory doesn't change during the game
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] retro-runner: Ensure save directory doesn't change during the game
- Date: Mon, 22 Mar 2021 07:29:12 +0000 (UTC)
commit 1eb9f89000d58f93ab85804d3678b71c27b235ec
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Mar 22 12:21:58 2021 +0500
retro-runner: Ensure save directory doesn't change during the game
Currently, we make a new save directory every time we load a state.
Unfortunately, libretro cores don't really have a good way to track
the save dir changes, save from polling it every frame and comparing to
what they have. And, for example, Dolphin doesn't do this.
Instead, create a save directory once per game and never change it, just
replace its contents when loading the state.
src/retro/retro-runner.vala | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 42e91adf..c17722d9 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -220,6 +220,11 @@ public class Games.RetroRunner : Object, Runner {
tmp_save_dir = create_tmp_save_dir ();
+ var tmp_dir = File.new_for_path (tmp_save_dir);
+ if (tmp_dir.query_exists ())
+ FileOperations.delete_files (tmp_dir);
+ tmp_dir.make_directory ();
+
if (snapshot != null) {
snapshot.copy_save_dir_to (tmp_save_dir);
} else {
@@ -319,7 +324,7 @@ public class Games.RetroRunner : Object, Runner {
var tmp_dir = File.new_for_path (tmp_save_dir);
var dest_dir = File.new_for_path (Path.build_filename (path, "save-dir"));
if (dest_dir.query_exists ())
- FileOperations.delete_files (dest_dir, {});
+ FileOperations.delete_files (dest_dir);
FileOperations.copy_contents (tmp_dir, dest_dir);
}
catch (Error e) {
@@ -538,9 +543,13 @@ public class Games.RetroRunner : Object, Runner {
}
protected virtual void load_from_snapshot (Snapshot snapshot) throws Error {
- tmp_save_dir = create_tmp_save_dir ();
+ File tmp_dir = File.new_for_path (tmp_save_dir);
+
+ if (tmp_dir.query_exists ())
+ FileOperations.delete_files (tmp_dir);
+ tmp_dir.make_directory ();
+
snapshot.copy_save_dir_to (tmp_save_dir);
- core.save_directory = tmp_save_dir;
load_save_ram (snapshot.get_save_ram_path ());
core.load_state (snapshot.get_snapshot_path ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]