From 2de3639f31450514ad7f1bbdef52cfb33a6461db Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 28 Apr 2017 17:40:59 -0700 Subject: [PATCH] Update backup/restore feature trycatch the restoration action, and force overwriting https://projectpokemon.org/forums/forums/topic/34377-pk3ds-xyoras-rom-editor-randomizer/?page=37#comment-213548 --- pk3DS/Game/GameBackup.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pk3DS/Game/GameBackup.cs b/pk3DS/Game/GameBackup.cs index e960444..a66fa4a 100644 --- a/pk3DS/Game/GameBackup.cs +++ b/pk3DS/Game/GameBackup.cs @@ -142,13 +142,13 @@ private static int restoreExeFS(GameConfig config, string bak_exefs) { int count = 0; var files = Directory.GetFiles(config.ExeFS); - foreach (var f in files) + foreach (var src in files) { - string dest = Path.Combine(bak_exefs, Path.GetFileName(f)); + string dest = Path.Combine(bak_exefs, Path.GetFileName(src)); if (File.Exists(dest)) { - File.Copy(dest, f); - count++; + try { File.Copy(dest, src, overwrite: true); count++; } + catch { Console.WriteLine("Unable to overwrite backup: " + dest); } } else Console.WriteLine("Unable to find backup: " + dest); @@ -167,8 +167,8 @@ private static int restoreGARC(GameConfig config, string bak_a) string dest = Path.Combine(bak_a, name); if (File.Exists(dest)) { - File.Copy(dest, src); - count++; + try { File.Copy(dest, src, overwrite: true); count++; } + catch { Console.WriteLine("Unable to overwrite backup: " + dest); } } else Console.WriteLine("Unable to find backup: " + dest); @@ -195,8 +195,8 @@ private static int restoreDLL(GameConfig config, string bak_dll) string dest = Path.Combine(bak_dll, Path.GetFileName(src)); if (File.Exists(dest)) { - File.Copy(dest, src); - count++; + try { File.Copy(dest, src, overwrite: true); count++; } + catch { Console.WriteLine("Unable to overwrite backup: " + dest); } } else Console.WriteLine("Unable to find backup: " + dest);