Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-11-03 02:00:22 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-03 02:00:22 +0400
commit4293f4738ce0ea1bb81260b12a6b64f98b6a3468 (patch)
tree6d4c1c3f363f4b77cb970a751794245fb688aa78 /intern/ghost
parentb07d92408b3ca76e00ea0e69203418fee49b5e19 (diff)
patch [#28947] Patches for #28943 (Support for XDG Base Directory Specification)
from Cosme
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/CMakeLists.txt4
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsX11.cpp25
2 files changed, 29 insertions, 0 deletions
diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
index 4446426098a..a84ff5825a9 100644
--- a/intern/ghost/CMakeLists.txt
+++ b/intern/ghost/CMakeLists.txt
@@ -108,6 +108,10 @@ if(WITH_INPUT_NDOF)
)
endif()
+if(WITH_XDG_USER_DIRS)
+ add_definitions(-DWITH_XDG_USER_DIRS)
+endif()
+
if(WITH_HEADLESS OR WITH_GHOST_SDL)
if(WITH_HEADLESS)
list(APPEND SRC
diff --git a/intern/ghost/intern/GHOST_SystemPathsX11.cpp b/intern/ghost/intern/GHOST_SystemPathsX11.cpp
index 1456bdef543..726149138ed 100644
--- a/intern/ghost/intern/GHOST_SystemPathsX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemPathsX11.cpp
@@ -41,6 +41,11 @@
#include <stdio.h> // for fprintf only
#include <cstdlib> // for exit
+#ifdef WITH_XDG_USER_DIRS
+# include <pwd.h> // for get home without use getenv()
+# include <limits.h> // for PATH_MAX
+#endif
+
#ifdef PREFIX
static const char *static_path= PREFIX "/share" ;
#else
@@ -63,7 +68,27 @@ const GHOST_TUns8* GHOST_SystemPathsX11::getSystemDir() const
const GHOST_TUns8* GHOST_SystemPathsX11::getUserDir() const
{
+#ifndef WITH_XDG_USER_DIRS
return (const GHOST_TUns8 *)getenv("HOME");
+#else /* WITH_XDG_USER_DIRS */
+ const char *home= getenv("XDG_CONFIG_HOME");
+
+ if (home) {
+ return (const GHOST_TUns8 *)home;
+ }
+ else {
+ static char user_path[PATH_MAX];
+
+ home= getenv("HOME");
+
+ if (home == NULL) {
+ home= getpwuid(getuid())->pw_dir;
+ }
+
+ snprintf(user_path, sizeof(user_path), "%s/.config", home);
+ return (const GHOST_TUns8 *)user_path;
+ }
+#endif /* WITH_XDG_USER_DIRS */
}
const GHOST_TUns8* GHOST_SystemPathsX11::getBinaryDir() const