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:
Diffstat (limited to 'intern/ghost/intern/GHOST_SystemPathsUnix.cpp')
-rw-r--r--intern/ghost/intern/GHOST_SystemPathsUnix.cpp51
1 files changed, 24 insertions, 27 deletions
diff --git a/intern/ghost/intern/GHOST_SystemPathsUnix.cpp b/intern/ghost/intern/GHOST_SystemPathsUnix.cpp
index d2c678855f2..41babc5d312 100644
--- a/intern/ghost/intern/GHOST_SystemPathsUnix.cpp
+++ b/intern/ghost/intern/GHOST_SystemPathsUnix.cpp
@@ -17,8 +17,8 @@
#include <sys/time.h>
#include <unistd.h>
+#include <cstdio> /* for fprintf only */
#include <cstdlib> /* for exit */
-#include <stdio.h> /* for fprintf only */
#include <pwd.h> /* for get home without use getenv() */
#include <string>
@@ -28,7 +28,7 @@ using std::string;
#ifdef PREFIX
static const char *static_path = PREFIX "/share";
#else
-static const char *static_path = NULL;
+static const char *static_path = nullptr;
#endif
GHOST_SystemPathsUnix::GHOST_SystemPathsUnix()
@@ -39,7 +39,7 @@ GHOST_SystemPathsUnix::~GHOST_SystemPathsUnix()
{
}
-const char *GHOST_SystemPathsUnix::getSystemDir(int, const char *versionstr) const
+const char *GHOST_SystemPathsUnix::getSystemDir(int /*version*/, const char *versionstr) const
{
/* no prefix assumes a portable build which only uses bundled scripts */
if (static_path) {
@@ -47,7 +47,7 @@ const char *GHOST_SystemPathsUnix::getSystemDir(int, const char *versionstr) con
return system_path.c_str();
}
- return NULL;
+ return nullptr;
}
const char *GHOST_SystemPathsUnix::getUserDir(int version, const char *versionstr) const
@@ -67,32 +67,29 @@ const char *GHOST_SystemPathsUnix::getUserDir(int version, const char *versionst
user_path = string(home) + "/.blender/" + versionstr;
}
else {
- return NULL;
+ return nullptr;
}
}
return user_path.c_str();
}
- else {
- if (user_path.empty() || last_version != version) {
- const char *home = getenv("XDG_CONFIG_HOME");
-
- last_version = version;
+ if (user_path.empty() || last_version != version) {
+ const char *home = getenv("XDG_CONFIG_HOME");
- if (home) {
- user_path = string(home) + "/blender/" + versionstr;
- }
- else {
- home = getenv("HOME");
+ last_version = version;
- if (home == NULL)
- home = getpwuid(getuid())->pw_dir;
-
- user_path = string(home) + "/.config/blender/" + versionstr;
+ if (home) {
+ user_path = string(home) + "/blender/" + versionstr;
+ }
+ else {
+ home = getenv("HOME");
+ if (home == nullptr) {
+ home = getpwuid(getuid())->pw_dir;
}
+ user_path = string(home) + "/.config/blender/" + versionstr;
}
-
- return user_path.c_str();
}
+
+ return user_path.c_str();
}
const char *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDirTypes type) const
@@ -135,7 +132,7 @@ const char *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDirTypes
GHOST_ASSERT(
false,
"GHOST_SystemPathsUnix::getUserSpecialDir(): Invalid enum value for type parameter");
- return NULL;
+ return nullptr;
}
static string path = "";
@@ -143,8 +140,8 @@ const char *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDirTypes
string command = string("xdg-user-dir ") + type_str + " 2> /dev/null";
FILE *fstream = popen(command.c_str(), "r");
- if (fstream == NULL) {
- return NULL;
+ if (fstream == nullptr) {
+ return nullptr;
}
std::stringstream path_stream;
while (!feof(fstream)) {
@@ -157,7 +154,7 @@ const char *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDirTypes
}
if (pclose(fstream) == -1) {
perror("GHOST_SystemPathsUnix::getUserSpecialDir failed at pclose()");
- return NULL;
+ return nullptr;
}
if (!add_path.empty()) {
@@ -165,12 +162,12 @@ const char *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDirTypes
}
path = path_stream.str();
- return path[0] ? path.c_str() : NULL;
+ return path[0] ? path.c_str() : nullptr;
}
const char *GHOST_SystemPathsUnix::getBinaryDir() const
{
- return NULL;
+ return nullptr;
}
void GHOST_SystemPathsUnix::addToSystemRecentFiles(const char * /*filename*/) const