diff --git a/src/porting.cpp b/src/porting.cpp index d0f9efe..986f7e4 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -332,20 +332,27 @@ void initializePaths(char* argv0) path_data = std::string(buf) + "/share/" + PROJECT_NAME; //path_data = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME; - if (!fs::PathExists(path_data)) { + if (!fs::PathExists(path_data)) + { dstream<<"WARNING: data path " << path_data << " not found!"; path_data = std::string(buf) + "/data"; dstream<<" Trying " << path_data << std::endl; } - if(getenv("XDG_CONFIG_HOME") == NULL) { - path_configdata = std::string(getenv("HOME")) + "/.config/" + PROJECT_NAME; - } else { + if (getenv("XDG_CONFIG_HOME") == NULL) + { + path_configdata = std::string(getenv("HOME")) + + "/.config/" + PROJECT_NAME; + } else + { path_configdata = std::string(getenv("XDG_CONFIG_HOME")); } - if(getenv("XDG_DATA_HOME") == NULL) { - path_userdata = std::string(getenv("HOME")) + "/.local/share/" + PROJECT_NAME; - } else { + if (getenv("XDG_DATA_HOME") == NULL) + { + path_userdata = std::string(getenv("HOME")) + + "/.local/share/" + PROJECT_NAME; + } else + { path_userdata = std::string(getenv("XDG_DATA_HOME")); } @@ -380,14 +387,18 @@ void initializePaths(char* argv0) path_data = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME; - if (getenv("XDG_CONFIG_HOME") == NULL) { + if (getenv("XDG_CONFIG_HOME") == NULL) + { path_configdata = std::string(getenv("HOME")) + "/.config/" + PROJECT_NAME; - } else { + } else + { path_configdata = std::string(getenv("XDG_CONFIG_HOME")); } - if (getenv("XDG_DATA_HOME") == NULL) { + if (getenv("XDG_DATA_HOME") == NULL) + { path_userdata = std::string(getenv("HOME")) + "/.local/share/" + PROJECT_NAME; - } else { + } else + { path_userdata = std::string(getenv("XDG_DATA_HOME")); } @@ -403,32 +414,45 @@ void initializePaths(char* argv0) std::string path_olddirectory = std::string(getenv("HOME")) + "/." + PROJECT_NAME; - if (fs::PathExists(path_olddirectory)) { - dstream<<"Found the old Directory! I will try to migrate the Directory." << std::endl; + if (fs::PathExists(path_olddirectory)) + { + dstream<<"Old directory found, Migrating process will start now." << std::endl; - if (!fs::PathExists(path_configdata)) { + if (!fs::PathExists(path_configdata)) + { fs::CreateDir(path_configdata); - std::string path_oldconfig = std::string(getenv("HOME")) + "/.voxelands/voxelands.conf"; + std::string path_oldconfig = std::string(getenv("HOME")) + + "/.voxelands/voxelands.conf"; std::string path_newconfig = path_configdata + "/voxelands.conf"; - if (rename( path_oldconfig.c_str() , path_newconfig.c_str() ) == 0) { - dstream<<"Config was sucessful migrated." << std::endl; - } else { - dstream<<"Error while move the Config Directory: " << strerror(errno) << std::endl; + if (rename( path_oldconfig.c_str() , path_newconfig.c_str() ) == 0) + { + dstream<<"Config is successful migrated." << std::endl; + } else + { + dstream<<"Error while moving the Config directory: " << std::endl; + dstream<" */ std::string getDataPath(const char *subpath); + /* Initialize path_data and path_userdata. */