summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-02-04 16:33:53 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-02-04 16:33:53 -0500
commitd696346689e161ee8a5623182ed65ab119adb203 (patch)
tree3c55935d75f847a21c82c1ca7e400971f4f12fb2 /eval.c
parent0a3754f8b66fc50dafeb61711679fc85c1e38038 (diff)
downloadbfs-d696346689e161ee8a5623182ed65ab119adb203.tar.xz
Implement -[ac]?newer.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 2463d86..33da8e4 100644
--- a/eval.c
+++ b/eval.c
@@ -1,3 +1,14 @@
+/*********************************************************************
+ * bfs *
+ * Copyright (C) 2015-2016 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * This program is free software. It comes without any warranty, to *
+ * the extent permitted by applicable law. You can redistribute it *
+ * and/or modify it under the terms of the Do What The Fuck You Want *
+ * To Public License, Version 2, as published by Sam Hocevar. See *
+ * the COPYING file or http://www.wtfpl.net/ for more details. *
+ *********************************************************************/
+
#include "bfs.h"
#include "bftw.h"
#include <dirent.h>
@@ -122,6 +133,32 @@ bool eval_acmtime(const struct expr *expr, struct eval_state *state) {
}
/**
+ * -[ac]?newer tests.
+ */
+bool eval_acnewer(const struct expr *expr, struct eval_state *state) {
+ const struct stat *statbuf = fill_statbuf(state);
+ if (!statbuf) {
+ return false;
+ }
+
+ const struct timespec *time;
+ switch (expr->timefield) {
+ case ATIME:
+ time = &statbuf->st_atim;
+ break;
+ case CTIME:
+ time = &statbuf->st_ctim;
+ break;
+ case MTIME:
+ time = &statbuf->st_mtim;
+ break;
+ }
+
+ return time->tv_sec > expr->reftime.tv_sec
+ || (time->tv_sec == expr->reftime.tv_sec && time->tv_nsec > expr->reftime.tv_nsec);
+}
+
+/**
* -gid test.
*/
bool eval_gid(const struct expr *expr, struct eval_state *state) {