From f4417d49014ec6bcbb4b5dfcbe85c8395bae662f Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 10 Feb 2011 21:46:34 +0000 Subject: [PATCH] Save state to tempfile an rename to avoid losing it in case saving fails --- source/engineer/engineer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; -- 2.45.2