Eliminate some redundant calls to archive_entry_hardlink.

This commit is contained in:
Tim Kientzle 2004-04-20 20:07:30 +00:00
parent 14f166b706
commit 9b26f9ec8e
2 changed files with 15 additions and 8 deletions

View File

@ -315,6 +315,7 @@ archive_write_pax_header(struct archive *a,
{
struct archive_entry *entry_main;
const char *linkname, *p;
const char *hardlink;
const wchar_t *wp, *wp2, *wname_start;
int need_extension, oldstate, r, ret;
struct pax *pax;
@ -332,8 +333,10 @@ archive_write_pax_header(struct archive *a,
st_original = archive_entry_stat(entry_original);
hardlink = archive_entry_hardlink(entry_original);
/* Make sure this is a type of entry that we can handle here */
if (!archive_entry_hardlink(entry_original)) {
if (hardlink == NULL) {
switch (st_original->st_mode & S_IFMT) {
case S_IFREG:
case S_IFLNK:
@ -390,13 +393,13 @@ archive_write_pax_header(struct archive *a,
}
/* If link name is too long, add 'linkpath' to pax extended attrs. */
linkname = archive_entry_hardlink(entry_main);
linkname = hardlink;
if (linkname == NULL)
linkname = archive_entry_symlink(entry_main);
if (linkname != NULL && strlen(linkname) > 100) {
add_pax_attr(&(pax->pax_header), "linkpath", linkname);
if (archive_entry_hardlink(entry_main))
if (hardlink != NULL)
archive_entry_set_hardlink(entry_main,
"././@LongHardLink");
else
@ -563,7 +566,7 @@ archive_write_pax_header(struct archive *a,
* to improve compatibility with ustar.
*/
if (a->archive_format != ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE &&
archive_entry_hardlink(entry_main) != NULL)
hardlink != NULL)
archive_entry_set_size(entry_main, 0);
/*
@ -576,7 +579,7 @@ archive_write_pax_header(struct archive *a,
* need to select this behavior, in which case the following
* will need to be revisited. XXX
*/
if (archive_entry_hardlink(entry_main) != NULL)
if (hardlink != NULL)
archive_entry_set_size(entry_main, 0);
/* Format 'ustar' header for main entry. */

View File

@ -181,8 +181,10 @@ __archive_write_format_header_ustar(struct archive *a, char buff[512],
size_t copy_length;
const char *p, *pp;
const struct stat *st;
int mytartype;
ret = 0;
mytartype = -1;
memcpy(buff, &template_header, 512);
h = (struct archive_entry_header_ustar *)buff;
@ -219,7 +221,9 @@ __archive_write_format_header_ustar(struct archive *a, char buff[512],
}
p = archive_entry_hardlink(entry);
if(p == NULL)
if(p != NULL)
mytartype = '1';
else
p = archive_entry_symlink(entry);
if (p != NULL && p[0] != '\0') {
copy_length = strlen(p);
@ -302,8 +306,8 @@ __archive_write_format_header_ustar(struct archive *a, char buff[512],
if (tartype >= 0) {
h->typeflag[0] = tartype;
} else if (archive_entry_hardlink(entry) != NULL) {
h->typeflag[0] = '1';
} else if (mytartype >= 0) {
h->typeflag[0] = mytartype;
} else {
switch (st->st_mode & S_IFMT) {
case S_IFREG: h->typeflag[0] = '0' ; break;