diff options
author | portix <portix@gmx.net> | 2012-02-20 11:19:01 +0100 |
---|---|---|
committer | portix <portix@gmx.net> | 2012-02-20 11:19:01 +0100 |
commit | 940f99ed4894ddc9d938fd5d70b871695b888995 (patch) | |
tree | 2d4a55cb785b9e33218a3da8dc7fa3f18a1cfffd /src/util.c | |
parent | b248323b4b718ec6922fe0d2a004f91b73967b43 (diff) | |
download | dwb-940f99ed4894ddc9d938fd5d70b871695b888995.zip |
Fixing ignoring local files.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -439,24 +439,29 @@ util_get_user_data_dir(const char *dir) { /* util_get_data_file(const char *filename) return: filename (alloc) or NULL {{{*/ char * util_get_data_file(const char *filename) { + if (filename == NULL) + return NULL; char *path = NULL; char *ret = NULL; + char *basename = g_path_get_basename(filename); path = util_get_user_data_dir("lib"); if (path != NULL) { - ret = g_build_filename(path, filename, NULL); - g_free(path); + ret = g_build_filename(path, basename, NULL); if (g_file_test(ret, G_FILE_TEST_EXISTS)) - return ret; + goto clean; } path = util_get_system_data_dir("lib"); if (path != NULL) { - ret = g_build_filename(path, filename, NULL); - g_free(path); + ret = g_build_filename(path, basename, NULL); if (g_file_test(ret, G_FILE_TEST_EXISTS)) - return ret; + goto clean; } - return NULL; + ret = g_strdup(filename); +clean: + g_free(path); + g_free(basename); + return ret; }/*}}}*/ /* util_file_remove_line const char *filename, const char *line {{{*/ |