38 static string system_path = string(
static_path) +
"/blender/" + versionstr;
39 return system_path.c_str();
50 const char *home_dir = getenv(
"HOME");
51 if (home_dir ==
nullptr) {
52 if (
const passwd *pwuser = getpwuid(getuid())) {
53 home_dir = pwuser->pw_dir;
61 static string user_path;
62 static int last_version = 0;
67 if (user_path.empty() || last_version != version) {
70 last_version = version;
73 user_path = string(home) +
"/.blender/" + versionstr;
79 return user_path.c_str();
81 if (user_path.empty() || last_version != version) {
82 const char *home = getenv(
"XDG_CONFIG_HOME");
84 last_version = version;
87 user_path = string(home) +
"/blender/" + versionstr;
92 user_path = string(home) +
"/.config/blender/" + versionstr;
100 return user_path.c_str();
105 const char *type_str;
110 type_str =
"DESKTOP";
113 type_str =
"DOCUMENTS";
116 type_str =
"DOWNLOAD";
122 type_str =
"PICTURES";
128 const char *cache_dir = getenv(
"XDG_CACHE_HOME");
135 if (home_dir ==
nullptr) {
138 path = string(home_dir) +
"/.cache";
144 "GHOST_SystemPathsUnix::getUserSpecialDir(): Invalid enum value for type parameter");
149 string command = string(
"xdg-user-dir ") + type_str +
" 2> /dev/null";
151 FILE *fstream = popen(command.c_str(),
"r");
152 if (fstream ==
nullptr) {
155 std::stringstream path_stream;
156 while (!feof(fstream)) {
157 char c = fgetc(fstream);
164 if (pclose(fstream) == -1) {
165 perror(
"GHOST_SystemPathsUnix::getUserSpecialDir failed at pclose()");
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 override
const char * getUserDir(int version, const char *versionstr) const override
~GHOST_SystemPathsUnix() override
const char * getUserSpecialDir(GHOST_TUserSpecialDirTypes type) const override
void addToSystemRecentFiles(const char *filepath) const override
const char * getSystemDir(int version, const char *versionstr) const override