36 #include <boost/filesystem.hpp> 40 static_assert(BOOST_VERSION == 106300,
"Wrong boost headers version");
43 static string s_ethereumDatadir;
44 static string s_ethereumIpcPath;
48 s_ethereumDatadir = _dataDir;
53 s_ethereumIpcPath = _ipcDir;
58 if (s_ethereumIpcPath.empty())
62 size_t socketPos = s_ethereumIpcPath.rfind(
"geth.ipc");
63 if (socketPos != string::npos)
64 return s_ethereumIpcPath.substr(0, socketPos);
65 return s_ethereumIpcPath;
73 if (_prefix ==
"ethereum" && !s_ethereumDatadir.empty())
74 return s_ethereumDatadir;
84 _prefix[0] = toupper(_prefix[0]);
86 if (SHGetSpecialFolderPathA(NULL, path, CSIDL_APPDATA,
true))
87 return (boost::filesystem::path(path) / _prefix).string();
90 #ifndef _MSC_VER // todo? 91 cwarn <<
"getDataDir(): SHGetSpecialFolderPathA() failed.";
93 BOOST_THROW_EXCEPTION(std::runtime_error(
"getDataDir() - SHGetSpecialFolderPathA() failed."));
96 boost::filesystem::path dataDirPath;
97 char const* homeDir = getenv(
"HOME");
98 if (!homeDir || strlen(homeDir) == 0)
100 struct passwd* pwd = getpwuid(getuid());
102 homeDir = pwd->pw_dir;
105 if (!homeDir || strlen(homeDir) == 0)
106 dataDirPath = boost::filesystem::path(
"/");
108 dataDirPath = boost::filesystem::path(homeDir);
110 return (dataDirPath / (
"." + _prefix)).string();
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
std::string getDefaultDataDir(std::string _prefix="ethereum")
std::hash for asio::adress
std::string getDataDir(std::string _prefix="ethereum")
void setIpcPath(std::string const &_ipcPath)
Sets the ipc socket dir.
void setDataDir(std::string const &_dir)
Sets the data dir for the default ("ethereum") prefix.