Trim trailing white spaces on empty lines.
[geeqie.git] / src / trash.c
index f073a8a..9ec05c2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Geeqie
  * (C) 2006 John Ellis
- * Copyright (C) 2008 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Author: John Ellis
  *
@@ -15,8 +15,7 @@
 #include "trash.h"
 #include "utilops.h"
 
-
-#include "debug.h"
+#include "editors.h"
 #include "filedata.h"
 #include "ui_fileops.h"
 #include "ui_misc.h"
@@ -34,10 +33,17 @@ static gint file_util_safe_number(gint64 free_space)
        gint64 total = 0;
        GList *list;
        GList *work;
-       gint sorted = FALSE;
-       gint warned = FALSE;
+       gboolean sorted = FALSE;
+       gboolean warned = FALSE;
+       FileData *dir_fd;
 
-       if (!filelist_read(options->file_ops.safe_delete_path, &list, NULL)) return 0;
+       dir_fd = file_data_new_dir(options->file_ops.safe_delete_path);
+       if (!filelist_read(dir_fd, &list, NULL))
+               {
+               file_data_unref(dir_fd);
+               return 0;
+               }
+       file_data_unref(dir_fd);
 
        work = list;
        while (work)
@@ -93,9 +99,15 @@ void file_util_trash_clear(void)
 static gchar *file_util_safe_dest(const gchar *path)
 {
        gint n;
+       gchar *name;
+       gchar *dest;
 
        n = file_util_safe_number(filesize(path));
-       return g_strdup_printf("%s/%06d_%s", options->file_ops.safe_delete_path, n, filename_from_path(path));
+       name = g_strdup_printf("%06d_%s", n, filename_from_path(path));
+       dest = g_build_filename(options->file_ops.safe_delete_path, name, NULL);
+       g_free(name);
+
+       return dest;
 }
 
 static void file_util_safe_del_toggle_cb(GtkWidget *button, gpointer data)
@@ -110,11 +122,11 @@ static void file_util_safe_del_close_cb(GtkWidget *dialog, gpointer data)
        *gd = NULL;
 }
 
-gint file_util_safe_unlink(const char *path)
+gboolean file_util_safe_unlink(const gchar *path)
 {
        static GenericDialog *gd = NULL;
        gchar *result = NULL;
-       gint success = TRUE;
+       gboolean success = TRUE;
 
        if (!isfile(path)) return FALSE;
 
@@ -172,11 +184,11 @@ gint file_util_safe_unlink(const char *path)
        return success;
 }
 
-char *file_util_safe_delete_status(void)
+gchar *file_util_safe_delete_status(void)
 {
        gchar *buf;
 
-       if (options->editor_command[CMD_DELETE])
+       if (is_valid_editor_command(CMD_DELETE))
                {
                buf = g_strdup(_("Deletion by external command"));
                }
@@ -198,7 +210,7 @@ char *file_util_safe_delete_status(void)
                        buf = g_strdup_printf(_("Safe delete: %s"), _("off"));
                        }
                }
-               
+
        return buf;
 }
-
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */