Use g_build_filename() to build paths.
authorLaurent Monin <geeqie@norz.org>
Tue, 20 May 2008 21:51:25 +0000 (21:51 +0000)
committerLaurent Monin <geeqie@norz.org>
Tue, 20 May 2008 21:51:25 +0000 (21:51 +0000)
src/bar_info.c
src/bar_sort.c

index 288d5b2..140b032 100644 (file)
@@ -101,8 +101,10 @@ static gint comment_legacy_write(FileData *fd, GList *keywords, const gchar *com
                comment_dir = cache_get_location(CACHE_TYPE_METADATA, fd->path, FALSE, &mode);
                if (cache_ensure_dir_exists(comment_dir, mode))
                        {
-                       comment_path = g_strconcat(comment_dir, "/", fd->name,
-                                                  GQ_CACHE_EXT_METADATA, NULL);
+                       gchar *filename = g_strconcat(fd->name, GQ_CACHE_EXT_METADATA, NULL);
+                       
+                       comment_path = g_build_filename(comment_dir, filename, NULL);
+                       g_free(filename);
                        }
                g_free(comment_dir);
                }
index 9376735..b8c3ee5 100644 (file)
@@ -94,7 +94,7 @@ static void bar_sort_collection_list_build(GtkWidget *bookmarks)
        history_list_free_key(SORT_KEY_COLLECTIONS);
        bookmark_list_set_key(bookmarks, SORT_KEY_COLLECTIONS);
 
-       collect_path = g_strconcat(homedir(), "/", GQ_RC_DIR_COLLECTIONS, NULL);
+       collect_path = g_build_filename(homedir(), GQ_RC_DIR_COLLECTIONS, NULL);
        filelist_read(collect_path, &list, NULL);
        g_free(collect_path);
 
@@ -433,20 +433,17 @@ static void bar_sort_add_ok_cb(FileDialog *fd, gpointer data)
        else
                {
                gchar *path;
-               gchar *ext;
-
+       
                if (strlen(name) == 0) return;
 
-               if (file_extension_match(name, ".gqv"))
-                       {
-                       ext = NULL;
-                       }
-               else
+               if (!file_extension_match(name, ".gqv"))
                        {
-                       ext = ".gqv";
+                       gchar *tmp = g_strconcat(name, ".gqv", NULL);
+                       g_free((gpointer) name);
+                       name = tmp;
                        }
 
-               path = g_strconcat(homedir(), "/", GQ_RC_DIR_COLLECTIONS, "/", name, ext, NULL);
+               path = g_build_filename(homedir(), GQ_RC_DIR_COLLECTIONS, name, NULL);
                if (isfile(path))
                        {
                        gchar *text = g_strdup_printf(_("The collection:\n%s\nalready exists."), name);