/* * 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) { int64_t skipped = __archive_read_skip_lenient(a, 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_ERRNO_MISC, "Truncated input file (needed %jd bytes, only %jd available)", (intmax_t)request, (intmax_t)skipped); return (ARCHIVE_FATAL); }
static int tk_archive_read_format_raw_read_data_skip(struct archive_read *a) { struct raw_info *info; off_t bytes_skipped; int64_t request = 1024 * 1024 * 1024UL; /* Skip 1 GB at a time. */ info = (struct raw_info *)(a->format->data); if (info->end_of_file) return (ARCHIVE_EOF); info->end_of_file = 1; for (;;) { bytes_skipped = __archive_read_skip_lenient(a, request); if (bytes_skipped < 0) return (ARCHIVE_FATAL); if (bytes_skipped < request) return (ARCHIVE_OK); /* We skipped all the bytes we asked for. There might * be more, so try again. */ } }