sync with sylpheed 0.5.0pre1 release
[claws.git] / src / utils.c
index 7fe6c6557c32f4d2ce85b39821cbd5f9b013a1d8..30fece025c03c93f311efdcd60a08728c87e37b5 100644 (file)
@@ -1377,11 +1377,12 @@ gint remove_all_files(const gchar *dir)
        return 0;
 }
 
-gint remove_all_numbered_files(const gchar *dir)
+gint remove_numbered_files(const gchar *dir, guint first, guint last)
 {
        DIR *dp;
        struct dirent *d;
        gchar *prev_dir;
+       gint fileno;
 
        prev_dir = g_get_current_dir();
 
@@ -1396,10 +1397,11 @@ gint remove_all_numbered_files(const gchar *dir)
        }
 
        while ((d = readdir(dp)) != NULL) {
-               if (to_number(d->d_name) < 0) continue;
-
-               if (unlink(d->d_name) < 0)
-                       FILE_OP_ERROR(d->d_name, "unlink");
+               fileno = to_number(d->d_name);
+               if (fileno >= 0 && first <= fileno && fileno <= last) {
+                       if (unlink(d->d_name) < 0)
+                               FILE_OP_ERROR(d->d_name, "unlink");
+               }
        }
 
        closedir(dp);
@@ -1415,6 +1417,11 @@ gint remove_all_numbered_files(const gchar *dir)
        return 0;
 }
 
+gint remove_all_numbered_files(const gchar *dir)
+{
+       return remove_numbered_files(dir, 0, UINT_MAX);
+}
+
 gint remove_dir_recursive(const gchar *dir)
 {
        struct stat s;