summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-11-20 00:42:51 +0100
committerGitHub <noreply@github.com>2017-11-20 00:42:51 +0100
commitecf80fbbbadaa782cbe81a6562916331c6762970 (patch)
tree7a949f6a95f36303a2f2d193aeabd6486e13f4a1 /platform/x11
parentbc26a5bd3a51b11bab63112275e7045c63a0ffc4 (diff)
parent6e3f2f44af808e9f4255c2462e16beee844c0df7 (diff)
Merge pull request #12988 from akien-mga/xdg-home-paths
Add support for XDG Base Directory spec
Diffstat (limited to 'platform/x11')
-rw-r--r--platform/x11/os_x11.cpp35
-rw-r--r--platform/x11/os_x11.h4
2 files changed, 38 insertions, 1 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index f018145d82..c1d744215d 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -464,7 +464,7 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
#ifdef JOYDEV_ENABLED
joypad = memnew(JoypadLinux(input));
#endif
- _ensure_data_dir();
+ _ensure_user_data_dir();
power_manager = memnew(PowerX11);
}
@@ -1941,6 +1941,39 @@ bool OS_X11::_check_internal_feature_support(const String &p_feature) {
return p_feature == "pc" || p_feature == "s3tc";
}
+String OS_X11::get_config_path() const {
+
+ if (has_environment("XDG_CONFIG_HOME")) {
+ return get_environment("XDG_CONFIG_HOME");
+ } else if (has_environment("HOME")) {
+ return get_environment("HOME").plus_file(".config");
+ } else {
+ return ".";
+ }
+}
+
+String OS_X11::get_data_path() const {
+
+ if (has_environment("XDG_DATA_HOME")) {
+ return get_environment("XDG_DATA_HOME");
+ } else if (has_environment("HOME")) {
+ return get_environment("HOME").plus_file(".local/share");
+ } else {
+ return get_config_path();
+ }
+}
+
+String OS_X11::get_cache_path() const {
+
+ if (has_environment("XDG_CACHE_HOME")) {
+ return get_environment("XDG_CACHE_HOME");
+ } else if (has_environment("HOME")) {
+ return get_environment("HOME").plus_file(".cache");
+ } else {
+ return get_config_path();
+ }
+}
+
String OS_X11::get_system_dir(SystemDir p_dir) const {
String xdgparam;
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index 0ea5bbfdb6..67f3807d99 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -213,6 +213,10 @@ public:
virtual void make_rendering_thread();
virtual void swap_buffers();
+ virtual String get_config_path() const;
+ virtual String get_data_path() const;
+ virtual String get_cache_path() const;
+
virtual String get_system_dir(SystemDir p_dir) const;
virtual Error shell_open(String p_uri);