check if tmp is null
This commit is contained in:
parent
347badf770
commit
df1ba83a53
1 changed files with 1 additions and 1 deletions
|
@ -119,7 +119,7 @@ inline std::string getHomeDir() {
|
||||||
inline std::string getTmpDir() {
|
inline std::string getTmpDir() {
|
||||||
// first, check if an env variable is set
|
// first, check if an env variable is set
|
||||||
const char* tmpdir = getenv("TMPDIR");
|
const char* tmpdir = getenv("TMPDIR");
|
||||||
if (std::strlen(tmpdir)) return std::string(tmpdir);
|
if (tmpdir && std::strlen(tmpdir)) return std::string(tmpdir);
|
||||||
|
|
||||||
// second, check if /tmp is writable
|
// second, check if /tmp is writable
|
||||||
if (access("/tmp/", W_OK) == 0) return "/tmp";
|
if (access("/tmp/", W_OK) == 0) return "/tmp";
|
||||||
|
|
Loading…
Reference in a new issue