|
@ -25,8 +25,13 @@ |
|
|
#include <libdevcore/Common.h> |
|
|
#include <libdevcore/Common.h> |
|
|
#include <libdevcore/Log.h> |
|
|
#include <libdevcore/Log.h> |
|
|
|
|
|
|
|
|
#ifdef _WIN32 |
|
|
#if defined(_WIN32) |
|
|
#include <shlobj.h> |
|
|
#include <shlobj.h> |
|
|
|
|
|
#elif defined(__APPLE__) |
|
|
|
|
|
#include <stdlib.h> |
|
|
|
|
|
#include <stdio.h> |
|
|
|
|
|
#include <pwd.h> |
|
|
|
|
|
#include <unistd.h> |
|
|
#endif |
|
|
#endif |
|
|
#include <boost/filesystem.hpp> |
|
|
#include <boost/filesystem.hpp> |
|
|
using namespace std; |
|
|
using namespace std; |
|
@ -51,6 +56,15 @@ 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) |
|
|
|
|
|
{ |
|
|
|
|
|
struct passwd* pwd = getpwuid(getuid()); |
|
|
|
|
|
if (pwd) |
|
|
|
|
|
homeDir = pwd->pw_dir; |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
if (!homeDir || strlen(homeDir) == 0) |
|
|
if (!homeDir || strlen(homeDir) == 0) |
|
|
dataDirPath = boost::filesystem::path("/"); |
|
|
dataDirPath = boost::filesystem::path("/"); |
|
|
else |
|
|
else |
|
|