zip_close man page

zip_close — close zip archive


libzip (-lzip)


#include <zip.h>


zip_close(zip_t *archive);


The zip_close() function closes archive and frees the memory allocated for it. If any files within were changed, those changes are written to disk first. If writing changes fails, zip_close() fails and archive is left unchanged. If archive contains no files, the file is completely removed (no empty archive is written).

To close a zip file without saving changes, use zip_discard(3).

Return Values

Upon successful completion 0 is returned. Otherwise, -1 is returned and the error code in archive is set to indicate the error.


zip_close() will fail if:

Unexpected end-of-file found while reading from a file.
The callback function of an added or replaced file returned an error but failed to report which.
The path argument is NULL.
Required memory could not be allocated.
File is not a zip archive.
A file read failed.
A temporary file could not be renamed to its final name.
A file seek failed.
A temporary file could not be created.
A file write failed.
An error occurred while (de)compressing a stream with zlib(3).

Additionally, any errors returned by the callback function for added or replaced files will be passed back.

See Also

libzip(3), zip_discard(3), zip_error_get(3), zip_fdopen(3), zip_open(3), zip_strerror(3)


Dieter Baron <dillo@nih.at> and Thomas Klausner <tk@giga.or.at>

Referenced By

libzip(3), zip_discard(3), zip_fdopen(3), zip_open(3), zip_source(3), zip_source_filep(3).

Explore man page connections for zip_close(3).

NiH February 13, 2012