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();
}
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);
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;