diff options
author | kientzle <kientzle@FreeBSD.org> | 2004-08-07 19:22:50 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2004-08-07 19:22:50 +0000 |
commit | ce43965b8b0a3777d17e84b790b1da388f3da574 (patch) | |
tree | ace20a04007ad2459488721ad147fc08b64bd24c /lib/libarchive/archive_read.c | |
parent | 42609f208c42763fa511ec4e8a440b74bfd3e0d8 (diff) | |
download | FreeBSD-src-ce43965b8b0a3777d17e84b790b1da388f3da574.zip FreeBSD-src-ce43965b8b0a3777d17e84b790b1da388f3da574.tar.gz |
Split archive_{read,write}_finish into separate "close" (finish the archive
and close it) and "finish" (destroy the object) functions. For backwards
compat and simplicity, have "finish" invoke "close" transparently if needed.
This allows clients to close the archive and check end-of-operation
statistics before destroying the object.
Diffstat (limited to 'lib/libarchive/archive_read.c')
-rw-r--r-- | lib/libarchive/archive_read.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c index b68b5a6..2f9a998 100644 --- a/lib/libarchive/archive_read.c +++ b/lib/libarchive/archive_read.c @@ -441,18 +441,15 @@ archive_read_data_block(struct archive *a, } /* - * Cleanup and free the archive object. + * Close the file and release most resources. * * Be careful: client might just call read_new and then read_finish. * Don't assume we actually read anything or performed any non-trivial * initialization. */ -void -archive_read_finish(struct archive *a) +int +archive_read_close(struct archive *a) { - int i; - int slots; - archive_check_magic(a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_ANY); a->state = ARCHIVE_STATE_CLOSED; @@ -465,6 +462,21 @@ archive_read_finish(struct archive *a) /* Close the input machinery. */ if (a->compression_finish != NULL) (a->compression_finish)(a); + return (ARCHIVE_OK); +} + +/* + * Release memory and other resources. + */ +void +archive_read_finish(struct archive *a) +{ + int i; + int slots; + + archive_check_magic(a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_ANY); + if (a->state != ARCHIVE_STATE_CLOSED) + archive_read_close(a); /* Cleanup format-specific data. */ slots = sizeof(a->formats) / sizeof(a->formats[0]); |