Remove the duplicate "archive_format" and "archive_format_name" fields
from the private archive_write structure and fix up all writers to use the format fields in the base "archive" structure. This error made it impossible to query the format after setting up a writer because the write format was stored in an inaccessible place.
This commit is contained in:
parent
c43d294189
commit
0b315cd9ae
@ -81,13 +81,6 @@ struct archive_write {
|
||||
int (*write)(struct archive_write *, const void *, size_t);
|
||||
} compressor;
|
||||
|
||||
/*
|
||||
* Again, write support is considerably simpler because there's
|
||||
* no need for an auction.
|
||||
*/
|
||||
int archive_format;
|
||||
const char *archive_format_name;
|
||||
|
||||
/*
|
||||
* Pointers to format-specific functions for writing. They're
|
||||
* initialized by archive_write_set_format_XXX() calls.
|
||||
|
@ -87,8 +87,8 @@ archive_write_set_format_ar_bsd(struct archive *_a)
|
||||
struct archive_write *a = (struct archive_write *)_a;
|
||||
int r = archive_write_set_format_ar(a);
|
||||
if (r == ARCHIVE_OK) {
|
||||
a->archive_format = ARCHIVE_FORMAT_AR_BSD;
|
||||
a->archive_format_name = "ar (BSD)";
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_AR_BSD;
|
||||
a->archive.archive_format_name = "ar (BSD)";
|
||||
}
|
||||
return (r);
|
||||
}
|
||||
@ -99,8 +99,8 @@ archive_write_set_format_ar_svr4(struct archive *_a)
|
||||
struct archive_write *a = (struct archive_write *)_a;
|
||||
int r = archive_write_set_format_ar(a);
|
||||
if (r == ARCHIVE_OK) {
|
||||
a->archive_format = ARCHIVE_FORMAT_AR_GNU;
|
||||
a->archive_format_name = "ar (GNU/SVR4)";
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_AR_GNU;
|
||||
a->archive.archive_format_name = "ar (GNU/SVR4)";
|
||||
}
|
||||
return (r);
|
||||
}
|
||||
@ -204,7 +204,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
|
||||
if (a->archive_format == ARCHIVE_FORMAT_AR_GNU) {
|
||||
if (a->archive.archive_format == ARCHIVE_FORMAT_AR_GNU) {
|
||||
/*
|
||||
* SVR4/GNU variant use a "/" to mark then end of the filename,
|
||||
* make it possible to have embedded spaces in the filename.
|
||||
@ -261,7 +261,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
}
|
||||
} else if (a->archive_format == ARCHIVE_FORMAT_AR_BSD) {
|
||||
} else if (a->archive.archive_format == ARCHIVE_FORMAT_AR_BSD) {
|
||||
/*
|
||||
* BSD variant: for any file name which is more than
|
||||
* 16 chars or contains one or more embedded space(s), the
|
||||
|
@ -97,8 +97,8 @@ archive_write_set_format_cpio(struct archive *_a)
|
||||
a->format_finish_entry = archive_write_cpio_finish_entry;
|
||||
a->format_finish = archive_write_cpio_finish;
|
||||
a->format_destroy = archive_write_cpio_destroy;
|
||||
a->archive_format = ARCHIVE_FORMAT_CPIO_POSIX;
|
||||
a->archive_format_name = "POSIX cpio";
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_CPIO_POSIX;
|
||||
a->archive.archive_format_name = "POSIX cpio";
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
|
@ -102,8 +102,8 @@ archive_write_set_format_cpio_newc(struct archive *_a)
|
||||
a->format_finish_entry = archive_write_newc_finish_entry;
|
||||
a->format_finish = archive_write_newc_finish;
|
||||
a->format_destroy = archive_write_newc_destroy;
|
||||
a->archive_format = ARCHIVE_FORMAT_CPIO_SVR4_NOCRC;
|
||||
a->archive_format_name = "SVR4 cpio nocrc";
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_CPIO_SVR4_NOCRC;
|
||||
a->archive.archive_format_name = "SVR4 cpio nocrc";
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,8 @@ archive_write_set_format_pax_restricted(struct archive *_a)
|
||||
struct archive_write *a = (struct archive_write *)_a;
|
||||
int r;
|
||||
r = archive_write_set_format_pax(&a->archive);
|
||||
a->archive_format = ARCHIVE_FORMAT_TAR_PAX_RESTRICTED;
|
||||
a->archive_format_name = "restricted POSIX pax interchange";
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_RESTRICTED;
|
||||
a->archive.archive_format_name = "restricted POSIX pax interchange";
|
||||
return (r);
|
||||
}
|
||||
|
||||
@ -116,8 +116,8 @@ archive_write_set_format_pax(struct archive *_a)
|
||||
a->format_finish = archive_write_pax_finish;
|
||||
a->format_destroy = archive_write_pax_destroy;
|
||||
a->format_finish_entry = archive_write_pax_finish_entry;
|
||||
a->archive_format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE;
|
||||
a->archive_format_name = "POSIX pax interchange";
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE;
|
||||
a->archive.archive_format_name = "POSIX pax interchange";
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
@ -701,7 +701,7 @@ archive_write_pax_header(struct archive_write *a,
|
||||
* already set (we're already generating an extended header, so
|
||||
* may as well include these).
|
||||
*/
|
||||
if (a->archive_format != ARCHIVE_FORMAT_TAR_PAX_RESTRICTED ||
|
||||
if (a->archive.archive_format != ARCHIVE_FORMAT_TAR_PAX_RESTRICTED ||
|
||||
need_extension) {
|
||||
|
||||
if (archive_entry_mtime(entry_main) < 0 ||
|
||||
@ -764,7 +764,7 @@ archive_write_pax_header(struct archive_write *a,
|
||||
* Pax-restricted does not store data for hardlinks, in order
|
||||
* to improve compatibility with ustar.
|
||||
*/
|
||||
if (a->archive_format != ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE &&
|
||||
if (a->archive.archive_format != ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE &&
|
||||
hardlink != NULL)
|
||||
archive_entry_set_size(entry_main, 0);
|
||||
|
||||
|
@ -113,8 +113,8 @@ archive_write_set_format_shar(struct archive *_a)
|
||||
a->format_destroy = archive_write_shar_destroy;
|
||||
a->format_write_data = archive_write_shar_data_sed;
|
||||
a->format_finish_entry = archive_write_shar_finish_entry;
|
||||
a->archive_format = ARCHIVE_FORMAT_SHAR_BASE;
|
||||
a->archive_format_name = "shar";
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_SHAR_BASE;
|
||||
a->archive.archive_format_name = "shar";
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
@ -134,8 +134,8 @@ archive_write_set_format_shar_dump(struct archive *_a)
|
||||
shar = (struct shar *)a->format_data;
|
||||
shar->dump = 1;
|
||||
a->format_write_data = archive_write_shar_data_uuencode;
|
||||
a->archive_format = ARCHIVE_FORMAT_SHAR_DUMP;
|
||||
a->archive_format_name = "shar dump";
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_SHAR_DUMP;
|
||||
a->archive.archive_format_name = "shar dump";
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
|
@ -186,8 +186,8 @@ archive_write_set_format_ustar(struct archive *_a)
|
||||
a->format_finish = archive_write_ustar_finish;
|
||||
a->format_destroy = archive_write_ustar_destroy;
|
||||
a->format_finish_entry = archive_write_ustar_finish_entry;
|
||||
a->archive_format = ARCHIVE_FORMAT_TAR_USTAR;
|
||||
a->archive_format_name = "POSIX ustar";
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_TAR_USTAR;
|
||||
a->archive.archive_format_name = "POSIX ustar";
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user