1ZIP_CLOSE(3)             BSD Library Functions Manual             ZIP_CLOSE(3)
2

NAME

4     zip_close — close zip archive
5

LIBRARY

7     libzip (-lzip)
8

SYNOPSIS

10     #include <zip.h>
11
12     int
13     zip_close(zip_t *archive);
14

DESCRIPTION

16     The zip_close() function writes any changes made to archive to disk.  If
17     archive contains no files, the file is completely removed (no empty ar‐
18     chive is written), unless the archive flag
19     ZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE is set.  If successful,
20     archive is freed.  Otherwise archive is left unchanged and must still be
21     freed.
22
23     To close and free a zip archive without saving changes, use
24     zip_discard(3).
25
26     Progress updates for GUIs can be implemented using
27     zip_register_progress_callback_with_state(3).  Cancelling the write of an
28     archive during zip_close can be implemented using
29     zip_register_cancel_callback_with_state(3).
30

RETURN VALUES

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

ERRORS

36     zip_close() will fail if:
37
38     [ZIP_ER_EOF]       Unexpected end-of-file found while reading from a
39                        file.
40
41     [ZIP_ER_INTERNAL]  The callback function of an added or replaced file re‐
42                        turned an error but failed to report which.
43
44     [ZIP_ER_INVAL]     The path argument is NULL.
45
46     [ZIP_ER_MEMORY]    Required memory could not be allocated.
47
48     [ZIP_ER_NOZIP]     File is not a zip archive.
49
50     [ZIP_ER_READ]      A file read failed.
51
52     [ZIP_ER_RENAME]    A temporary file could not be renamed to its final
53                        name.
54
55     [ZIP_ER_SEEK]      A file seek failed.
56
57     [ZIP_ER_TMPOPEN]   A temporary file could not be created.
58
59     [ZIP_ER_WRITE]     A file write failed.
60
61     [ZIP_ER_ZLIB]      An error occurred while (de)compressing a stream with
62                        zlib(3).
63     Additionally, any errors returned by the callback function for added or
64     replaced files will be passed back.
65

SEE ALSO

67     libzip(3), zip_discard(3), zip_fdopen(3), zip_get_error(3), zip_open(3),
68     zip_register_cancel_callback_with_state(3),
69     zip_register_progress_callback_with_state(3), zip_set_archive_flag(3),
70     zip_strerror(3)
71

HISTORY

73     zip_close() was added in libzip 0.6.
74

AUTHORS

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

CAVEATS

79     Please note that all indices, zip_stat(3) information and other data
80     about the archive is invalid after zip_close.  When you open the same
81     file again, it will be a completely new zip_t structure.
82
83BSD                            January 23, 2023                            BSD
Impressum