From: Charles Wilson Date: Wed, 22 Jul 2009 12:01:18 +0000 (-0400) Subject: Merge r1167 (part c) from trunk X-Git-Tag: v2.7.1~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51875521da44c0e858ac214835f61f31e9459ac5;p=thirdparty%2Flibarchive.git Merge r1167 (part c) from trunk Fix a bunch of tests on Visual Studio: * Change off_t to int64_t for a lot of internal vars to support VS 32-bit off_t; since we can't change the external client_skip interface until libarchive 3.0, just limit forward skips until then. libarchive/archive_private.h libarchive/archive_read.c libarchive/archive_read_support_format_tar.c SVN-Revision: 1263 --- diff --git a/libarchive/archive_private.h b/libarchive/archive_private.h index a25dd2274..698ad2258 100644 --- a/libarchive/archive_private.h +++ b/libarchive/archive_private.h @@ -87,9 +87,9 @@ struct archive { const char *compression_name; /* Position in UNCOMPRESSED data stream. */ - off_t file_position; + int64_t file_position; /* Position in COMPRESSED data stream. */ - off_t raw_position; + int64_t raw_position; int archive_error_number; const char *error; diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c index 7c48b025f..e88b90f4a 100644 --- a/libarchive/archive_read.c +++ b/libarchive/archive_read.c @@ -242,13 +242,26 @@ client_read_proxy(struct archive_read_filter *self, const void **buff) static int64_t client_skip_proxy(struct archive_read_filter *self, int64_t request) { - int64_t r; + int64_t ask, get, total; + /* Limit our maximum seek request to 1GB on platforms + * with 32-bit off_t (such as Windows). */ + int64_t skip_limit = ((int64_t)1) << (sizeof(off_t) * 8 - 2); + if (self->archive->client.skipper == NULL) return (0); - r = (self->archive->client.skipper)(&self->archive->archive, - self->data, request); - self->archive->archive.raw_position += r; - return (r); + total = 0; + for (;;) { + ask = request; + if (ask > skip_limit) + ask = skip_limit; + get = (self->archive->client.skipper)(&self->archive->archive, + self->data, ask); + if (get == 0) + return (total); + request -= get; + self->archive->archive.raw_position += get; + total += get; + } } static int @@ -1119,7 +1132,7 @@ __archive_read_skip(struct archive_read *a, int64_t request) int64_t __archive_read_filter_skip(struct archive_read_filter *filter, int64_t request) { - off_t bytes_skipped, total_bytes_skipped = 0; + int64_t bytes_skipped, total_bytes_skipped = 0; size_t min; if (filter->fatal) @@ -1134,7 +1147,7 @@ __archive_read_filter_skip(struct archive_read_filter *filter, int64_t request) total_bytes_skipped += bytes_skipped; } if (filter->client_avail > 0) { - min = minimum(request, (off_t)filter->client_avail); + min = minimum(request, (int64_t)filter->client_avail); bytes_skipped = __archive_read_consume(filter->archive, min); request -= bytes_skipped; total_bytes_skipped += bytes_skipped; diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index 60ad8147e..bc82878d1 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -159,10 +159,10 @@ struct tar { wchar_t *pax_entry; size_t pax_entry_length; int header_recursion_depth; - off_t entry_bytes_remaining; - off_t entry_offset; - off_t entry_padding; - off_t realsize; + int64_t entry_bytes_remaining; + int64_t entry_offset; + int64_t entry_padding; + int64_t realsize; struct sparse_block *sparse_list; struct sparse_block *sparse_last; int64_t sparse_offset; @@ -509,7 +509,7 @@ archive_read_format_tar_read_data(struct archive_read *a, static int archive_read_format_tar_skip(struct archive_read *a) { - off_t bytes_skipped; + int64_t bytes_skipped; struct tar* tar; tar = (struct tar *)(a->format->data);