diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2018-01-20 11:53:36 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2018-01-20 12:36:08 -0500 |
commit | b2b97e301892d89b9909bed17f4299e09af1e33b (patch) | |
tree | 1083300b9f710b8fcd50c9bfec6fa83b1575b9c8 /printf.c | |
parent | 50432108fb3ef826301626b94c5e82ad2ab2bd75 (diff) | |
download | bfs-b2b97e301892d89b9909bed17f4299e09af1e33b.tar.xz |
printf: Add %w and %Wk for file birth times
%w and %W were chosen to match the format specifiers for file birth
times from stat(1)
Diffstat (limited to 'printf.c')
-rw-r--r-- | printf.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -81,6 +81,7 @@ static int bfs_printf_flush(FILE *file, const struct bfs_printf_directive *direc */ static const struct timespec *get_time_field(const struct bfs_stat *statbuf, enum bfs_stat_field stat_field) { if (!(statbuf->mask & stat_field)) { + errno = ENOTSUP; return NULL; } @@ -700,6 +701,11 @@ struct bfs_printf *parse_bfs_printf(const char *format, struct cmdline *cmdline) directive->fn = bfs_printf_U; command->needs_stat = true; break; + case 'w': + directive->fn = bfs_printf_ctime; + directive->stat_field = BFS_STAT_BTIME; + command->needs_stat = true; + break; case 'y': directive->fn = bfs_printf_y; break; @@ -716,6 +722,9 @@ struct bfs_printf *parse_bfs_printf(const char *format, struct cmdline *cmdline) case 'T': directive->stat_field = BFS_STAT_MTIME; goto directive_strftime; + case 'W': + directive->stat_field = BFS_STAT_BTIME; + goto directive_strftime; directive_strftime: directive->fn = bfs_printf_strftime; |