]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Merge r1167 (part c) from trunk
authorCharles Wilson <cwilso11@gmail.com>
Wed, 22 Jul 2009 12:01:18 +0000 (08:01 -0400)
committerCharles Wilson <cwilso11@gmail.com>
Wed, 22 Jul 2009 12:01:18 +0000 (08:01 -0400)
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

libarchive/archive_private.h
libarchive/archive_read.c
libarchive/archive_read_support_format_tar.c

index a25dd227468d0097ba4d115a95b97d339e847fba..698ad2258c35a98706149fb92472dd64877872ac 100644 (file)
@@ -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;
index 7c48b025f30966d867be93dfb6aff079c012cf27..e88b90f4a8704740920ccf4bff70a8f2b7677961 100644 (file)
@@ -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;
index 60ad8147ee923f4f8403c4b0699ec54368f5e931..bc82878d18f3b3c056d31187d9c19693d45662e0 100644 (file)
@@ -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);