summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2006-07-30 00:29:01 +0000
committerkientzle <kientzle@FreeBSD.org>2006-07-30 00:29:01 +0000
commitf501dbec5fe3a8ec80a115b83f7f07e2671bfc95 (patch)
tree7a38c3d6e84fc5da7d1e72df478099c6b6a417f6 /lib/libarchive/archive_read.c
parent61dd143cfb0a5bd3bf9dc7304f3f4126ae2e5acd (diff)
downloadFreeBSD-src-f501dbec5fe3a8ec80a115b83f7f07e2671bfc95.zip
FreeBSD-src-f501dbec5fe3a8ec80a115b83f7f07e2671bfc95.tar.gz
Use 'skip' when ignoring data in tar archives. This dramatically
increases performance when extracting a single entry from a large uncompressed archive, especially on slow devices such as USB hard drives. Requires a number of changes: * New archive_read_open2() supports a 'skip' client function * Old archive_read_open() is implemented as a wrapper now, to continue supporting the old API/ABI. * _read_open_fd and _read_open_file sprout new 'skip' functions. * compression layer gets a new 'skip' operation. * compression_none passes skip requests through to client. * compression_{gzip,bzip2,compress} simply ignore skip requests. Thanks to: Benjamin Lutz, who designed and implemented the whole thing. I'm just committing it. ;-) TODO: Need to update the documentation a little bit.
Diffstat (limited to 'lib/libarchive/archive_read.c')
-rw-r--r--lib/libarchive/archive_read.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c
index c6e47e1..46ccb59 100644
--- a/lib/libarchive/archive_read.c
+++ b/lib/libarchive/archive_read.c
@@ -110,6 +110,19 @@ archive_read_open(struct archive *a, void *client_data,
archive_open_callback *client_opener, archive_read_callback *client_reader,
archive_close_callback *client_closer)
{
+ /* Old archive_read_open() is just a thin shell around
+ * archive_read_open2. */
+ return archive_read_open2(a, client_data, client_opener,
+ client_reader, NULL, client_closer);
+}
+
+int
+archive_read_open2(struct archive *a, void *client_data,
+ archive_open_callback *client_opener,
+ archive_read_callback *client_reader,
+ archive_skip_callback *client_skipper,
+ archive_close_callback *client_closer)
+{
const void *buffer;
ssize_t bytes_read;
int high_bidder;
@@ -129,6 +142,7 @@ archive_read_open(struct archive *a, void *client_data,
*/
a->client_opener = NULL;
a->client_reader = NULL;
+ a->client_skipper = NULL;
a->client_closer = NULL;
a->client_data = NULL;
@@ -167,6 +181,7 @@ archive_read_open(struct archive *a, void *client_data,
/* Now that the client callbacks have worked, remember them. */
a->client_opener = client_opener; /* Do we need to remember this? */
a->client_reader = client_reader;
+ a->client_skipper = client_skipper;
a->client_closer = client_closer;
a->client_data = client_data;
OpenPOWER on IntegriCloud