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
1 changed files with 4 additions and 12 deletions

View File

@ -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("\"."));