From: Mikko Rasa Date: Thu, 10 Feb 2011 21:46:34 +0000 (+0000) Subject: Save state to tempfile an rename to avoid losing it in case saving fails X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f4417d49014ec6bcbb4b5dfcbe85c8395bae662f;p=r2c2.git Save state to tempfile an rename to avoid losing it in case saving fails --- diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index 8db0be6..90cb8eb 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -12,6 +12,7 @@ Distributed under the GPL #include #include #include +#include #include #include #include @@ -131,7 +132,10 @@ Engineer::~Engineer() layout.get_driver().flush(); if(!options.simulate) - layout.save_dynamic(options.state_fn); + { + layout.save_dynamic(options.state_fn+".tmp"); + FS::rename(options.state_fn+".tmp", options.state_fn); + } delete overlay; delete root;