38 static string system_path = string(
static_path) +
"/blender/" + versionstr;
39 return system_path.c_str();
47 const char *home_dir = getenv(
"HOME");
48 if (home_dir ==
nullptr) {
49 if (
const passwd *pwuser = getpwuid(getuid())) {
50 home_dir = pwuser->pw_dir;
58 static string user_path =
"";
59 static int last_version = 0;
64 if (user_path.empty() || last_version != version) {
67 last_version = version;
70 user_path = string(home) +
"/.blender/" + versionstr;
76 return user_path.c_str();
78 if (user_path.empty() || last_version != version) {
79 const char *home = getenv(
"XDG_CONFIG_HOME");
81 last_version = version;
84 user_path = string(home) +
"/blender/" + versionstr;
89 user_path = string(home) +
"/.config/blender/" + versionstr;
97 return user_path.c_str();
102 const char *type_str;
103 std::string add_path =
"";
107 type_str =
"DESKTOP";
110 type_str =
"DOCUMENTS";
113 type_str =
"DOWNLOAD";
119 type_str =
"PICTURES";
125 const char *cache_dir = getenv(
"XDG_CACHE_HOME");
139 "GHOST_SystemPathsUnix::getUserSpecialDir(): Invalid enum value for type parameter");
143 static string path =
"";
145 string command = string(
"xdg-user-dir ") + type_str +
" 2> /dev/null";
147 FILE *fstream = popen(command.c_str(),
"r");
148 if (fstream ==
nullptr) {
151 std::stringstream path_stream;
152 while (!feof(fstream)) {
153 char c = fgetc(fstream);
160 if (pclose(fstream) == -1) {
161 perror(
"GHOST_SystemPathsUnix::getUserSpecialDir failed at pclose()");
165 if (!add_path.empty()) {
166 path_stream <<
'/' << add_path;
169 path = path_stream.str();
170 return path[0] ? path.c_str() :
nullptr;
#define GHOST_ASSERT(x, info)
static const char * static_path
static const char * home_dir_get()
GHOST_TUserSpecialDirTypes
@ GHOST_kUserSpecialDirDesktop
@ GHOST_kUserSpecialDirMusic
@ GHOST_kUserSpecialDirPictures
@ GHOST_kUserSpecialDirVideos
@ GHOST_kUserSpecialDirDownloads
@ GHOST_kUserSpecialDirCaches
@ GHOST_kUserSpecialDirDocuments
const char * getBinaryDir() const
void addToSystemRecentFiles(const char *filepath) const
const char * getUserSpecialDir(GHOST_TUserSpecialDirTypes type) const
const char * getSystemDir(int version, const char *versionstr) const
const char * getUserDir(int version, const char *versionstr) const