Browse Source

Fixes for filesystem commit.

cl-refactor
Gav Wood 11 years ago
parent
commit
2b849b61a1
  1. 25
      libethereum/FileSystem.cpp
  2. 10
      libethereum/FileSystem.h

25
libethereum/FileSystem.cpp

@ -15,39 +15,42 @@
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file FileSystem.cpp
* @author Eric Lombrozo <elombrozo@gmail.com>
* @authors
* Eric Lombrozo <elombrozo@gmail.com>
* Gav Wood <i@gavwood.com>
* @date 2014
*/
#include "FileSystem.h"
#include <boost/filesystem.hpp>
#ifdef _WIN32
#include <shlobj.h>
#endif
#include <boost/filesystem.hpp>
#include "FileSystem.h"
using namespace std;
using namespace eth;
std::string getDataDir()
std::string eth::getDataDir()
{
#ifdef _WIN32
char path[1024] = "";
if (SHGetSpecialFolderPathA(NULL, path, CSIDL_APPDATA, true))
return (boost::filesystem::path(path) / "Ethereum").string();
else
{
std::cerr << "getDataDir() - SHGetSpecialFolderPathA() failed." << std::endl;
{
cwarn << "getDataDir(): SHGetSpecialFolderPathA() failed.";
throw std::runtime_error("getDataDir() - SHGetSpecialFolderPathA() failed.");
}
#else
boost::filesystem::path dataDirPath;
char* homeDir = getenv("HOME");
if (homeDir == NULL || strlen(homeDir) == 0)
char const* homeDir = getenv("HOME");
if (!homeDir || strlen(homeDir) == 0)
dataDirPath = boost::filesystem::path("/");
else
dataDirPath = boost::filesystem::path(homeDir);
#if defined(__APPLE__) && defined(__MACH__)
dataDirPath /= "Library/Application Support";
dataDirPath /= "Library" / "Application Support";
boost::filesystem::create_directory(dataDirPath);
return (dataDirPath / "Ethereum").string();
return (dataDirPath / "Ethereum").string();
#else
return (dataDirPath / ".ethereum").string();
#endif

10
libethereum/FileSystem.h

@ -15,7 +15,9 @@
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file FileSystem.h
* @author Eric Lombrozo <elombrozo@gmail.com>
* @authors
* Eric Lombrozo <elombrozo@gmail.com>
* Gav Wood <i@gavwood.com>
* @date 2014
*/
@ -23,4 +25,10 @@
#include <string>
namespace eth
{
/// @returns the path for user data.
std::string getDataDir();
}

Loading…
Cancel
Save