From 7c0520451b071e77b4c432ed89fc7559b8c58138 Mon Sep 17 00:00:00 2001 From: Adam Spragg Date: Mon, 23 May 2022 15:00:28 +0100 Subject: Make "--no-mtime" apply to "dump" action --- src/metaentry.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/metaentry.c') diff --git a/src/metaentry.c b/src/metaentry.c index 9956f7f..7e90290 100644 --- a/src/metaentry.c +++ b/src/metaentry.c @@ -911,7 +911,7 @@ mentries_compare(struct metahash *mhashreal, /* Dumps given metadata */ void -mentries_dump(struct metahash *mhash) +mentries_dump(struct metahash *mhash, int with_mtime) { const struct metaentry *mentry; char mode[11 + 1] = ""; @@ -923,18 +923,23 @@ mentries_dump(struct metahash *mhash) for (int key = 0; key < HASH_INDEXES; key++) { for (mentry = mhash->bucket[key]; mentry; mentry = mentry->next) { strmode(mentry->mode, mode); - if (mentry->mtimensec == MTIME_NONE) { - snprintf(date, sizeof(date), "%19s", ""); + if (!with_mtime) { + date[0] = '\0'; + nsec[0] = '\0'; + zone[0] = '\0'; + } + else if (mentry->mtimensec == MTIME_NONE) { + snprintf(date, sizeof(date), "\t%19s", ""); snprintf(nsec, sizeof(nsec), "%10s", ""); snprintf(zone, sizeof(zone), "%6s", ""); } else { localtime_r(&mentry->mtime, &cal); - strftime(date, sizeof(date), "%F %T", &cal); + strftime(date, sizeof(date), "\t%F %T", &cal); snprintf(nsec, sizeof(nsec), ".%09ld", mentry->mtimensec); strftime(zone, sizeof(zone), " %z", &cal); } - printf("%s\t%s\t%s\t%s%s%s\t%s%s\n", + printf("%s\t%s\t%s%s%s%s\t%s%s\n", mode, mentry->owner, mentry->group, date, nsec, zone, -- cgit v1.2.1