]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Finish merging the archive_read_consume and archive_read_skip implementations.
authorTim Kientzle <kientzle@gmail.com>
Sun, 21 Mar 2010 16:00:28 +0000 (12:00 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sun, 21 Mar 2010 16:00:28 +0000 (12:00 -0400)
These have always been just two different ways to advance the file
pointer; merging them is a simplification.

The only point remaining is to actually remove one of them and
change the users.

SVN-Revision: 2046

libarchive/archive_read.c
libarchive/archive_read_private.h

index f461fe1c69392560e760d5ca9f6c08b36e910098..c6f1f0e0b4198292170ac84aa49103922c3d861c 100644 (file)
@@ -1181,62 +1181,37 @@ __archive_read_filter_ahead(struct archive_read_filter *filter,
 }
 
 /*
- * Move the file pointer forward.  This should be called after
- * __archive_read_ahead() returns data to you.  Don't try to move
- * ahead by more than the amount of data available according to
- * __archive_read_ahead().
+ * Move the file pointer forward.
  */
-/*
- * Mark the appropriate data as used.  Note that the request here will
- * often be much smaller than the size of the previous read_ahead
- * request.
- */
-ssize_t
+int64_t
 __archive_read_consume(struct archive_read *a, size_t request)
 {
        return (__archive_read_filter_consume(a->filter, request));
 }
 
-ssize_t
-__archive_read_filter_consume(struct archive_read_filter * filter,
-    size_t request)
-{
-       if (filter->avail > 0) {
-               /* Read came from copy buffer. */
-               filter->next += request;
-               filter->avail -= request;
-       } else {
-               /* Read came from client buffer. */
-               filter->client_next += request;
-               filter->client_avail -= request;
-       }
-       filter->bytes_consumed += request;
-       return (request);
-}
-
-/*
- * Move the file pointer ahead by an arbitrary amount.  If you're
- * reading uncompressed data from a disk file, this will actually
- * translate into a seek() operation.  Even in cases where seek()
- * isn't feasible, this at least pushes the read-and-discard loop
- * down closer to the data source.
- */
 int64_t
-__archive_read_skip(struct archive_read *a, int64_t request)
+__archive_read_filter_consume(struct archive_read_filter * filter,
+    int64_t request)
 {
-       int64_t skipped = _archive_read_filter_skip(a->filter, request);
+       int64_t skipped = _archive_read_filter_skip(filter, request);
        if (skipped == request)
                return (skipped);
        /* We hit EOF before we satisfied the skip request. */
        if (skipped < 0)  // Map error code to 0 for error message below.
                skipped = 0;
-       archive_set_error(&a->archive,
+       archive_set_error(&filter->archive->archive,
            ARCHIVE_ERRNO_MISC,
            "Truncated input file (needed %jd bytes, only %jd available)",
            (intmax_t)request, (intmax_t)skipped);
        return (ARCHIVE_FATAL);
 }
 
+int64_t
+__archive_read_skip(struct archive_read *a, int64_t request)
+{
+       return (__archive_read_filter_consume(a->filter, request));
+}
+
 int64_t
 __archive_read_skip_all(struct archive_read *a)
 {
index 1d41d59fba7f71e9997fa44de115381b8fd683ae..68873f06d1131d89156dc0c020d82946ab100104 100644 (file)
@@ -208,8 +208,8 @@ struct archive_read_filter_bidder
 const void *__archive_read_ahead(struct archive_read *, size_t, ssize_t *);
 const void *__archive_read_filter_ahead(struct archive_read_filter *,
     size_t, ssize_t *);
-ssize_t        __archive_read_consume(struct archive_read *, size_t);
-ssize_t        __archive_read_filter_consume(struct archive_read_filter *, size_t);
+int64_t        __archive_read_consume(struct archive_read *, size_t);
+int64_t        __archive_read_filter_consume(struct archive_read_filter *, int64_t);
 int64_t        __archive_read_skip(struct archive_read *, int64_t);
 int64_t        __archive_read_skip_all(struct archive_read *);
 int __archive_read_program(struct archive_read_filter *, const char *);