return str;
}
+/* remove trailing character */
+gchar *strtailchomp(gchar *str, gchar tail_char)
+{
+ register gchar *s;
+
+ if (!*str) return str;
+ if (tail_char == '\0') return str;
+
+ for (s = str + strlen(str) - 1; s >= str && *s == tail_char; s--)
+ *s = '\0';
+
+ return str;
+}
+
+
/* Similar to `strstr' but this function ignores the case of both strings. */
gchar *strcasestr(const gchar *haystack, const gchar *needle)
{
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();
}
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);
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;