]> git.tdb.fi Git - r2c2.git/commitdiff
Save state to tempfile an rename to avoid losing it in case saving fails
authorMikko Rasa <tdb@tdb.fi>
Thu, 10 Feb 2011 21:46:34 +0000 (21:46 +0000)
committerMikko Rasa <tdb@tdb.fi>
Thu, 10 Feb 2011 21:46:34 +0000 (21:46 +0000)
source/engineer/engineer.cpp

index 8db0be6c2465433f23cef8ea3610fb3fb9da0aaf..90cb8eb7007fbb9ab08e62924888e42f546d6680 100644 (file)
@@ -12,6 +12,7 @@ Distributed under the GPL
 #include <signal.h>
 #include <msp/core/except.h>
 #include <msp/fs/stat.h>
+#include <msp/fs/utils.h>
 #include <msp/gbase/display.h>
 #include <msp/gbase/window.h>
 #include <msp/gl/blend.h>
@@ -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;