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

NAME

4     zip_open, zip_open_from_source — open zip archive
5

LIBRARY

7     libzip (-lzip)
8

SYNOPSIS

10     #include <zip.h>
11
12     zip_t *
13     zip_open(const char *path, int flags, int *errorp);
14
15     zip_t *
16     zip_open_from_source(zip_source_t *zs, int flags, zip_error_t *ze);
17

DESCRIPTION

19     The zip_open() function opens the zip archive specified by path and re‐
20     turns a pointer to a struct zip, used to manipulate the archive.  The
21     flags are specified by or'ing the following values, or 0 for none of
22     them.
23
24           ZIP_CHECKCONS  Perform additional stricter consistency checks on
25                          the archive, and error if they fail.
26
27           ZIP_CREATE     Create the archive if it does not exist.
28
29           ZIP_EXCL       Error if archive already exists.
30
31           ZIP_TRUNCATE   If archive exists, ignore its current contents.  In
32                          other words, handle it the same way as an empty ar‐
33                          chive.
34
35           ZIP_RDONLY     Open archive in read-only mode.
36
37     If an error occurs and errorp is non-NULL, it will be set to the corre‐
38     sponding error code.
39
40     The zip_open_from_source() function opens a zip archive encapsulated by
41     the zip_source zs using the provided flags.  In case of error, the
42     zip_error ze is filled in.
43

RETURN VALUES

45     Upon successful completion zip_open() and zip_open_from_source() return a
46     struct zip pointer.  Otherwise, NULL is returned and zip_open() sets
47     *errorp to indicate the error, while zip_open_from(source) sets ze to in‐
48     dicate the error.
49

ERRORS

51     The archive specified by path is opened unless:
52
53     [ZIP_ER_EXISTS]    The file specified by path exists and ZIP_EXCL is set.
54
55     [ZIP_ER_INCONS]    Inconsistencies were found in the file specified by
56                        path.  This error is often caused by specifying
57                        ZIP_CHECKCONS but can also happen without it.
58
59     [ZIP_ER_INVAL]     The path argument is NULL.
60
61     [ZIP_ER_MEMORY]    Required memory could not be allocated.
62
63     [ZIP_ER_NOENT]     The file specified by path does not exist and
64                        ZIP_CREATE is not set.
65
66     [ZIP_ER_NOZIP]     The file specified by path is not a zip archive.
67
68     [ZIP_ER_OPEN]      The file specified by path could not be opened.
69
70     [ZIP_ER_READ]      A read error occurred; see errno for details.
71
72     [ZIP_ER_SEEK]      The file specified by path does not allow seeks.
73     For newly created archives, zip_open() does not try to create the file;
74     this is done when calling zip_close(3) and any errors, like missing write
75     permissions, will be reported then.
76

SEE ALSO

78     libzip(3), zip_close(3), zip_error_strerror(3), zip_fdopen(3)
79

HISTORY

81     zip_open() and zip_open_from_source() were added in libzip 1.0.
82

AUTHORS

84     Dieter Baron <dillo@nih.at> and Thomas Klausner <tk@giga.or.at>
85
86BSD                              June 18, 2022                             BSD
Impressum