Switch the safer autosaving to the standard method of writing to a different file then replacing the original.

Originally committed to SVN as r3354.
This commit is contained in:
Thomas Goyne 2009-08-02 20:39:36 +00:00
parent cca0de98cb
commit 755b40a966

View file

@ -1750,19 +1750,11 @@ void FrameMain::OnAutoSave(wxTimerEvent &event) {
dstpath.SetFullName(name + L".AUTOSAVE.ass"); dstpath.SetFullName(name + L".AUTOSAVE.ass");
} }
// If the autosave file already exists, make a temporary copy of it in case the autosave fails wxFileName temp = dstpath;
wxFileName backup; temp.SetName(dstpath.GetName() + ".temp");
if (dstpath.FileExists()) {
backup = dstpath;
backup.SetName(backup.GetName() + ".backup");
wxRenameFile(dstpath.GetFullPath(), backup.GetFullPath());
}
AssFile::top->Save(dstpath.GetFullPath(),false,false); AssFile::top->Save(temp.GetFullPath(),false,false);
wxRenameFile(temp.GetFullPath(), dstpath.GetFullPath());
if (backup.FileExists()) {
wxRemoveFile(backup.GetFullPath());
}
// Set status bar // Set status bar
StatusTimeout(_("File backup saved as \"") + dstpath.GetFullPath() + _T("\".")); StatusTimeout(_("File backup saved as \"") + dstpath.GetFullPath() + _T("\"."));