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_write.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_write.c')
-rw-r--r-- | lib/libarchive/archive_write.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/libarchive/archive_write.c b/lib/libarchive/archive_write.c index eded384..d3dfc26 100644 --- a/lib/libarchive/archive_write.c +++ b/lib/libarchive/archive_write.c @@ -141,14 +141,14 @@ archive_write_open(struct archive *a, void *client_data, /* - * Cleanup and free the archive object. + * Close out the archive. * * Be careful: user might just call write_new and then write_finish. * Don't assume we actually wrote anything or performed any non-trivial * initialization. */ -void -archive_write_finish(struct archive *a) +int +archive_write_close(struct archive *a) { archive_check_magic(a, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_ANY); @@ -164,6 +164,20 @@ archive_write_finish(struct archive *a) if (a->compression_finish != NULL) (a->compression_finish)(a); + a->state = ARCHIVE_STATE_CLOSED; + return (ARCHIVE_OK); +} + +/* + * Destroy the archive structure. + */ +void +archive_write_finish(struct archive *a) +{ + archive_check_magic(a, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_ANY); + if (a->state != ARCHIVE_STATE_CLOSED) + archive_write_close(a); + /* Release various dynamic buffers. */ free((void *)(uintptr_t)(const void *)a->nulls); archive_string_free(&a->error_string); |