summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-01 13:17:34 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-01 13:17:34 +0300
commitc28e2e8e0cfa0ae4358f798c3bd34c8678de9541 (patch)
treedb84a006ab6e2a8d4d00a25e8216ed22ac6d2fb9 /src/client.cpp
parent9fc83299bfb029328f19671efae42a7f4b4d465a (diff)
downloadplus-c28e2e8e0cfa0ae4358f798c3bd34c8678de9541.tar.gz
plus-c28e2e8e0cfa0ae4358f798c3bd34c8678de9541.tar.bz2
plus-c28e2e8e0cfa0ae4358f798c3bd34c8678de9541.tar.xz
plus-c28e2e8e0cfa0ae4358f798c3bd34c8678de9541.zip
add ability for auto backup main configuration file on startup.
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 483b260ee..d27896a14 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -110,6 +110,7 @@
#include "utils/files.h"
#include "utils/fuzzer.h"
#include "utils/gettext.h"
+#include "utils/files.h"
#include "utils/mkdir.h"
#include "utils/paths.h"
#include "utils/physfstools.h"
@@ -297,6 +298,7 @@ void Client::gameInit()
#ifdef USE_FUZZER
Fuzzer::init();
#endif
+ backupConfig();
initConfiguration();
paths.setDefaultValues(getPathsDefaults());
initFeatures();
@@ -2142,6 +2144,22 @@ void Client::initConfiguration() const
}
}
+void Client::backupConfig() const
+{
+ const std::string confName = mConfigDir + "/config.xml.bak";
+ const int maxFileIndex = 5;
+ ::remove((confName + toString(maxFileIndex)).c_str());
+ for (int f = maxFileIndex; f > 1; f --)
+ {
+ const std::string fileName1 = confName + toString(f - 1);
+ const std::string fileName2 = confName + toString(f);
+ Files::renameFile(fileName1, fileName2);
+ }
+ const std::string fileName3 = mConfigDir + "/config.xml";
+ const std::string fileName4 = confName + toString(1);
+ Files::copyFile(fileName3, fileName4);
+}
+
/**
* Parse the update host and determine the updates directory
* Then verify that the directory exists (creating if needed).