From 755b40a966076b8d490f34e6c565722c3bc2b12f Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sun, 2 Aug 2009 20:39:36 +0000 Subject: [PATCH] Switch the safer autosaving to the standard method of writing to a different file then replacing the original. Originally committed to SVN as r3354. --- aegisub/src/frame_main_events.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/aegisub/src/frame_main_events.cpp b/aegisub/src/frame_main_events.cpp index fcc5dfa20..7bac96b33 100644 --- a/aegisub/src/frame_main_events.cpp +++ b/aegisub/src/frame_main_events.cpp @@ -1750,19 +1750,11 @@ void FrameMain::OnAutoSave(wxTimerEvent &event) { dstpath.SetFullName(name + L".AUTOSAVE.ass"); } - // If the autosave file already exists, make a temporary copy of it in case the autosave fails - wxFileName backup; - if (dstpath.FileExists()) { - backup = dstpath; - backup.SetName(backup.GetName() + ".backup"); - wxRenameFile(dstpath.GetFullPath(), backup.GetFullPath()); - } + wxFileName temp = dstpath; + temp.SetName(dstpath.GetName() + ".temp"); - AssFile::top->Save(dstpath.GetFullPath(),false,false); - - if (backup.FileExists()) { - wxRemoveFile(backup.GetFullPath()); - } + AssFile::top->Save(temp.GetFullPath(),false,false); + wxRenameFile(temp.GetFullPath(), dstpath.GetFullPath()); // Set status bar StatusTimeout(_("File backup saved as \"") + dstpath.GetFullPath() + _T("\"."));