aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Kavanagh <rak@rak.ac>2020-09-11 12:23:35 -0400
committerRyan Kavanagh <rak@rak.ac>2020-09-11 12:23:35 -0400
commit4487121b45dae9cddd685ab17e0a406dcc5fe6f0 (patch)
treefa10f4c4a015d1ad18aa2cbf92d37871e6a943eb
parentuse fts_nochdir (diff)
Add exclusion option
-rw-r--r--cleanup.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/cleanup.c b/cleanup.c
index f708900..d308a12 100644
--- a/cleanup.c
+++ b/cleanup.c
@@ -24,6 +24,7 @@
#include <err.h>
#include <errno.h>
#include <math.h>
+#include <string.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
@@ -45,10 +46,11 @@ main(int argc, char * const argv[])
time_t curr_time = time(NULL);
int verbose, dryrun, ch;
+ char* exclude = "";
verbose = 0;
dryrun = 0;
- while ((ch = getopt(argc, argv, "vn")) != -1) {
+ while ((ch = getopt(argc, argv, "vnx:")) != -1) {
switch (ch) {
case 'v':
verbose = 1;
@@ -56,6 +58,8 @@ main(int argc, char * const argv[])
case 'n':
dryrun = 1;
break;
+ case 'x':
+ exclude = optarg;
}
}
argc -= optind;
@@ -73,6 +77,8 @@ main(int argc, char * const argv[])
if (stat(node->fts_path, &attr) == -1)
err(1, NULL);
if (strcmp(node->fts_name, exclude) == 0) {
+ if (verbose)
+ printf("%s excluded\n", node->fts_path);
break;
}
file_age = difftime(curr_time, attr.st_mtime) / 86400.0;