summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-12-25 18:08:43 -0500
committerTavian Barnes <tavianator@tavianator.com>2018-12-25 18:13:15 -0500
commit36cb1762dd647a6c9cbb0ab36993c83798c854f1 (patch)
tree4bc2fc1cca1400774855e0b2618b967bb9466947 /eval.c
parentb2e69d3f76270fc4051801cac923307514184055 (diff)
downloadbfs-36cb1762dd647a6c9cbb0ab36993c83798c854f1.tar.xz
stat: Provide a helper for getting human-readable field names
And fix -newerXY if the Y time doesn't exist.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c25
1 files changed, 2 insertions, 23 deletions
diff --git a/eval.c b/eval.c
index f636173..fa2be65 100644
--- a/eval.c
+++ b/eval.c
@@ -215,32 +215,11 @@ bool eval_capable(const struct expr *expr, struct eval_state *state) {
*/
static const struct timespec *eval_stat_time(const struct bfs_stat *statbuf, enum bfs_stat_field field, const struct eval_state *state) {
const struct timespec *ret = bfs_stat_time(statbuf, field);
-
if (!ret) {
- const char *kind;
- switch (field) {
- case BFS_STAT_ATIME:
- kind = "access";
- break;
- case BFS_STAT_BTIME:
- kind = "birth";
- break;
- case BFS_STAT_CTIME:
- kind = "change";
- break;
- case BFS_STAT_MTIME:
- kind = "modification";
- break;
- default:
- assert(false);
- kind = "???";
- break;
- }
-
- cfprintf(state->cmdline->cerr, "%{er}error: '%s': Couldn't get file %s time: %s%{rs}\n", state->ftwbuf->path, kind, strerror(errno));
+ cfprintf(state->cmdline->cerr, "%{er}error: '%s': Couldn't get file %s time: %m%{rs}\n",
+ state->ftwbuf->path, bfs_stat_field_name(field));
*state->ret = EXIT_FAILURE;
}
-
return ret;
}