Don't use deprecated libarchive functions, if possible

pull/17/merge
Dave Vasilevsky 11 years ago
parent 4a5fffc19c
commit afd3914086

@ -30,6 +30,17 @@
#endif #endif
#pragma mark LIBARCHIVE CHANGES
#include <archive.h>
#if ARCHIVE_VERSION_NUMBER >= 3000000
#define prevent_compression(a) archive_read_support_filter_none(a)
#define finish_reading(a) archive_read_free(a)
#else
#define prevent_compression(a) archive_read_support_compression_none(a)
#define finish_reading(a) archive_read_finish(a)
#endif
#pragma mark OPERATIONS #pragma mark OPERATIONS
void pixz_list(bool tar); void pixz_list(bool tar);

@ -115,7 +115,7 @@ void pixz_read(bool verify, size_t nspecs, char **specs) {
off_t lastoff = 0; off_t lastoff = 0;
struct archive *ar = archive_read_new(); struct archive *ar = archive_read_new();
archive_read_support_compression_none(ar); prevent_compression(ar);
archive_read_support_format_tar(ar); archive_read_support_format_tar(ar);
archive_read_open(ar, NULL, tar_ok, tar_read, tar_ok); archive_read_open(ar, NULL, tar_ok, tar_read, tar_ok);
struct archive_entry *entry; struct archive_entry *entry;
@ -150,7 +150,7 @@ void pixz_read(bool verify, size_t nspecs, char **specs) {
wlast = w; wlast = w;
w = w->next; w = w->next;
} }
archive_read_finish(ar); finish_reading(ar);
if (w && w->name) if (w && w->name)
die("File %s missing in archive", w->name); die("File %s missing in archive", w->name);
tar_write_last(); // write whatever's left tar_write_last(); // write whatever's left
@ -669,12 +669,12 @@ static ssize_t tar_read(struct archive *ar, void *ref, const void **bufp) {
static bool taste_tar(io_block_t *ib) { static bool taste_tar(io_block_t *ib) {
struct archive *ar = archive_read_new(); struct archive *ar = archive_read_new();
archive_read_support_compression_none(ar); prevent_compression(ar);
archive_read_support_format_tar(ar); archive_read_support_format_tar(ar);
archive_read_open_memory(ar, ib->output, ib->outsize); archive_read_open_memory(ar, ib->output, ib->outsize);
struct archive_entry *entry; struct archive_entry *entry;
bool ok = (archive_read_next_header(ar, &entry) == ARCHIVE_OK); bool ok = (archive_read_next_header(ar, &entry) == ARCHIVE_OK);
archive_read_finish(ar); finish_reading(ar);
return ok; return ok;
} }

@ -135,7 +135,7 @@ static void read_thread() {
if (gTar) { if (gTar) {
struct archive *ar = archive_read_new(); struct archive *ar = archive_read_new();
archive_read_support_compression_none(ar); prevent_compression(ar);
archive_read_support_format_tar(ar); archive_read_support_format_tar(ar);
archive_read_support_format_raw(ar); archive_read_support_format_raw(ar);
archive_read_open(ar, NULL, tar_ok, tar_read, tar_ok); archive_read_open(ar, NULL, tar_ok, tar_read, tar_ok);
@ -159,7 +159,7 @@ static void read_thread() {
} }
if (archive_read_header_position(ar) == 0) if (archive_read_header_position(ar) == 0)
gTar = false; // probably spuriously identified as tar gTar = false; // probably spuriously identified as tar
archive_read_finish(ar); finish_reading(ar);
} }
if (!feof(gInFile)) { if (!feof(gInFile)) {
const void *dummy; const void *dummy;

Loading…
Cancel
Save