aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cleanup.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/cleanup.c b/cleanup.c
index 3dd6e36..f708900 100644
--- a/cleanup.c
+++ b/cleanup.c
@@ -61,7 +61,7 @@ main(int argc, char * const argv[])
argc -= optind;
argv += optind;
- if ((file_system = fts_open(paths, 0, NULL)) == NULL)
+ if ((file_system = fts_open(paths, FTS_NOCHDIR, NULL)) == NULL)
errx(1, NULL);
while ((node = fts_read(file_system)) != NULL) {
@@ -70,19 +70,22 @@ main(int argc, char * const argv[])
switch (node->fts_info) {
case FTS_F:
- if (stat(node->fts_name, &attr) == -1)
+ if (stat(node->fts_path, &attr) == -1)
err(1, NULL);
+ if (strcmp(node->fts_name, exclude) == 0) {
+ break;
+ }
file_age = difftime(curr_time, attr.st_mtime) / 86400.0;
cutoff = mind + (mind - maxd) *
pow((double) attr.st_size / (double) max_size - 1, 3.0);
if (verbose)
printf("%s age %fd cuttoff %fd size %lldB\n",
- node->fts_name, file_age, cutoff, attr.st_size);
+ node->fts_path, file_age, cutoff, attr.st_size);
if (file_age >= cutoff) {
if (!dryrun)
- unlink(node->fts_name);
+ unlink(node->fts_path);
if (verbose)
- printf("%s deleted\n", node->fts_name);
+ printf("%s deleted\n", node->fts_path);
}
break;
default: