more sync with sylpheed 0.5.0pre1
[claws.git] / src / utils.c
index 7fe6c6557c32f4d2ce85b39821cbd5f9b013a1d8..f5b720074af51db56da560a3eb0765d6652f254e 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, gint first, gint last)
 {
        DIR *dp;
        struct dirent *d;
        gchar *prev_dir;
+       gint fileno;
 
        prev_dir = g_get_current_dir();
 
@@ -1396,10 +1397,12 @@ 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 &&
+                   (last < 0 || fileno <= last)) {
+                       if (unlink(d->d_name) < 0)
+                               FILE_OP_ERROR(d->d_name, "unlink");
+               }
        }
 
        closedir(dp);
@@ -1415,6 +1418,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, -1);
+}
+
 gint remove_dir_recursive(const gchar *dir)
 {
        struct stat s;