From 62c7590f26adfc7ab5cda0ade1dc044ae9e75a53 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Tue, 4 Nov 2014 00:36:18 +0530 Subject: [PATCH] Detiled listing of archive members (-i). --- archive/pc_archive.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/archive/pc_archive.c b/archive/pc_archive.c index e8df9c3..3a7ca2c 100644 --- a/archive/pc_archive.c +++ b/archive/pc_archive.c @@ -1429,9 +1429,41 @@ copy_data_skip(struct archive *ar, struct archive_entry *entry, int typ) static int archive_list_entry(struct archive *a, struct archive_entry *entry, int typ) { - printf("%s\n", archive_entry_pathname(entry)); - if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) > 0) { - return (copy_data_skip(a, entry, typ)); + time_t tm; + int tm_is_set = 0; + char strtm[13]; + + if (archive_entry_mtime_is_set(entry)) { + tm = archive_entry_mtime(entry); + tm_is_set = 1; + + } else if (archive_entry_atime_is_set(entry)) { + tm = archive_entry_atime(entry); + tm_is_set = 1; + + } else if (archive_entry_ctime_is_set(entry)) { + tm = archive_entry_ctime(entry); + tm_is_set = 1; + + } else if (archive_entry_birthtime_is_set(entry)) { + tm = archive_entry_birthtime(entry); + tm_is_set = 1; + } + + if (!tm_is_set) { + strcpy(strtm, "N/A"); + } else { + if (strftime(strtm, sizeof (strtm), "%b %e %G", localtime(&tm)) == 0) + strcpy(strtm, "N/A"); + } + + if (archive_entry_size_is_set(entry)) { + int64_t sz = archive_entry_size(entry); + printf("%12" PRId64 " %13s %s\n", sz, strtm, archive_entry_pathname(entry)); + if (sz > 0) + return (copy_data_skip(a, entry, typ)); + } else { + printf("%12" PRId64 " %13s %s\n", 0LL, strtm, archive_entry_pathname(entry)); } return (ARCHIVE_OK); }