that they both do the same thing. Remove archive_read_consume().
Rename the core "advance_file_pointer" function to make it a little
more clear that it's internal to archive_read.c.
Clean up a few comments.
SVN-Revision: 2047
static const char *_archive_filter_name(struct archive *, int);
static int _archive_read_close(struct archive *);
static int _archive_read_free(struct archive *);
-static int64_t _archive_read_filter_skip(struct archive_read_filter *, int64_t);
+static int64_t advance_file_pointer(struct archive_read_filter *, int64_t);
static struct archive_vtable *
archive_read_vtable(void)
* Move the file pointer forward.
*/
int64_t
-__archive_read_consume(struct archive_read *a, size_t request)
+__archive_read_consume(struct archive_read *a, int64_t request)
{
return (__archive_read_filter_consume(a->filter, request));
}
__archive_read_filter_consume(struct archive_read_filter * filter,
int64_t request)
{
- int64_t skipped = _archive_read_filter_skip(filter, request);
+ int64_t skipped = advance_file_pointer(filter, request);
if (skipped == request)
return (skipped);
/* We hit EOF before we satisfied the skip request. */
}
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)
+__archive_read_consume_all(struct archive_read *a)
{
int64_t total_bytes_skipped = 0;
off_t bytes_skipped;
int64_t request = 1024 * 1024 * 1024UL; /* Skip 1 GB at a time. */
for (;;) {
- bytes_skipped = _archive_read_filter_skip(a->filter, request);
+ bytes_skipped = advance_file_pointer(a->filter, request);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
total_bytes_skipped += bytes_skipped;
}
}
-
+/*
+ * Advance the file pointer by the amount requested.
+ * Returns the amount actually advanced, which may be less than the
+ * request if EOF is encountered first.
+ * Returns a negative value if there's an I/O error.
+ */
static int64_t
-_archive_read_filter_skip(struct archive_read_filter *filter, int64_t request)
+advance_file_pointer(struct archive_read_filter *filter, int64_t request)
{
int64_t bytes_skipped, total_bytes_skipped = 0;
ssize_t bytes_read;
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 *);
-int64_t __archive_read_consume(struct archive_read *, size_t);
+int64_t __archive_read_consume(struct archive_read *, int64_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 *);
+int64_t __archive_read_consume_all(struct archive_read *);
int __archive_read_program(struct archive_read_filter *, const char *);
#endif
ar = (struct ar *)(a->format->data);
- bytes_skipped = __archive_read_skip(a,
+ bytes_skipped = __archive_read_consume(a,
ar->entry_bytes_remaining + ar->entry_padding);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
int64_t skipsize;
skipsize = parent->offset - iso9660->current_position;
- skipsize = __archive_read_skip(a, skipsize);
+ skipsize = __archive_read_consume(a, skipsize);
if (skipsize < 0)
return ((int)skipsize);
iso9660->current_position = parent->offset;
vd = &(iso9660->joliet);
skipsize = LOGICAL_BLOCK_SIZE * vd->location;
- skipsize = __archive_read_skip(a, skipsize);
+ skipsize = __archive_read_consume(a, skipsize);
if (skipsize < 0)
return ((int)skipsize);
iso9660->current_position = skipsize;
vd = &(iso9660->joliet);
skipsize = LOGICAL_BLOCK_SIZE * vd->location;
skipsize -= iso9660->current_position;
- skipsize = __archive_read_skip(a, skipsize);
+ skipsize = __archive_read_consume(a, skipsize);
if (skipsize < 0)
return ((int)skipsize);
iso9660->current_position += skipsize;
step = iso9660->entry_content->offset -
iso9660->current_position;
- step = __archive_read_skip(a, step);
+ step = __archive_read_consume(a, step);
if (step < 0)
return ((int)step);
iso9660->current_position =
int64_t step;
step = file->offset - iso9660->current_position;
- step = __archive_read_skip(a, step);
+ step = __archive_read_consume(a, step);
if (step < 0)
return ((int)step);
iso9660->current_position = file->offset;
if (info->end_of_file)
return (ARCHIVE_EOF);
info->end_of_file = 1;
- skipped = __archive_read_skip_all(a);
+ skipped = __archive_read_consume_all(a);
if (skipped < 0)
return ((int)skipped);
return (ARCHIVE_OK);
/* If we're at end of file, return EOF. */
if (tar->sparse_list == NULL || tar->entry_bytes_remaining == 0) {
- if (__archive_read_skip(a, tar->entry_padding) < 0)
+ if (__archive_read_consume(a, tar->entry_padding) < 0)
return (ARCHIVE_FATAL);
tar->entry_padding = 0;
*buff = NULL;
tar = (struct tar *)(a->format->data);
- /*
- * Compression layer skip functions are required to either skip the
- * length requested or fail, so we can rely upon the entire entry
- * plus padding being skipped.
- */
- bytes_skipped = __archive_read_skip(a,
+ bytes_skipped = __archive_read_consume(a,
tar->entry_bytes_remaining + tar->entry_padding);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
/* Skip rest of block... */
bytes_read = tar->entry_bytes_remaining - remaining;
to_skip = 0x1ff & -bytes_read;
- if (to_skip != __archive_read_skip(a, to_skip))
+ if (to_skip != __archive_read_consume(a, to_skip))
return (ARCHIVE_FATAL);
return (bytes_read + to_skip);
}
xar = (struct xar *)(a->format->data);
if (xar->end_of_file)
return (ARCHIVE_EOF);
- bytes_skipped = __archive_read_skip(a, xar->entry_remaining);
+ bytes_skipped = __archive_read_consume(a, xar->entry_remaining);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
xar->offset += bytes_skipped;
step = offset - (xar->offset - xar->h_base);
if (step > 0) {
- step = __archive_read_skip(a, step);
+ step = __archive_read_consume(a, step);
if (step < 0)
return ((int)step);
xar->offset += step;
* If the length is at the beginning, we can skip the
* compressed data much more quickly.
*/
- bytes_skipped = __archive_read_skip(a, zip->entry_bytes_remaining);
+ bytes_skipped = __archive_read_consume(a, zip->entry_bytes_remaining);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);