From 4487121b45dae9cddd685ab17e0a406dcc5fe6f0 Mon Sep 17 00:00:00 2001 From: Ryan Kavanagh Date: Fri, 11 Sep 2020 12:23:35 -0400 Subject: Add exclusion option --- cleanup.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cleanup.c') diff --git a/cleanup.c b/cleanup.c index f708900..d308a12 100644 --- a/cleanup.c +++ b/cleanup.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -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; -- cgit v1.2.3