From: Tim Kientzle Date: Fri, 17 Jul 2009 06:31:13 +0000 (-0400) Subject: Use archive_entry_XXX() functions more heavily. X-Git-Tag: v2.8.0~528 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f710c218d804184190c06d5729715f00d5dbf58;p=thirdparty%2Flibarchive.git Use archive_entry_XXX() functions more heavily. This removes the need for major()/minor() and reduces the use of struct stat in the client code. SVN-Revision: 1233 --- diff --git a/tar/read.c b/tar/read.c index 960ad4f02..16709a3f7 100644 --- a/tar/read.c +++ b/tar/read.c @@ -29,11 +29,6 @@ __FBSDID("$FreeBSD: src/usr.bin/tar/read.c,v 1.40 2008/08/21 06:41:14 kientzle E #ifdef HAVE_SYS_TYPES_H #include #endif -#ifdef MAJOR_IN_MKDEV -#include -#elif defined(MAJOR_IN_SYSMACROS) -#include -#endif #ifdef HAVE_SYS_PARAM_H #include #endif @@ -348,7 +343,6 @@ read_archive(struct bsdtar *bsdtar, char mode) static void list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) { - const struct stat *st; char tmp[100]; size_t w; const char *p; @@ -356,8 +350,6 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) time_t tim; static time_t now; - st = archive_entry_stat(entry); - /* * We avoid collecting the entire list in memory at once by * listing things as we see them. However, that also means we can't @@ -373,12 +365,13 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) time(&now); fprintf(out, "%s %d ", archive_entry_strmode(entry), - (int)(st->st_nlink)); + archive_entry_nlink(entry)); /* Use uname if it's present, else uid. */ p = archive_entry_uname(entry); if ((p == NULL) || (*p == '\0')) { - sprintf(tmp, "%lu ", (unsigned long)st->st_uid); + sprintf(tmp, "%lu ", + (unsigned long)archive_entry_uid(entry)); p = tmp; } w = strlen(p); @@ -392,7 +385,8 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) fprintf(out, "%s", p); w = strlen(p); } else { - sprintf(tmp, "%lu", (unsigned long)st->st_gid); + sprintf(tmp, "%lu", + (unsigned long)archive_entry_gid(entry)); w = strlen(tmp); fprintf(out, "%s", tmp); } @@ -405,8 +399,8 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) if (archive_entry_filetype(entry) == AE_IFCHR || archive_entry_filetype(entry) == AE_IFBLK) { sprintf(tmp, "%lu,%lu", - (unsigned long)major(st->st_rdev), - (unsigned long)minor(st->st_rdev)); /* ls(1) also casts here. */ + (unsigned long)archive_entry_rdevmajor(entry), + (unsigned long)archive_entry_rdevminor(entry)); } else { /* * Note the use of platform-dependent macros to format @@ -414,14 +408,14 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry) * corresponding type for the cast. */ sprintf(tmp, BSDTAR_FILESIZE_PRINTF, - (BSDTAR_FILESIZE_TYPE)st->st_size); + (BSDTAR_FILESIZE_TYPE)archive_entry_size(entry)); } if (w + strlen(tmp) >= bsdtar->gs_width) bsdtar->gs_width = w+strlen(tmp)+1; fprintf(out, "%*s", (int)(bsdtar->gs_width - w), tmp); /* Format the time using 'ls -l' conventions. */ - tim = (time_t)st->st_mtime; + tim = archive_entry_mtime(entry); #if defined(_WIN32) && !defined(__CYGWIN__) /* Windows' strftime function does not support %e format. */ if (abs(tim - now) > (365/2)*86400)