1ZIP_ADD(3) Library Functions Manual ZIP_ADD(3)
2
3
4
6 zip_add , - .Nm zip_replace add file to zip archive or replace file in
7 zip archive
8
10 libzip (-lzip)
11
13 #include <zip.h>
14
15 zip_int64_t zip_add(struct zip *archive, const char *name); "struct
16 zip_source *source"
17
18 int zip_replace(struct zip *archive, zip_uint64_t index); "struct
19 zip_source *source"
20
22 The function zip_add adds a file to a zip archive, while zip_replace
23 replaces an existing file in a zip archive. The argument archive spec‐
24 ifies the zip archive to which the file should be added. name is the
25 file's name in the zip archive (for zip_add ), while index specifies
26 which file should be replaced (for zip_replace ). The data is obtained
27 from the source argument. See the zip_source_* functions cited in SEE
28 ALSO.
29
31 Upon successful completion, zip_add returns the index of the new file
32 in the archive, and zip_replace returns 0. Otherwise, -1 is returned
33 and the error code in archive is set to indicate the error.
34
36 struct zip_source *s;
37
38 if ((s=zip_source_buffer(archive, buffer, len)) == NULL ||
39 zip_add(archive, name, s) 0) {
40 zip_source_free(s);
41 printf("error adding file: %s0, zip_strerror(archive)); }
42
44 zip_add and zip_replace fail if:
45
46 [ZIP_ER_EXISTS]
47 There is already a file called name in the archive. (Only
48 applies to zip_add ).
49
50 [ZIP_ER_INVAL]
51 source or name are NULL, or index is invalid.
52
53 [ZIP_ER_MEMORY]
54 Required memory could not be allocated.
55
57 libzip(3), zip_source_file(3), zip_source_filep(3), zip_source_func‐
58 tion(3), zip_source_zip(3)
59
61 Dieter Baron <dillo@giga.or.at> and Thomas Klausner <tk@giga.or.at>
62
63
64
65NiH March 10, 2009 ZIP_ADD(3)