1ZIP_CLOSE(3) BSD Library Functions Manual ZIP_CLOSE(3)
2
4 zip_close — close zip archive
5
7 libzip (-lzip)
8
10 #include <zip.h>
11
12 int
13 zip_close(zip_t *archive);
14
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). If successful, archive is freed. Otherwise archive
19 is left unchanged and must still be freed.
20
21 To close and free a zip archive without saving changes, use
22 zip_discard(3).
23
24 Progress updates for GUIs can be implemented using
25 zip_register_progress_callback_with_state(3). Cancelling the write of an
26 archive during zip_close can be implemented using
27 zip_register_cancel_callback_with_state(3).
28
30 Upon successful completion 0 is returned. Otherwise, -1 is returned and
31 the error code in archive is set to indicate the error.
32
34 zip_close() will fail if:
35
36 [ZIP_ER_EOF] Unexpected end-of-file found while reading from a
37 file.
38
39 [ZIP_ER_INTERNAL] The callback function of an added or replaced file re‐
40 turned an error but failed to report which.
41
42 [ZIP_ER_INVAL] The path argument is NULL.
43
44 [ZIP_ER_MEMORY] Required memory could not be allocated.
45
46 [ZIP_ER_NOZIP] File is not a zip archive.
47
48 [ZIP_ER_READ] A file read failed.
49
50 [ZIP_ER_RENAME] A temporary file could not be renamed to its final
51 name.
52
53 [ZIP_ER_SEEK] A file seek failed.
54
55 [ZIP_ER_TMPOPEN] A temporary file could not be created.
56
57 [ZIP_ER_WRITE] A file write failed.
58
59 [ZIP_ER_ZLIB] An error occurred while (de)compressing a stream with
60 zlib(3).
61 Additionally, any errors returned by the callback function for added or
62 replaced files will be passed back.
63
65 libzip(3), zip_discard(3), zip_fdopen(3), zip_get_error(3), zip_open(3),
66 zip_register_cancel_callback_with_state(3),
67 zip_register_progress_callback_with_state(3), zip_strerror(3)
68
70 zip_close() was added in libzip 0.6.
71
73 Dieter Baron <dillo@nih.at> and Thomas Klausner <tk@giga.or.at>
74
76 Please note that all indices, zip_stat(3) information and other data
77 about the archive is invalid after zip_close. When you open the same
78 file again, it will be a completely new zip_t structure.
79
80BSD April 1, 2022 BSD