summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorBernd Wachter <bwachter-tmw@lart.info>2010-03-18 20:24:46 +0100
committerBernd Wachter <bwachter-tmw@lart.info>2010-03-18 20:24:46 +0100
commit18abf64759ce8c9d338ce35f4da2938a9dc6548d (patch)
tree97e9aae68c0beeb22f54c68f69ee2aaba17fab76 /src/client.cpp
parentd5de9172924d56d8c598e2d43563fa60bbf1f6cc (diff)
downloadmana-18abf64759ce8c9d338ce35f4da2938a9dc6548d.tar.gz
mana-18abf64759ce8c9d338ce35f4da2938a9dc6548d.tar.bz2
mana-18abf64759ce8c9d338ce35f4da2938a9dc6548d.tar.xz
mana-18abf64759ce8c9d338ce35f4da2938a9dc6548d.zip
Copy old tmw config if found
Reviewed-by: Thorbjørn Lindeijer
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 3944215a..eebdaace 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1035,6 +1035,32 @@ void Client::initHomeDir()
logger->error(strprintf(_("%s doesn't exist and can't be created! "
"Exiting."), mConfigDir.c_str()));
}
+
+ struct stat statbuf;
+ std::string newConfigFile = mConfigDir + "/config.xml";
+ if (stat(newConfigFile.c_str(), &statbuf))
+ {
+ std::string oldConfigFile = std::string(PHYSFS_getUserDir()) +
+ "/.tmw/config.xml";
+ if (!stat(oldConfigFile.c_str(), &statbuf) && S_ISREG(statbuf.st_mode))
+ {
+ std::ifstream oldConfig;
+ std::ofstream newConfig;
+ logger->log("Copying old TMW settings.");
+
+ oldConfig.open(oldConfigFile.c_str(), std::ios::binary);
+ newConfig.open(newConfigFile.c_str(), std::ios::binary);
+
+ if (!oldConfig.is_open() || !newConfig.is_open())
+ logger->log("Unable to copy old settings.");
+ else
+ {
+ newConfig << oldConfig.rdbuf();
+ newConfig.close();
+ oldConfig.close();
+ }
+ }
+ }
}
/**