2015-11-13 02:12:09 +00:00
|
|
|
#include "HECL/Runtime.hpp"
|
|
|
|
#include <LogVisor/LogVisor.hpp>
|
2015-11-14 08:48:31 +00:00
|
|
|
#if _WIN32
|
|
|
|
#include <ShlObj.h>
|
|
|
|
#endif
|
2015-11-13 02:12:09 +00:00
|
|
|
|
|
|
|
namespace HECL
|
|
|
|
{
|
|
|
|
namespace Runtime
|
|
|
|
{
|
|
|
|
static LogVisor::LogModule Log("FileStoreManager");
|
|
|
|
|
|
|
|
FileStoreManager::FileStoreManager(const SystemString& domain)
|
|
|
|
: m_domain(domain)
|
|
|
|
{
|
|
|
|
#if _WIN32
|
2015-11-14 08:48:31 +00:00
|
|
|
WCHAR home[MAX_PATH];
|
|
|
|
if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PROFILE, NULL, 0, home)))
|
|
|
|
Log.report(LogVisor::FatalError, _S("unable to locate profile for file store"));
|
|
|
|
|
|
|
|
SystemString path(home);
|
|
|
|
|
|
|
|
path += _S("/.heclrun");
|
|
|
|
|
|
|
|
HECL::MakeDir(path.c_str());
|
|
|
|
path += _S('/') + domain;
|
|
|
|
|
|
|
|
HECL::MakeDir(path.c_str());
|
|
|
|
m_storeRoot = path;
|
2015-11-13 02:12:09 +00:00
|
|
|
#else
|
|
|
|
const char* home = getenv("HOME");
|
|
|
|
if (!home)
|
|
|
|
Log.report(LogVisor::FatalError, "unable to locate $HOME for file store");
|
|
|
|
std::string path(home);
|
|
|
|
path += "/.heclrun";
|
2015-11-16 04:30:06 +00:00
|
|
|
if (mkdir(path.c_str(), 0755) && errno != EEXIST)
|
2015-11-13 02:12:09 +00:00
|
|
|
Log.report(LogVisor::FatalError, "unable to mkdir at %s", path.c_str());
|
|
|
|
path += '/' + domain;
|
2015-11-16 04:30:06 +00:00
|
|
|
if (mkdir(path.c_str(), 0755) && errno != EEXIST)
|
2015-11-13 02:12:09 +00:00
|
|
|
Log.report(LogVisor::FatalError, "unable to mkdir at %s", path.c_str());
|
|
|
|
m_storeRoot = path;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|