Use G_DIR_SEPARATOR where applicable.
authorLaurent Monin <geeqie@norz.org>
Wed, 21 May 2008 11:07:23 +0000 (11:07 +0000)
committerLaurent Monin <geeqie@norz.org>
Wed, 21 May 2008 11:07:23 +0000 (11:07 +0000)
14 files changed:
src/cache.c
src/collect-io.c
src/collect.c
src/layout.c
src/main.c
src/pan-item.c
src/pan-util.c
src/pan-view.c
src/ui_pathsel.c
src/ui_tabcomp.c
src/ui_utildlg.c
src/utilops.c
src/view_dir_tree.c
src/view_file_list.c

index c299baf..c1b0a44 100644 (file)
@@ -593,7 +593,7 @@ gint cache_ensure_dir_exists(gchar *path, mode_t mode)
                while (p[0] != '\0')
                        {
                        p++;
-                       if (p[0] == '/' || p[0] == '\0')
+                       if (p[0] == G_DIR_SEPARATOR || p[0] == '\0')
                                {
                                gint end = TRUE;
                                if (p[0] != '\0')
@@ -610,7 +610,7 @@ gint cache_ensure_dir_exists(gchar *path, mode_t mode)
                                                return FALSE;
                                                }
                                        }
-                               if (!end) p[0] = '/';
+                               if (!end) p[0] = G_DIR_SEPARATOR;
                                }
                        }
                }
index 1f6ddda..f11e273 100644 (file)
@@ -155,7 +155,7 @@ static gint collection_load_private(CollectionData *cd, const gchar *path, Colle
                        if (!flush)
                                changed |= collect_manager_process_action(entry, &buf);
 
-                       valid = (buf[0] == '/' && collection_add_check(cd, file_data_new_simple(buf), FALSE, TRUE));
+                       valid = (buf[0] == G_DIR_SEPARATOR && collection_add_check(cd, file_data_new_simple(buf), FALSE, TRUE));
                        if (!valid) DEBUG_1("collection invalid file: %s", buf);
                        g_free(buf);
 
index 09e1d30..e329b24 100644 (file)
@@ -1253,7 +1253,7 @@ CollectWindow *collection_window_new(const gchar *path)
 
        collection_set_update_info_func(cw->cd, collection_window_update_info, cw);
 
-       if (path && *path == '/') collection_load_begin(cw->cd, NULL, COLLECTION_LOAD_NONE);
+       if (path && *path == G_DIR_SEPARATOR) collection_load_begin(cw->cd, NULL, COLLECTION_LOAD_NONE);
 
        return cw;
 }
index 6b344ef..f6df188 100644 (file)
@@ -149,7 +149,7 @@ static void layout_path_entry_tab_cb(const gchar *path, gpointer data)
                if ((!lw->path || strcmp(lw->path, buf) != 0) && layout_set_path(lw, buf))
                        {
                        gint pos = -1;
-                       /* put the '/' back, if we are in tab completion for a dir and result was path change */
+                       /* put the G_DIR_SEPARATOR back, if we are in tab completion for a dir and result was path change */
                        gtk_editable_insert_text(GTK_EDITABLE(lw->path_entry), G_DIR_SEPARATOR_S, -1, &pos);
                        gtk_editable_set_position(GTK_EDITABLE(lw->path_entry),
                                                  strlen(gtk_entry_get_text(GTK_ENTRY(lw->path_entry))));
index c83a995..6869afd 100644 (file)
@@ -297,7 +297,7 @@ static void parse_command_line(int argc, char *argv[], gchar **path, gchar **fil
                        const gchar *cmd_line = argv[i];
                        gchar *cmd_all = g_build_filename(base_dir, cmd_line, NULL);
 
-                       if (cmd_line[0] == '/' && isdir(cmd_line))
+                       if (cmd_line[0] == G_DIR_SEPARATOR && isdir(cmd_line))
                                {
                                parse_command_line_process_dir(cmd_line, path, file, &list, &first_dir);
                                }
@@ -305,7 +305,7 @@ static void parse_command_line(int argc, char *argv[], gchar **path, gchar **fil
                                {
                                parse_command_line_process_dir(cmd_all, path, file, &list, &first_dir);
                                }
-                       else if (cmd_line[0] == '/' && isfile(cmd_line))
+                       else if (cmd_line[0] == G_DIR_SEPARATOR && isfile(cmd_line))
                                {
                                parse_command_line_process_file(cmd_line, path, file,
                                                                &list, collection_list, &first_dir);
index 79d1f51..7d56c8a 100644 (file)
@@ -739,7 +739,7 @@ static GList *pan_item_find_by_path_l(GList *list, GList *search_list,
                        {
                        gint match = FALSE;
 
-                       if (path[0] == '/')
+                       if (path[0] == G_DIR_SEPARATOR)
                                {
                                if (pi->fd->path && strcmp(path, pi->fd->path) == 0) match = TRUE;
                                }
@@ -785,7 +785,7 @@ GList *pan_item_find_by_path(PanWindow *pw, PanItemType type, const gchar *path,
        GList *list = NULL;
 
        if (!path) return NULL;
-       if (partial && path[0] == '/') return NULL;
+       if (partial && path[0] == G_DIR_SEPARATOR) return NULL;
 
        list = pan_item_find_by_path_l(list, pw->list_static, type, path, ignore_case, partial);
        list = pan_item_find_by_path_l(list, pw->list, type, path, ignore_case, partial);
index 63e81fd..ef95e52 100644 (file)
@@ -158,10 +158,10 @@ gint pan_is_link_loop(const gchar *s)
 
                        parse_out_relatives(sl);
 
-                       if (buf[0] == '/')
+                       if (buf[0] == G_DIR_SEPARATOR)
                                {
                                if (strncmp(sl, buf, l) == 0 &&
-                                   (sl[l] == '\0' || sl[l] == '/' || l == 1)) ret = TRUE;
+                                   (sl[l] == '\0' || sl[l] == G_DIR_SEPARATOR || l == 1)) ret = TRUE;
                                }
                        else
                                {
@@ -171,7 +171,7 @@ gint pan_is_link_loop(const gchar *s)
                                parse_out_relatives(link_path);
 
                                if (strncmp(sl, link_path, l) == 0 &&
-                                   (sl[l] == '\0' || sl[l] == '/' || l == 1)) ret = TRUE;
+                                   (sl[l] == '\0' || sl[l] == G_DIR_SEPARATOR || l == 1)) ret = TRUE;
 
                                g_free(link_path);
                                }
index 7a1c703..0e0adbf 100644 (file)
@@ -1646,7 +1646,7 @@ static gint pan_search_by_path(PanWindow *pw, const gchar *path)
        image_scroll_to_point(pw->imd, pi->x + pi->width / 2, pi->y + pi->height / 2, 0.5, 0.5);
 
        buf = g_strdup_printf("%s ( %d / %d )",
-                             (path[0] == '/') ? _("path found") : _("filename found"),
+                             (path[0] == G_DIR_SEPARATOR) ? _("path found") : _("filename found"),
                              g_list_index(list, pi) + 1,
                              g_list_length(list));
        pan_search_status(pw, buf);
index 2b6c4c7..4f8cdc4 100644 (file)
@@ -184,7 +184,7 @@ static void dest_populate(Dest_Data *dd, const gchar *path)
                    && dir->d_name[0] == '.' && dir->d_name[1] == '\0')
                        continue;
                if (dir->d_name[0] == '.' && dir->d_name[1] == '.' && dir->d_name[2] == '\0'
-                   && pathl[0] == '/' && pathl[1] == '\0')
+                   && pathl[0] == G_DIR_SEPARATOR && pathl[1] == '\0')
                        continue; /* no .. for root directory */
                if (dd->show_hidden || !is_hidden(dir->d_name))
                        {
@@ -1207,7 +1207,7 @@ GtkWidget *path_selection_new_with_files(GtkWidget *entry, const gchar *path,
                dd->filter = g_strdup(gtk_entry_get_text(GTK_ENTRY(GTK_BIN(dd->filter_combo)->child)));
                }
 
-       if (path && path[0] == '/' && isdir(path))
+       if (path && path[0] == G_DIR_SEPARATOR && isdir(path))
                {
                dest_populate(dd, path);
                }
index 0ad448f..67cee46 100644 (file)
@@ -51,7 +51,7 @@
 /* ----------------------------------------------------------------
    Tab completion routines, can be connected to any gtkentry widget
    using the tab_completion_add_to_entry() function.
-   Use remove_trailing_slash() to strip the trailing '/'.
+   Use remove_trailing_slash() to strip the trailing G_DIR_SEPARATOR.
    ----------------------------------------------------------------*/
 
 typedef struct _TabCompData TabCompData;
@@ -821,7 +821,7 @@ gchar *remove_trailing_slash(const gchar *path)
        if (!path) return NULL;
 
        l = strlen(path);
-       while (l > 1 && path[l - 1] == '/') l--;
+       while (l > 1 && path[l - 1] == G_DIR_SEPARATOR) l--;
 
        return g_strndup(path, l);
 }
index f08eaf1..f63507e 100644 (file)
@@ -386,7 +386,7 @@ void file_dialog_add_path_widgets(FileDialog *fdlg, const gchar *default_path, c
        generic_dialog_attach_default(GENERIC_DIALOG(fdlg), fdlg->entry);
        gtk_widget_show(tabcomp);
 
-       if (path && path[0] == '/')
+       if (path && path[0] == G_DIR_SEPARATOR)
                {
                fdlg->dest_path = g_strdup(path);
                }
index 2e8d770..11747ce 100644 (file)
@@ -1109,7 +1109,7 @@ static void file_util_move_check(FileDialog *fdlg)
                return;
                }
 
-       if (!fdlg->dest_path || fdlg->dest_path[0] != '/')
+       if (!fdlg->dest_path || fdlg->dest_path[0] != G_DIR_SEPARATOR)
                {
                if (fdlg->source_fd)
                        {
@@ -2772,7 +2772,7 @@ static void file_util_create_dir_cb(FileDialog *fdlg, gpointer data)
 
        if (strlen(name) == 0) return;
 
-       if (name[0] == '/')
+       if (name[0] == G_DIR_SEPARATOR)
                {
                gchar *buf;
                buf  = remove_level_from_path(name);
index 1eca737..89f40fc 100644 (file)
@@ -206,7 +206,7 @@ static GList *parts_list(const gchar *path)
 
        strp = path;
 
-       if (*strp != '/') return NULL;
+       if (*strp != G_DIR_SEPARATOR) return NULL;
 
        strp++;
        strb = strp;
@@ -214,7 +214,7 @@ static GList *parts_list(const gchar *path)
 
        while (*strp != '\0')
                {
-               if (*strp == '/')
+               if (*strp == G_DIR_SEPARATOR)
                        {
                        if (l > 0) list = g_list_prepend(list, g_strndup(strb, l));
                        strp++;
@@ -465,14 +465,14 @@ static gint vdtree_populate_path_by_iter(ViewDir *vd, GtkTreeIter *iter, gint fo
                gint n;
 
                n = strlen(nd->fd->path);
-               if (target_path[n] == '/' && target_path[n+1] == '.')
+               if (target_path[n] == G_DIR_SEPARATOR && target_path[n+1] == '.')
                        {
                        gchar *name8;
                        struct stat sbuf;
 
                        n++;
 
-                       while (target_path[n] != '\0' && target_path[n] != '/') n++;
+                       while (target_path[n] != '\0' && target_path[n] != G_DIR_SEPARATOR) n++;
                        name8 = g_strndup(target_path, n);
 
                        if (stat_utf8(name8, &sbuf))
index 586aacf..328d6ff 100644 (file)
@@ -384,7 +384,7 @@ static gint vflist_row_rename_cb(TreeEditData *td, const gchar *old, const gchar
        old_path = g_build_filename(vf->path, old, NULL);
        new_path = g_build_filename(vf->path, new, NULL);
 
-       if (strchr(new, '/') != NULL)
+       if (strchr(new, G_DIR_SEPARATOR) != NULL)
                {
                gchar *text = g_strdup_printf(_("Invalid file name:\n%s"), new);
                file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, vf->listview);