Move SwapBackupSavestate() from EmuHawk.Mainform to Client.Common.SaveSlotManager

This commit is contained in:
adelikat 2013-12-24 22:20:18 +00:00
parent dd63395f67
commit e711a6ec6f
3 changed files with 28 additions and 28 deletions

View File

@ -99,5 +99,32 @@ namespace BizHawk.Client.Common
ClearRedoList();
Update();
}
public void SwapBackupSavestate(string path)
{
// Takes the .state and .bak files and swaps them
var state = new FileInfo(path);
var backup = new FileInfo(path + ".bak");
var temp = new FileInfo(path + ".bak.tmp");
if (!state.Exists || !backup.Exists)
{
return;
}
if (temp.Exists)
{
temp.Delete();
}
backup.CopyTo(path + ".bak.tmp");
backup.Delete();
state.CopyTo(path + ".bak");
state.Delete();
temp.CopyTo(path);
temp.Delete();
ToggleRedo(Global.Config.SaveSlot);
}
}
}

View File

@ -1874,7 +1874,7 @@ namespace BizHawk.Client.EmuHawk
private void UndoSavestateContextMenuItem_Click(object sender, EventArgs e)
{
SwapBackupSavestate(
_stateSlots.SwapBackupSavestate(
PathManager.SaveStatePrefix(Global.Game) +
".QuickSave" +
Global.Config.SaveSlot +

View File

@ -3571,33 +3571,6 @@ namespace BizHawk.Client.EmuHawk
}
}
private void SwapBackupSavestate(string path) // Move inside Saveslot Manager
{
// Takes the .state and .bak files and swaps them
var state = new FileInfo(path);
var backup = new FileInfo(path + ".bak");
var temp = new FileInfo(path + ".bak.tmp");
if (!state.Exists || !backup.Exists)
{
return;
}
if (temp.Exists)
{
temp.Delete();
}
backup.CopyTo(path + ".bak.tmp");
backup.Delete();
state.CopyTo(path + ".bak");
state.Delete();
temp.CopyTo(path);
temp.Delete();
_stateSlots.ToggleRedo(Global.Config.SaveSlot);
}
private static void ProcessMovieImport(string fn) // Nothing Winform Specific here, move to Movie import
{
var d = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPathFragment, null);