From: Niels K. B. J. <nk...@us...> - 2014-08-25 14:45:11
|
Update of /cvsroot/ufraw/ufraw In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23649 Modified Files: ufraw_conf.c Log Message: Add feature request #289: Support XDG basedir specification. Based on patch by Lev Babiev. Index: ufraw_conf.c =================================================================== RCS file: /cvsroot/ufraw/ufraw/ufraw_conf.c,v retrieving revision 1.196 retrieving revision 1.197 diff -u -d -r1.196 -r1.197 --- ufraw_conf.c 1 Jan 2014 06:00:23 -0000 1.196 +++ ufraw_conf.c 25 Aug 2014 14:45:09 -0000 1.197 @@ -766,7 +766,7 @@ int conf_load(conf_data *c, const char *IDFilename) { char *confFilename, line[max_path], *locale; - const char *hd; + const char *xdgconf; FILE *in; GMarkupParser parser = { &conf_parse_start, &conf_parse_end, @@ -782,10 +782,13 @@ else c->ufobject = ufraw_image_new(); if (IDFilename == NULL) { - hd = uf_get_home_dir(); - confFilename = g_build_filename(hd, ".ufrawrc", NULL); + confFilename = g_build_filename(uf_get_home_dir(), ".ufrawrc", NULL); + if (!g_file_test(confFilename, G_FILE_TEST_IS_REGULAR)) + if ((xdgconf = g_get_user_config_dir())) + confFilename = g_build_filename(xdgconf, "ufrawrc", NULL); + in = g_fopen(confFilename, "r"); - /* We don't mind if ~/.ufrawrc does not exist. */ + /* We don't mind if confFilename does not exist. */ if (in == NULL) { g_free(confFilename); return UFRAW_SUCCESS; @@ -1278,10 +1281,13 @@ uf_reset_locale(locale); if (confBuffer == NULL) { char *confFilename; + const char *xdgconf; FILE *out; if (IDFilename == NULL) { - const char *hd = uf_get_home_dir(); - confFilename = g_build_filename(hd, ".ufrawrc", NULL); + confFilename = g_build_filename(uf_get_home_dir(), ".ufrawrc", NULL); + if (!g_file_test(confFilename, G_FILE_TEST_IS_REGULAR)) + if ((xdgconf = g_get_user_config_dir())) + confFilename = g_build_filename(xdgconf, "ufrawrc", NULL); } else confFilename = g_strdup(IDFilename); if ((out = g_fopen(confFilename, "w")) == NULL) { |