Browse Source

get home dir even when no env available on linux

cl-refactor
arkpar 10 years ago
parent
commit
35d4c15ebe
  1. 4
      libdevcore/FileSystem.cpp

4
libdevcore/FileSystem.cpp

@ -27,7 +27,7 @@
#if defined(_WIN32) #if defined(_WIN32)
#include <shlobj.h> #include <shlobj.h>
#elif defined(__APPLE__) #else
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <pwd.h> #include <pwd.h>
@ -56,14 +56,12 @@ std::string dev::getDataDir(std::string _prefix)
#else #else
boost::filesystem::path dataDirPath; boost::filesystem::path dataDirPath;
char const* homeDir = getenv("HOME"); char const* homeDir = getenv("HOME");
#if defined(__APPLE__)
if (!homeDir || strlen(homeDir) == 0) if (!homeDir || strlen(homeDir) == 0)
{ {
struct passwd* pwd = getpwuid(getuid()); struct passwd* pwd = getpwuid(getuid());
if (pwd) if (pwd)
homeDir = pwd->pw_dir; homeDir = pwd->pw_dir;
} }
#endif
if (!homeDir || strlen(homeDir) == 0) if (!homeDir || strlen(homeDir) == 0)
dataDirPath = boost::filesystem::path("/"); dataDirPath = boost::filesystem::path("/");

Loading…
Cancel
Save