38
38
#include <sys/time.h>
39
39
#include <unistd.h>
41
#include <stdio.h> // for fprintf only
42
#include <cstdlib> // for exit
41
#include <stdio.h> /* for fprintf only */
42
#include <cstdlib> /* for exit */
44
#ifdef WITH_XDG_USER_DIRS
45
# include <pwd.h> // for get home without use getenv()
46
# include <limits.h> // for PATH_MAX
44
#include <pwd.h> /* for get home without use getenv() */
45
#include <limits.h> /* for PATH_MAX */
50
static const char *static_path= PREFIX "/lib";
48
static const char *static_path = PREFIX "/share";
52
static const char *static_path= NULL;
50
static const char *static_path = NULL;
55
53
GHOST_SystemPathsX11::GHOST_SystemPathsX11()
63
const GHOST_TUns8* GHOST_SystemPathsX11::getSystemDir() const
61
const GHOST_TUns8 *GHOST_SystemPathsX11::getSystemDir(int, const char *versionstr) const
65
63
/* no prefix assumes a portable build which only uses bundled scripts */
66
return (const GHOST_TUns8 *)static_path;
65
static char system_path[PATH_MAX];
66
snprintf(system_path, sizeof(system_path), "%s/blender/%s", static_path, versionstr);
67
return (GHOST_TUns8 *)system_path;
69
const GHOST_TUns8* GHOST_SystemPathsX11::getUserDir() const
73
const GHOST_TUns8 *GHOST_SystemPathsX11::getUserDir(int version, const char *versionstr) const
71
#ifndef WITH_XDG_USER_DIRS
72
return (const GHOST_TUns8 *)getenv("HOME");
73
#else /* WITH_XDG_USER_DIRS */
74
const char *home= getenv("XDG_CONFIG_HOME");
77
return (const GHOST_TUns8 *)home;
75
static char user_path[PATH_MAX];
77
/* in blender 2.64, we migrate to XDG. to ensure the copy previous settings
78
* operator works we give a different path depending on the requested version */
80
const char *home = getenv("HOME");
83
snprintf(user_path, sizeof(user_path), "%s/.blender/%s", home, versionstr);
84
return (GHOST_TUns8 *)user_path;
80
static char user_path[PATH_MAX];
85
home= getpwuid(getuid())->pw_dir;
88
snprintf(user_path, sizeof(user_path), "%s/.config", home);
90
const char *home = getenv("XDG_CONFIG_HOME");
93
snprintf(user_path, sizeof(user_path), "%s/blender/%s", home, versionstr);
96
home = getenv("HOME");
99
home = getpwuid(getuid())->pw_dir;
101
snprintf(user_path, sizeof(user_path), "%s/.config/blender/%s", home, versionstr);
89
104
return (const GHOST_TUns8 *)user_path;
91
#endif /* WITH_XDG_USER_DIRS */
94
const GHOST_TUns8* GHOST_SystemPathsX11::getBinaryDir() const
108
const GHOST_TUns8 *GHOST_SystemPathsX11::getBinaryDir() const
99
void GHOST_SystemPathsX11::addToSystemRecentFiles(const char* filename) const
113
void GHOST_SystemPathsX11::addToSystemRecentFiles(const char *filename) const
101
115
/* XXXXX TODO: Implementation for X11 if possible */