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
This commit is contained in:
Kurt
2017-04-28 17:40:59 -07:00
parent 8fa0f9cc7e
commit 2de3639f31

View File

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