summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2012-02-20 11:19:01 +0100
committerportix <portix@gmx.net>2012-02-20 11:19:01 +0100
commit940f99ed4894ddc9d938fd5d70b871695b888995 (patch)
tree2d4a55cb785b9e33218a3da8dc7fa3f18a1cfffd /src/util.c
parentb248323b4b718ec6922fe0d2a004f91b73967b43 (diff)
downloaddwb-940f99ed4894ddc9d938fd5d70b871695b888995.zip
Fixing ignoring local files.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/util.c b/src/util.c
index f7808bb1..c7e3ca6e 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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 {{{*/