Ephoto: Better checking for XDG_CONFIG_HOME.

This commit is contained in:
Stephen okra Houston 2016-08-29 14:08:02 -05:00
parent 2cdb2a5138
commit b05d3b1dba
1 changed files with 10 additions and 6 deletions

View File

@ -623,9 +623,11 @@ _ephoto_config_load(Ephoto *ephoto)
Eet_File *ef; Eet_File *ef;
char buf[4096], buf2[4096], xdg[4096]; char buf[4096], buf2[4096], xdg[4096];
snprintf(xdg, PATH_MAX, "%s", getenv("XDG_CONFIG_HOME")); if (getenv("XDG_CONFIG_HOME"))
if (strlen(xdg)) {
snprintf(buf2, sizeof(buf2), "%s/ephoto", xdg); snprintf(xdg, PATH_MAX, "%s", getenv("XDG_CONFIG_HOME"));
snprintf(buf2, sizeof(buf2), "%s/ephoto", xdg);
}
else else
snprintf(buf2, sizeof(buf2), "%s/.config/ephoto", getenv("HOME")); snprintf(buf2, sizeof(buf2), "%s/.config/ephoto", getenv("HOME"));
ecore_file_mkpath(buf2); ecore_file_mkpath(buf2);
@ -666,9 +668,11 @@ _ephoto_on_config_save(void *data)
Eet_File *ef; Eet_File *ef;
char buf[4096], buf2[4096], xdg[4096]; char buf[4096], buf2[4096], xdg[4096];
snprintf(xdg, PATH_MAX, "%s", getenv("XDG_CONFIG_HOME")); if (getenv("XDG_CONFIG_HOME"))
if (strlen(xdg)) {
snprintf(buf, sizeof(buf), "%s/ephoto/ephoto.cfg", xdg); snprintf(xdg, PATH_MAX, "%s", getenv("XDG_CONFIG_HOME"));
snprintf(buf, sizeof(buf), "%s/ephoto/ephoto.cfg", xdg);
}
else else
snprintf(buf, sizeof(buf), "%s/.config/ephoto/ephoto.cfg", getenv("HOME")); snprintf(buf, sizeof(buf), "%s/.config/ephoto/ephoto.cfg", getenv("HOME"));
snprintf(buf2, sizeof(buf2), "%s.tmp", buf); snprintf(buf2, sizeof(buf2), "%s.tmp", buf);