From b2b97e301892d89b9909bed17f4299e09af1e33b Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 20 Jan 2018 11:53:36 -0500 Subject: 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) --- printf.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'printf.c') diff --git a/printf.c b/printf.c index 27d9521..86804b8 100644 --- a/printf.c +++ b/printf.c @@ -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; -- cgit v1.2.3