libsaria: Check if $HOME is part of $XDG_CONFIG_HOME

On one machine it is, on another it isn't.  This should be a solution
that works for everybody.
This commit is contained in:
Bryan Schumaker 2011-12-11 20:26:39 -05:00
parent 83867dba2c
commit 304b581274
1 changed files with 7 additions and 5 deletions

View File

@ -61,13 +61,15 @@ void readdir(string dir, list<file> &files, list<file> &dirs)
string get_saria_dir()
{
string saria = getenv("HOME");
char *xdg = getenv("XDG_CONFIG_HOME");
string xdg = getenv("XDG_CONFIG_HOME");
saria += "/";
if (xdg != NULL)
saria += xdg;
if (xdg == "")
saria += "/.config";
else if (xdg.compare(0, saria.size(), saria) == 0)
saria = xdg + "/";
else
saria += ".config";
saria += "/" + xdg += "/";
return saria += SARIA_DIR;
}