36 #include <boost/filesystem.hpp>
40 namespace fs = boost::filesystem;
42 static_assert(BOOST_VERSION >= 106400,
"Wrong boost headers version");
45 static fs::path s_ethereumDatadir;
46 static fs::path s_ethereumIpcPath;
50 s_ethereumDatadir = _dataDir;
55 s_ethereumIpcPath = _ipcDir;
61 if (s_ethereumIpcPath.filename() ==
"geth.ipc")
62 return s_ethereumIpcPath.parent_path();
64 return s_ethereumIpcPath;
71 if (_prefix ==
"ethereum" && !s_ethereumDatadir.empty())
72 return s_ethereumDatadir;
82 _prefix[0] = toupper(_prefix[0]);
84 if (SHGetSpecialFolderPathA(NULL, path, CSIDL_APPDATA,
true))
85 return fs::path(path) / _prefix;
88 #ifndef _MSC_VER // todo?
89 cwarn <<
"getDataDir(): SHGetSpecialFolderPathA() failed.";
91 BOOST_THROW_EXCEPTION(std::runtime_error(
"getDataDir() - SHGetSpecialFolderPathA() failed."));
95 char const* homeDir = getenv(
"HOME");
96 if (!homeDir || strlen(homeDir) == 0)
98 struct passwd* pwd = getpwuid(getuid());
100 homeDir = pwd->pw_dir;
103 if (!homeDir || strlen(homeDir) == 0)
104 dataDirPath = fs::path(
"/");
106 dataDirPath = fs::path(homeDir);
108 return dataDirPath / (
"." + _prefix);
114 if (_orig.filename() == fs::path(
".") || _orig.filename() == fs::path(
".."))
115 return _orig / fs::path(_suffix);
117 return _orig.parent_path() / fs::path( _orig.filename().string() + _suffix);