Drop concat_dir_and_file() and use g_build_filename() instead.
authorLaurent Monin <geeqie@norz.org>
Tue, 20 May 2008 22:09:04 +0000 (22:09 +0000)
committerLaurent Monin <geeqie@norz.org>
Tue, 20 May 2008 22:09:04 +0000 (22:09 +0000)
src/bar_sort.c
src/main.c
src/pan-util.c
src/ui_bookmark.c
src/ui_fileops.c
src/ui_fileops.h
src/ui_pathsel.c
src/ui_utildlg.c
src/utilops.c
src/view_dir.c
src/view_file_list.c

index b8c3ee5..65df9c1 100644 (file)
@@ -272,7 +272,7 @@ static void bar_sort_bookmark_select_folder(SortData *sd, FileData *source, cons
 
        if (!isdir(path)) return;
 
-       dest_path = concat_dir_and_file(path, source->name);
+       dest_path = g_build_filename(path, source->name, NULL);
        bar_sort_undo_set(sd, NULL, source, dest_path);
 
        list = g_list_append(NULL, file_data_ref(source));
index cfee23f..d2e0512 100644 (file)
@@ -295,7 +295,7 @@ static void parse_command_line(int argc, char *argv[], gchar **path, gchar **fil
                while (i < argc)
                        {
                        const gchar *cmd_line = argv[i];
-                       gchar *cmd_all = concat_dir_and_file(base_dir, cmd_line);
+                       gchar *cmd_all = g_build_filename(base_dir, cmd_line, NULL);
 
                        if (cmd_line[0] == '/' && isdir(cmd_line))
                                {
@@ -560,15 +560,15 @@ static void setup_default_options(void)
        editor_reset_defaults();
 
        bookmark_add_default(_("Home"), homedir());
-       path = concat_dir_and_file(homedir(), "Desktop");
+       path = g_build_filename(homedir(), "Desktop", NULL);
        bookmark_add_default(_("Desktop"), path);
        g_free(path);
-       path = concat_dir_and_file(homedir(), GQ_RC_DIR_COLLECTIONS);
+       path = g_build_filename(homedir(), GQ_RC_DIR_COLLECTIONS, NULL);
        bookmark_add_default(_("Collections"), path);
        g_free(path);
 
        g_free(options->file_ops.safe_delete_path);
-       options->file_ops.safe_delete_path = concat_dir_and_file(homedir(), GQ_RC_DIR_TRASH);
+       options->file_ops.safe_delete_path = g_build_filename(homedir(), GQ_RC_DIR_TRASH, NULL);
 
        for (i = 0; i < COLOR_PROFILE_INPUTS; i++)
                {
index 37518f1..63e81fd 100644 (file)
@@ -167,7 +167,7 @@ gint pan_is_link_loop(const gchar *s)
                                {
                                gchar *link_path;
 
-                               link_path = concat_dir_and_file(sl, buf);
+                               link_path = g_build_filename(sl, buf, NULL);
                                parse_out_relatives(link_path);
 
                                if (strncmp(sl, link_path, l) == 0 &&
index 90ac068..da18305 100644 (file)
@@ -856,7 +856,7 @@ static void bookmark_populate(BookMarkData *bm)
                        history_list_add_to_key(bm->key, buf, 0);
                        g_free(buf);
 
-                       path = concat_dir_and_file(homedir(), "Desktop");
+                       path = g_build_filename(homedir(), "Desktop", NULL);
                        if (isname(path))
                                {
                                buf = bookmark_string(_("Desktop"), path, NULL);
index d70d5e0..3f30b9b 100644 (file)
@@ -618,15 +618,6 @@ gchar *remove_level_from_path(const gchar *path)
        return g_strndup(path, (gsize) n);
 }
 
-gchar *concat_dir_and_file(const gchar *base, const gchar *name)
-{
-       if (!base || !name) return NULL;
-
-       if (strcmp(base, "/") == 0) return g_strconcat(base, name, NULL);
-
-       return g_strconcat(base, "/", name, NULL);
-}
-
 const gchar *extension_from_path(const gchar *path)
 {
        if (!path) return NULL;
index 840dbe0..3749040 100644 (file)
@@ -66,7 +66,6 @@ gchar *unique_filename_simple(const gchar *path);
 
 const gchar *filename_from_path(const gchar *path);
 gchar *remove_level_from_path(const gchar *path);
-gchar *concat_dir_and_file(const gchar *base, const gchar *name);
 
 const gchar *extension_from_path(const gchar *path);
 gchar *remove_extension_from_path(const gchar *path);
index d26a108..0ac2fe3 100644 (file)
@@ -231,7 +231,7 @@ static void dest_populate(Dest_Data *dd, const gchar *path)
                        }
                else
                        {
-                       filepath = concat_dir_and_file(path, list->data);
+                       filepath = g_build_filename(path, list->data, NULL);
                        }
 
                gtk_list_store_append(store, &iter);
@@ -256,7 +256,7 @@ static void dest_populate(Dest_Data *dd, const gchar *path)
                        gchar *filepath;
                        const gchar *name = list->data;
 
-                       filepath = concat_dir_and_file(path, name);
+                       filepath = g_build_filename(path, name, NULL);
 
                        gtk_list_store_append(store, &iter);
                        gtk_list_store_set(store, &iter, 0, name, 1, filepath, -1);
@@ -424,7 +424,7 @@ static gint dest_view_rename_cb(TreeEditData *ted, const gchar *old, const gchar
        if (!old_path) return FALSE;
 
        buf = remove_level_from_path(old_path);
-       new_path = concat_dir_and_file(buf, new);
+       new_path = g_build_filename(buf, new, NULL);
        g_free(buf);
 
        if (isname(new_path))
@@ -745,7 +745,7 @@ static void dest_new_dir_cb(GtkWidget *widget, gpointer data)
                }
        else
                {
-               buf = concat_dir_and_file(dd->path, _("New folder"));
+               buf = g_build_filename(dd->path, _("New folder"), NULL);
                path = unique_filename(buf, NULL, " ", FALSE);
                g_free(buf);
                }
index 8b31771..f08eaf1 100644 (file)
@@ -401,7 +401,7 @@ void file_dialog_add_path_widgets(FileDialog *fdlg, const gchar *default_path, c
 
                if (path)
                        {
-                       fdlg->dest_path = concat_dir_and_file(base, path);
+                       fdlg->dest_path = g_build_filename(base, path, NULL);
                        }
                else
                        {
index 5578828..8ba30b1 100644 (file)
@@ -542,7 +542,7 @@ static void file_util_move_multiple_ok_cb(GenericDialog *gd, gpointer data)
                else
                        {
                        g_free(fdm->dest);
-                       fdm->dest = concat_dir_and_file(fdm->dest_base, name);
+                       fdm->dest = g_build_filename(fdm->dest_base, name, NULL);
                        fdm->confirmed = !isname(fdm->dest);
                        }
                }
@@ -705,7 +705,7 @@ static void file_util_move_multiple(FileDataMult *fdm)
                        {
                        GList *work = fdm->source_next;
                        fdm->source_fd = work->data;
-                       fdm->dest = concat_dir_and_file(fdm->dest_base, fdm->source_fd->name);
+                       fdm->dest = g_build_filename(fdm->dest_base, fdm->source_fd->name, NULL);
                        fdm->source_next = work->next;
                        fdm->confirmed = FALSE;
                        }
@@ -905,7 +905,7 @@ static void file_util_move_single_ok_cb(GenericDialog *gd, gpointer data)
 
                        base = remove_level_from_path(fds->dest);
                        g_free(fds->dest);
-                       fds->dest = concat_dir_and_file(base, name);
+                       fds->dest = g_build_filename(base, name, NULL);
                        fds->confirmed = !isname(fds->dest);
 
                        g_free(base);
@@ -1077,7 +1077,7 @@ static void file_util_move_do(FileDialog *fdlg)
                {
                if (isdir(fdlg->dest_path))
                        {
-                       gchar *buf = concat_dir_and_file(fdlg->dest_path, fdlg->source_fd->name);
+                       gchar *buf = g_build_filename(fdlg->dest_path, fdlg->source_fd->name, NULL);
                        gtk_entry_set_text(GTK_ENTRY(fdlg->entry), buf);
                        g_free(buf);
                        }
@@ -1117,7 +1117,7 @@ static void file_util_move_check(FileDialog *fdlg)
                        gchar *path;
 
                        base = remove_level_from_path(fdlg->source_fd->path);
-                       path = concat_dir_and_file(base, fdlg->dest_path);
+                       path = g_build_filename(base, fdlg->dest_path, NULL);
 
                        gtk_entry_set_text(GTK_ENTRY(fdlg->entry), path);
 
@@ -1288,7 +1288,7 @@ void file_util_move_simple(GList *list, const gchar *dest_path)
                gchar *dest;
 
                source_fd = list->data;
-               dest = concat_dir_and_file(dest_path, source_fd->name);
+               dest = g_build_filename(dest_path, source_fd->name, NULL);
 
                file_util_move_single(file_data_single_new(source_fd, dest, FALSE));
                g_free(dest);
@@ -1314,7 +1314,7 @@ void file_util_copy_simple(GList *list, const gchar *dest_path)
                gchar *dest;
 
                source_fd = list->data;
-               dest = concat_dir_and_file(dest_path, source_fd->name);
+               dest = g_build_filename(dest_path, source_fd->name, NULL);
 
                file_util_move_single(file_data_single_new(source_fd, dest, TRUE));
                g_free(dest);
@@ -2183,7 +2183,7 @@ static void file_util_rename_multiple_cb(FileDialog *fdlg, gpointer data)
        base = remove_level_from_path(fdlg->source_fd->path);
 
        g_free(fdlg->dest_path);
-       fdlg->dest_path = concat_dir_and_file(base, name);
+       fdlg->dest_path = g_build_filename(base, name, NULL);
        g_free(base);
 
        if (strlen(name) == 0 || strcmp(fdlg->source_fd->path, fdlg->dest_path) == 0)
@@ -2644,7 +2644,7 @@ static void file_util_rename_single_cb(FileDialog *fdlg, gpointer data)
        gchar *path;
 
        name = gtk_entry_get_text(GTK_ENTRY(fdlg->entry));
-       path = concat_dir_and_file(fdlg->dest_path, name);
+       path = g_build_filename(fdlg->dest_path, name, NULL);
 
        if (strlen(name) == 0 || strcmp(fdlg->source_fd->path, path) == 0)
                {
@@ -2729,7 +2729,7 @@ static void file_util_create_dir_do(const gchar *base, const gchar *name)
 {
        gchar *path;
 
-       path = concat_dir_and_file(base, name);
+       path = g_build_filename(base, name, NULL);
 
        if (isdir(path))
                {
index cf4896f..e99ab6b 100644 (file)
@@ -218,7 +218,7 @@ static gint vd_rename_cb(TreeEditData *td, const gchar *old, const gchar *new, g
        old_path = g_strdup(fd->path);
 
        base = remove_level_from_path(old_path);
-       new_path = concat_dir_and_file(base, new);
+       new_path = g_build_filename(base, new, NULL);
        g_free(base);
 
        if (file_util_rename_dir(fd, new_path, vd->view))
@@ -499,7 +499,7 @@ static void vd_pop_menu_new_cb(GtkWidget *widget, gpointer data)
                        break;
                }
 
-       buf = concat_dir_and_file(path, _("new_folder"));
+       buf = g_build_filename(path, _("new_folder"), NULL);
        new_path = unique_filename(buf, NULL, NULL, FALSE);
        g_free(buf);
        if (!new_path) return;
index d791dbd..586aacf 100644 (file)
@@ -381,8 +381,8 @@ static gint vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar
 
        if (strlen(new) == 0) return FALSE;
 
-       old_path = concat_dir_and_file(vf->path, old);
-       new_path = concat_dir_and_file(vf->path, new);
+       old_path = g_build_filename(vf->path, old, NULL);
+       new_path = g_build_filename(vf->path, new, NULL);
 
        if (strchr(new, '/') != NULL)
                {