From ecb0c751d8ec685892f63ffe963f4f136a8672ec Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 18 Jul 2024 15:57:45 +0900 Subject: [PATCH] Print permissions when in "-t" mode --- src/archiver.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/archiver.c b/src/archiver.c index e098577..c8cd0bd 100644 --- a/src/archiver.c +++ b/src/archiver.c @@ -825,32 +825,85 @@ int simple_archiver_parse_archive_info(FILE *in_f, int do_extract, SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_MAC || \ SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX + if (do_extract == 0) { + fprintf(stderr, " Permissions: "); + } + if ((buf[0] & 0x2) != 0) { permissions |= S_IRUSR; + if (do_extract == 0) { + fprintf(stderr, "r"); + } + } else if (do_extract == 0) { + fprintf(stderr, "-"); } if ((buf[0] & 0x4) != 0) { permissions |= S_IWUSR; + if (do_extract == 0) { + fprintf(stderr, "w"); + } + } else if (do_extract == 0) { + fprintf(stderr, "-"); } if ((buf[0] & 0x8) != 0) { permissions |= S_IXUSR; + if (do_extract == 0) { + fprintf(stderr, "x"); + } + } else if (do_extract == 0) { + fprintf(stderr, "-"); } if ((buf[0] & 0x10) != 0) { permissions |= S_IRGRP; + if (do_extract == 0) { + fprintf(stderr, "r"); + } + } else if (do_extract == 0) { + fprintf(stderr, "-"); } if ((buf[0] & 0x20) != 0) { permissions |= S_IWGRP; + if (do_extract == 0) { + fprintf(stderr, "w"); + } + } else if (do_extract == 0) { + fprintf(stderr, "-"); } if ((buf[0] & 0x40) != 0) { permissions |= S_IXGRP; + if (do_extract == 0) { + fprintf(stderr, "x"); + } + } else if (do_extract == 0) { + fprintf(stderr, "-"); } if ((buf[0] & 0x80) != 0) { permissions |= S_IROTH; + if (do_extract == 0) { + fprintf(stderr, "r"); + } + } else if (do_extract == 0) { + fprintf(stderr, "-"); } if ((buf[1] & 0x1) != 0) { permissions |= S_IWOTH; + if (do_extract == 0) { + fprintf(stderr, "w"); + } + } else if (do_extract == 0) { + fprintf(stderr, "-"); } if ((buf[1] & 0x2) != 0) { permissions |= S_IXOTH; + if (do_extract == 0) { + fprintf(stderr, "x"); + } + } else if (do_extract == 0) { + fprintf(stderr, "-"); + } + + if (do_extract == 0) { + fprintf(stderr, "\n"); } #endif