From 037361965a14e1899020bf16c9112936e39020e8 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 5 Mar 2016 13:53:40 -0500 Subject: Implement -used. This doesn't agree with find's output, but I think find is buggy here. For example, find -used +0 is returning fewer results than find -used 1, which makes no sense given that 1 is greater than 0. --- eval.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 81d2de7..aae82cd 100644 --- a/eval.c +++ b/eval.c @@ -173,6 +173,21 @@ bool eval_acnewer(const struct expr *expr, struct eval_state *state) { || (time->tv_sec == expr->reftime.tv_sec && time->tv_nsec > expr->reftime.tv_nsec); } +/** + * -used test. + */ +bool eval_used(const struct expr *expr, struct eval_state *state) { + const struct stat *statbuf = fill_statbuf(state); + if (!statbuf) { + return false; + } + + time_t diff = timespec_diff(&statbuf->st_atim, &statbuf->st_ctim); + diff /= 60*60*24; + printf("%d\n", (int)diff); + return do_cmp(expr, diff); +} + /** * -gid test. */ -- cgit v1.2.3