diff options
author | Ryan Kavanagh <rak@rak.ac> | 2020-09-11 12:23:35 -0400 |
---|---|---|
committer | Ryan Kavanagh <rak@rak.ac> | 2020-09-11 12:23:35 -0400 |
commit | 4487121b45dae9cddd685ab17e0a406dcc5fe6f0 (patch) | |
tree | fa10f4c4a015d1ad18aa2cbf92d37871e6a943eb /cleanup.c | |
parent | use fts_nochdir (diff) |
Add exclusion option
Diffstat (limited to 'cleanup.c')
-rw-r--r-- | cleanup.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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; |