Moved userdata directory to an XDG-compliant location. (Fix for bug #11558.)
This commit is contained in:
parent
2ca092a37d
commit
2f8556935d
1 changed files with 30 additions and 4 deletions
|
@ -509,13 +509,38 @@ void set_preferences_dir(std::string path)
|
|||
}
|
||||
|
||||
#else /*_WIN32*/
|
||||
if (path.empty()) {
|
||||
|
||||
#ifdef PREFERENCES_DIR
|
||||
path = PREFERENCES_DIR;
|
||||
#else
|
||||
path = ".wesnoth" + game_config::version.substr(0,3);
|
||||
if (path.empty()) path = PREFERENCES_DIR;
|
||||
#endif
|
||||
|
||||
std::string path2 = ".wesnoth" + game_config::version.substr(0,3);
|
||||
|
||||
#ifdef _X11
|
||||
const char *home_str = getenv("HOME");
|
||||
|
||||
if (path.empty()) {
|
||||
char const *xdg_data = getenv("XDG_DATA_HOME");
|
||||
if (!xdg_data || xdg_data[0] == '\0') {
|
||||
if (!home_str) {
|
||||
path = path2;
|
||||
goto other;
|
||||
}
|
||||
user_data_dir = home_str;
|
||||
user_data_dir += "/.local/share";
|
||||
} else user_data_dir = xdg_data;
|
||||
user_data_dir += "/wesnoth/";
|
||||
user_data_dir += game_config::version.substr(0,3);
|
||||
create_directory_if_missing_recursive(user_data_dir);
|
||||
game_config::preferences_dir = user_data_dir;
|
||||
} else {
|
||||
other:
|
||||
std::string home = home_str ? home_str : ".";
|
||||
game_config::preferences_dir = home + "/" + path;
|
||||
}
|
||||
#else
|
||||
if (path.empty()) path = path2;
|
||||
|
||||
#ifdef __AMIGAOS4__
|
||||
game_config::preferences_dir = "PROGDIR:" + path;
|
||||
#elif defined(__BEOS__)
|
||||
|
@ -533,6 +558,7 @@ void set_preferences_dir(std::string path)
|
|||
std::string home = home_str ? home_str : ".";
|
||||
game_config::preferences_dir = home + std::string("/") + path;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /*_WIN32*/
|
||||
user_data_dir = game_config::preferences_dir;
|
||||
|
|
Loading…
Add table
Reference in a new issue