1ZIP_ADD(3)                 Library Functions Manual                 ZIP_ADD(3)
2
3
4

NAME

6       zip_add  , - .Nm zip_replace add file to zip archive or replace file in
7       zip archive
8

LIBRARY

10       libzip (-lzip)
11

SYNOPSIS

13       #include <zip.h>
14
15       int zip_add(struct zip *archive, const char *name); "struct  zip_source
16       *source"
17
18       int  zip_replace(struct  zip  *archive,  int index); "struct zip_source
19       *source"
20

DESCRIPTION

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

RETURN VALUES

31       Upon successful completion, the index of the new file in the archive is
32       returned.   Otherwise,  -1 is returned and the error code in archive is
33       set to indicate the error.
34

EXAMPLES

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

ERRORS

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

SEE ALSO

57       libzip(3),  zip_source_file(3),  zip_source_filep(3),  zip_source_func‐
58       tion(3), zip_source_zip(3)
59

AUTHORS

61       Dieter Baron <dillo@giga.or.at> and Thomas Klausner <tk@giga.or.at>
62
63
64
65NiH                              April 9, 2006                      ZIP_ADD(3)
Impressum