mirror of https://github.com/AxioDL/metaforce.git
Merge pull request #34 from linkmauve/xdg-basedir
Respect the XDG base directory specification
This commit is contained in:
commit
7abe527032
|
@ -36,11 +36,20 @@ FileStoreManager::FileStoreManager(SystemStringView domain) : m_domain(domain) {
|
||||||
hecl::MakeDir(path.c_str());
|
hecl::MakeDir(path.c_str());
|
||||||
m_storeRoot = path;
|
m_storeRoot = path;
|
||||||
#else
|
#else
|
||||||
const char* home = getenv("HOME");
|
const char* xdg_data_home = getenv("XDG_DATA_HOME");
|
||||||
if (!home)
|
std::string path;
|
||||||
Log.report(logvisor::Fatal, fmt("unable to locate $HOME for file store"));
|
if (xdg_data_home) {
|
||||||
std::string path(home);
|
if (xdg_data_home[0] != '/')
|
||||||
path += "/.heclrun";
|
Log.report(logvisor::Fatal, fmt("invalid $XDG_DATA_HOME for file store (must be absolute)"));
|
||||||
|
path = xdg_data_home;
|
||||||
|
} else {
|
||||||
|
const char* home = getenv("HOME");
|
||||||
|
if (!home)
|
||||||
|
Log.report(logvisor::Fatal, fmt("unable to locate $HOME for file store"));
|
||||||
|
path = home;
|
||||||
|
path += "/.local/share"
|
||||||
|
}
|
||||||
|
path += "/hecl";
|
||||||
if (mkdir(path.c_str(), 0755) && errno != EEXIST)
|
if (mkdir(path.c_str(), 0755) && errno != EEXIST)
|
||||||
Log.report(logvisor::Fatal, fmt("unable to mkdir at {}"), path);
|
Log.report(logvisor::Fatal, fmt("unable to mkdir at {}"), path);
|
||||||
path += '/';
|
path += '/';
|
||||||
|
|
Loading…
Reference in New Issue