Browse Source

Merge pull request #2685 from arkpar/dir-fix

Find home dir even when no environment available on linux
cl-refactor
Gav Wood 10 years ago
parent
commit
defa24e614
  1. 4
      libdevcore/FileSystem.cpp

4
libdevcore/FileSystem.cpp

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

Loading…
Cancel
Save