Imported Upstream version 1.4.0
[platform/upstream/libzip.git] / man / zip_open.man
1 .TH "ZIP_OPEN" "3" "December 18, 2017" "NiH" "Library Functions Manual"
2 .nh
3 .if n .ad l
4 .SH "NAME"
5 \fBzip_open\fR,
6 \fBzip_open_from_source\fR
7 \- open zip archive
8 .SH "LIBRARY"
9 libzip (-lzip)
10 .SH "SYNOPSIS"
11 \fB#include <zip.h>\fR
12 .sp
13 \fIzip_t *\fR
14 .br
15 .PD 0
16 .HP 4n
17 \fBzip_open\fR(\fIconst\ char\ *path\fR, \fIint\ flags\fR, \fIint\ *errorp\fR);
18 .PD
19 .PP
20 \fIzip_t *\fR
21 .br
22 .PD 0
23 .HP 4n
24 \fBzip_open_from_source\fR(\fIzip_source_t\ *zs\fR, \fIint\ flags\fR, \fIzip_error_t\ *ze\fR);
25 .PD
26 .SH "DESCRIPTION"
27 The
28 \fBzip_open\fR()
29 function opens the zip archive specified by
30 \fIpath\fR
31 and returns a pointer to a
32 \fIstruct zip\fR,
33 used to manipulate the archive.
34 The
35 \fIflags\fR
36 are specified by
37 \fIor\fR'ing
38 the following values, or 0 for none of them.
39 .RS 6n
40 .TP 15n
41 \fRZIP_CHECKCONS\fR
42 Perform additional stricter consistency checks on the archive, and
43 error if they fail.
44 .TP 15n
45 \fRZIP_CREATE\fR
46 Create the archive if it does not exist.
47 .TP 15n
48 \fRZIP_EXCL\fR
49 Error if archive already exists.
50 .TP 15n
51 \fRZIP_TRUNCATE\fR
52 If archive exists, ignore its current contents.
53 In other words, handle it the same way as an empty archive.
54 .TP 15n
55 \fRZIP_RDONLY\fR
56 Open archive in read-only mode.
57 .RE
58 .PP
59 If an error occurs and
60 \fIerrorp\fR
61 is
62 non-\fRNULL\fR,
63 it will be set to the corresponding error code.
64 .PP
65 The
66 \fBzip_open_from_source\fR()
67 function opens a zip archive encapsulated by the zip_source
68 \fIzs\fR
69 using the provided
70 \fIflags\fR.
71 In case of error, the zip_error
72 \fIze\fR
73 is filled in.
74 .SH "RETURN VALUES"
75 Upon successful completion
76 \fBzip_open\fR()
77 and
78 \fBzip_open_from_source\fR()
79 return a
80 \fIstruct zip\fR
81 pointer.
82 Otherwise,
83 \fRNULL\fR
84 is returned and
85 \fBzip_open\fR()
86 sets
87 \fI*errorp\fR
88 to indicate the error, while
89 \fBzip_open_from\fR(\fIsource\fR)
90 sets
91 \fIze\fR
92 to indicate the error.
93 .SH "ERRORS"
94 The archive specified by
95 \fIpath\fR
96 is opened unless:
97 .TP 19n
98 [\fRZIP_ER_EXISTS\fR]
99 The file specified by
100 \fIpath\fR
101 exists and
102 \fRZIP_EXCL\fR
103 is set.
104 .TP 19n
105 [\fRZIP_ER_INCONS\fR]
106 Inconsistencies were found in the file specified by
107 \fIpath\fR.
108 This error is often caused by specifying
109 \fRZIP_CHECKCONS\fR
110 but can also happen without it.
111 .TP 19n
112 [\fRZIP_ER_INVAL\fR]
113 The
114 \fIpath\fR
115 argument is
116 \fRNULL\fR.
117 .TP 19n
118 [\fRZIP_ER_MEMORY\fR]
119 Required memory could not be allocated.
120 .TP 19n
121 [\fRZIP_ER_NOENT\fR]
122 The file specified by
123 \fIpath\fR
124 does not exist and
125 \fRZIP_CREATE\fR
126 is not set.
127 .TP 19n
128 [\fRZIP_ER_NOZIP\fR]
129 The file specified by
130 \fIpath\fR
131 is not a zip archive.
132 .TP 19n
133 [\fRZIP_ER_OPEN\fR]
134 The file specified by
135 \fIpath\fR
136 could not be opened.
137 .TP 19n
138 [\fRZIP_ER_READ\fR]
139 A read error occurred; see
140 \fIerrno\fR
141 for details.
142 .TP 19n
143 [\fRZIP_ER_SEEK\fR]
144 The file specified by
145 \fIpath\fR
146 does not allow seeks.
147 .SH "SEE ALSO"
148 libzip(3),
149 zip_close(3),
150 zip_error_to_str(3),
151 zip_fdopen(3)
152 .SH "HISTORY"
153 \fBzip_open\fR()
154 and
155 \fBzip_open_from_source\fR()
156 were added in libzip 1.0.
157 .SH "AUTHORS"
158 Dieter Baron <\fIdillo@nih.at\fR>
159 and
160 Thomas Klausner <\fItk@giga.or.at\fR>