diff options
author | kientzle <kientzle@FreeBSD.org> | 2008-02-27 06:05:59 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2008-02-27 06:05:59 +0000 |
commit | 13c4f20c016c9228af5c2deb46a089d0d6d44acf (patch) | |
tree | 347a3b5deee8d34e4e34abcc0d0e0169108c6cdb | |
parent | e043fbfcdef275f645d6adf3820734fe0532f487 (diff) | |
download | FreeBSD-src-13c4f20c016c9228af5c2deb46a089d0d6d44acf.zip FreeBSD-src-13c4f20c016c9228af5c2deb46a089d0d6d44acf.tar.gz |
Optimize skipping over Zip entries.
Thanks to: Dan Nelson, who sent me the patch
MFC after: 7 days
-rw-r--r-- | lib/libarchive/archive_read_support_format_zip.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/lib/libarchive/archive_read_support_format_zip.c b/lib/libarchive/archive_read_support_format_zip.c index 0fc0525..f18c3c2 100644 --- a/lib/libarchive/archive_read_support_format_zip.c +++ b/lib/libarchive/archive_read_support_format_zip.c @@ -636,7 +636,7 @@ archive_read_format_zip_read_data_skip(struct archive_read *a) { struct zip *zip; const void *buff = NULL; - ssize_t bytes_avail; + off_t bytes_skipped; zip = (struct zip *)(a->format->data); @@ -659,19 +659,10 @@ archive_read_format_zip_read_data_skip(struct archive_read *a) * If the length is at the beginning, we can skip the * compressed data much more quickly. */ - while (zip->entry_bytes_remaining > 0) { - bytes_avail = (a->decompressor->read_ahead)(a, &buff, 1); - if (bytes_avail <= 0) { - archive_set_error(&a->archive, - ARCHIVE_ERRNO_FILE_FORMAT, - "Truncated ZIP file body"); - return (ARCHIVE_FATAL); - } - if (bytes_avail > zip->entry_bytes_remaining) - bytes_avail = zip->entry_bytes_remaining; - (a->decompressor->consume)(a, bytes_avail); - zip->entry_bytes_remaining -= bytes_avail; - } + bytes_skipped = (a->decompressor->skip)(a, zip->entry_bytes_remaining); + if (bytes_skipped < 0) + return (ARCHIVE_FATAL); + /* This entry is finished and done. */ zip->end_of_entry_cleanup = zip->end_of_entry = 1; return (ARCHIVE_OK); |