mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Use XDG basedir spec for model-cache-dir (now $XDG_CACHE_HOME/panda3d which is usually $HOME/.cache/panda3d)
User appdata directory on posix is now $XDG_DATA_HOME (usually $HOME/.local/share). Common appdata dir is /usr/share (or /usr/local/share on FreeBSD)
This commit is contained in:
parent
69eab74b77
commit
2b537d2263
@ -341,6 +341,22 @@ ns_get_environment_variable(const string &var) const {
|
||||
}
|
||||
}
|
||||
|
||||
#elif !defined(__APPLE__)
|
||||
// Similarly, we define fallbacks on POSIX systems for the variables defined
|
||||
// in the XDG Base Directory specification, so that they can be safely used
|
||||
// in Config.prc files.
|
||||
if (var == "XDG_CONFIG_HOME") {
|
||||
Filename home_dir = Filename::get_home_directory();
|
||||
return home_dir.get_fullpath() + "/.config";
|
||||
|
||||
} else if (var == "XDG_CACHE_HOME") {
|
||||
Filename home_dir = Filename::get_home_directory();
|
||||
return home_dir.get_fullpath() + "/.cache";
|
||||
|
||||
} else if (var == "XDG_DATA_HOME") {
|
||||
Filename home_dir = Filename::get_home_directory();
|
||||
return home_dir.get_fullpath() + "/.local/share";
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
return string();
|
||||
|
@ -600,8 +600,14 @@ get_user_appdata_directory() {
|
||||
user_appdata_directory.set_basename("files");
|
||||
|
||||
#else
|
||||
// Posix case.
|
||||
user_appdata_directory = get_home_directory();
|
||||
// Posix case. We follow the XDG base directory spec.
|
||||
struct stat st;
|
||||
const char *datadir = getenv("XDG_DATA_HOME");
|
||||
if (datadir != nullptr && stat(datadir, &st) == 0 && S_ISDIR(st.st_mode)) {
|
||||
user_appdata_directory = datadir;
|
||||
} else {
|
||||
user_appdata_directory = Filename(get_home_directory(), ".local/share");
|
||||
}
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
@ -649,9 +655,10 @@ get_common_appdata_directory() {
|
||||
common_appdata_directory.set_dirname(_internal_data_dir);
|
||||
common_appdata_directory.set_basename("files");
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
common_appdata_directory = "/usr/local/share";
|
||||
#else
|
||||
// Posix case.
|
||||
common_appdata_directory = "/var";
|
||||
common_appdata_directory = "/usr/share";
|
||||
#endif // WIN32
|
||||
|
||||
if (common_appdata_directory.empty()) {
|
||||
|
@ -89,7 +89,7 @@ hardware-animated-vertices #f
|
||||
|
||||
# Enable the model-cache, but only for models, not textures.
|
||||
|
||||
model-cache-dir $HOME/.panda3d/cache
|
||||
model-cache-dir $XDG_CACHE_HOME/panda3d
|
||||
model-cache-textures #f
|
||||
|
||||
# This option specifies the default profiles for Cg shaders.
|
||||
|
@ -2797,12 +2797,12 @@ else:
|
||||
configprc = ReadFile("makepanda/config.in")
|
||||
|
||||
if (GetTarget() == 'windows'):
|
||||
configprc = configprc.replace("$HOME/.panda3d", "$USER_APPDATA/Panda3D-%s" % MAJOR_VERSION)
|
||||
configprc = configprc.replace("$XDG_CACHE_HOME/panda3d", "$USER_APPDATA/Panda3D-%s" % MAJOR_VERSION)
|
||||
else:
|
||||
configprc = configprc.replace("aux-display pandadx9", "")
|
||||
|
||||
if (GetTarget() == 'darwin'):
|
||||
configprc = configprc.replace(".panda3d/cache", "Library/Caches/Panda3D-%s" % MAJOR_VERSION)
|
||||
configprc = configprc.replace("$XDG_CACHE_HOME/panda3d", "Library/Caches/Panda3D-%s" % MAJOR_VERSION)
|
||||
|
||||
# OpenAL is not yet working well on OSX for us, so let's do this for now.
|
||||
configprc = configprc.replace("p3openal_audio", "p3fmod_audio")
|
||||
|
Loading…
x
Reference in New Issue
Block a user