1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +00:00

Move dirs to luanti and linux and bsd to xdg

This commit is contained in:
wrrrzr 2025-04-27 17:06:23 +03:00
parent 01e4395977
commit 0899262585

View file

@ -449,8 +449,7 @@ bool setSystemPaths()
// Use "C:\Users\<user>\AppData\Roaming\<PROJECT_NAME_C>" // Use "C:\Users\<user>\AppData\Roaming\<PROJECT_NAME_C>"
len = GetEnvironmentVariable("APPDATA", buf, sizeof(buf)); len = GetEnvironmentVariable("APPDATA", buf, sizeof(buf));
FATAL_ERROR_IF(len == 0 || len > sizeof(buf), "Failed to get APPDATA"); FATAL_ERROR_IF(len == 0 || len > sizeof(buf), "Failed to get APPDATA");
// TODO: Luanti with migration path_user = std::string(buf) + DIR_DELIM PROJECT_NAME_C;
path_user = std::string(buf) + DIR_DELIM + "Minetest";
} else { } else {
path_user = std::string(buf); path_user = std::string(buf);
} }
@ -466,7 +465,7 @@ bool setSystemPaths()
extern bool setSystemPaths(); // defined in porting_android.cpp extern bool setSystemPaths(); // defined in porting_android.cpp
//// Linux //// XDG systems
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) #elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
bool setSystemPaths() bool setSystemPaths()
@ -515,9 +514,12 @@ bool setSystemPaths()
if (minetest_user_path && minetest_user_path[0] != '\0') { if (minetest_user_path && minetest_user_path[0] != '\0') {
path_user = std::string(minetest_user_path); path_user = std::string(minetest_user_path);
} else { } else {
// TODO: luanti with migration const char *const xdg_data = getenv("XDG_DATA_HOME");
path_user = std::string(getHomeOrFail()) + DIR_DELIM "." if (xdg_data) {
+ "minetest"; path_user = std::string(xdg_data);
} else {
path_user = std::string(getHomeOrFail()) + DIR_DELIM ".local" DIR_DELIM "share" DIR_DELIM PROJECT_NAME;
}
} }
return true; return true;
@ -544,10 +546,9 @@ bool setSystemPaths()
if (minetest_user_path && minetest_user_path[0] != '\0') { if (minetest_user_path && minetest_user_path[0] != '\0') {
path_user = std::string(minetest_user_path); path_user = std::string(minetest_user_path);
} else { } else {
// TODO: luanti with migration
path_user = std::string(getHomeOrFail()) path_user = std::string(getHomeOrFail())
+ "/Library/Application Support/" + "/Library/Application Support/"
+ "minetest"; PROJECT_NAME;
} }
return true; return true;
} }
@ -562,9 +563,7 @@ bool setSystemPaths()
if (minetest_user_path && minetest_user_path[0] != '\0') { if (minetest_user_path && minetest_user_path[0] != '\0') {
path_user = std::string(minetest_user_path); path_user = std::string(minetest_user_path);
} else { } else {
// TODO: luanti with migration path_user = std::string(getHomeOrFail()) + DIR_DELIM "." PROJECT_NAME;
path_user = std::string(getHomeOrFail()) + DIR_DELIM "."
+ "minetest";
} }
return true; return true;
} }
@ -670,13 +669,10 @@ void initializePaths()
const char *cache_dir = getenv("XDG_CACHE_HOME"); const char *cache_dir = getenv("XDG_CACHE_HOME");
const char *home_dir = getenv("HOME"); const char *home_dir = getenv("HOME");
if (cache_dir && cache_dir[0] != '\0') { if (cache_dir && cache_dir[0] != '\0') {
// TODO: luanti with migration path_cache = std::string(cache_dir) + DIR_DELIM PROJECT_NAME;
path_cache = std::string(cache_dir) + DIR_DELIM + "minetest";
} else if (home_dir) { } else if (home_dir) {
// Then try $HOME/.cache/PROJECT_NAME // Then try $HOME/.cache/PROJECT_NAME
// TODO: luanti with migration path_cache = std::string(home_dir) + DIR_DELIM ".cache" DIR_DELIM PROJECT_NAME;
path_cache = std::string(home_dir) + DIR_DELIM + ".cache"
+ DIR_DELIM + "minetest";
} else { } else {
// If neither works, use $PATH_USER/cache // If neither works, use $PATH_USER/cache
path_cache = path_user + DIR_DELIM + "cache"; path_cache = path_user + DIR_DELIM + "cache";