diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2018-12-25 18:08:43 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2018-12-25 18:13:15 -0500 |
commit | 36cb1762dd647a6c9cbb0ab36993c83798c854f1 (patch) | |
tree | 4bc2fc1cca1400774855e0b2618b967bb9466947 /eval.c | |
parent | b2e69d3f76270fc4051801cac923307514184055 (diff) | |
download | bfs-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.c | 25 |
1 files changed, 2 insertions, 23 deletions
@@ -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; } |