Config dirs is now XDG compliant.

pull/40/head
LemonBoy 2012-06-10 20:15:40 +02:00
parent 6157dc57f3
commit 9a76cb8839
1 changed files with 23 additions and 3 deletions

View File

@ -27,10 +27,30 @@ namespace gr {
const std::string& Config::Filename()
{
static const char *env_cfg = ::getenv( "GR_CONFIG" ) ;
static const std::string filename = (env_cfg != 0) ? env_cfg : ".grive" ;
static std::string cfg_path;
char *cfg_base;
bool fallback;
fallback = false;
cfg_base = getenv("XDG_CONFIG_HOME");
if (!cfg_base)
{
fallback = true;
cfg_base = getenv("HOME");
/* Clutter the current directory if forced to */
if (!cfg_base)
cfg_base = (char *)".";
}
return filename ;
cfg_path = cfg_base;
cfg_path += "/";
if (fallback) /* Hidden folder */
cfg_path += ".";
cfg_path += "grive";
cfg_path += "/";
cfg_path += "config.json";
return cfg_path ;
}
Config::Config() :