Imported Upstream version 1.1.1
[platform/upstream/libzip.git] / man / zip_fopen.man
1 .TH "ZIP_FOPEN" "3" "October 23, 2013" "NiH" "Library Functions Manual"
2 .nh
3 .if n .ad l
4 .SH "NAME"
5 \fBzip_fopen\fR,
6 \fBzip_fopen_index\fR
7 \- open file in zip archive for reading
8 .SH "LIBRARY"
9 libzip (-lzip)
10 .SH "SYNOPSIS"
11 \fB#include <zip.h>\fR
12 .sp
13 \fIzip_file_t *\fR
14 .PD 0
15 .HP 4n
16 \fBzip_fopen\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *fname\fR, \fIzip_flags_t\ flags\fR);
17 .PD
18 .PP
19 \fIzip_file_t *\fR
20 .PD 0
21 .HP 4n
22 \fBzip_fopen_index\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_flags_t\ flags\fR);
23 .PD
24 .SH "DESCRIPTION"
25 The
26 \fBzip_fopen\fR()
27 function opens the file name
28 \fIfname\fR
29 in
30 \fIarchive\fR.
31 The
32 \fIflags\fR
33 argument specifies how the name lookup should be done, according to
34 the values are described in
35 zip_name_locate(3).
36 Also, the following values may be
37 \fIor\fR'ed
38 to it.
39 .RS 6n
40 .TP 19n
41 \fRZIP_FL_COMPRESSED\fR
42 Read the compressed data.
43 Otherwise the data is uncompressed by
44 \fBzip_fread\fR().
45 .TP 19n
46 \fRZIP_FL_UNCHANGED\fR
47 Read the original data from the zip archive, ignoring any changes made
48 to the file.
49 .RE
50 .PP
51 The
52 \fBzip_fopen_index\fR()
53 function opens the file at position
54 \fIindex\fR.
55 .PP
56 If encrypted data is encountered, the functions call
57 zip_fopen_encrypted(3)
58 or
59 zip_fopen_index_encrypted(3)
60 respectively, using the default password set with
61 zip_set_default_password(3).
62 .SH "RETURN VALUES"
63 Upon successful completion, a
64 \fIstruct zip_file\fR
65 pointer is returned.
66 Otherwise,
67 \fRNULL\fR
68 is returned and the error code in
69 \fIarchive\fR
70 is set to indicate the error.
71 .SH "ERRORS"
72 .TP 19n
73 [\fRZIP_ER_CHANGED\fR]
74 The file data has been changed.
75 .TP 19n
76 [\fRZIP_ER_COMPNOTSUPP\fR]
77 The compression method used is not supported.
78 .TP 19n
79 [\fRZIP_ER_ENCRNOTSUPP\fR]
80 The encryption method used is not supported.
81 .TP 19n
82 [\fRZIP_ER_MEMORY\fR]
83 Required memory could not be allocated.
84 .TP 19n
85 [\fRZIP_ER_NOPASSWD\fR]
86 The file is encrypted, but no password has been provided.
87 .TP 19n
88 [\fRZIP_ER_READ\fR]
89 A file read error occurred.
90 .TP 19n
91 [\fRZIP_ER_SEEK\fR]
92 A file seek error occurred.
93 .TP 19n
94 [\fRZIP_ER_WRONGPASSWD\fR]
95 The provided password does not match the password used for encryption.
96 Note that some incorrect passwords are not detected by the check done by
97 \fBzip_fopen\fR().
98 .TP 19n
99 [\fRZIP_ER_ZLIB\fR]
100 Initializing the zlib stream failed.
101 .PP
102 The function
103 \fBzip_fopen\fR()
104 may also fail and set
105 \fIzip_err\fR
106 for any of the errors specified for the routine
107 zip_name_locate(3).
108 .PP
109 The function
110 \fBzip_fopen_index\fR()
111 may also fail with
112 \fRZIP_ER_INVAL\fR
113 if
114 \fIindex\fR
115 is invalid.
116 .SH "SEE ALSO"
117 libzip(3),
118 zip_fclose(3),
119 zip_fread(3),
120 zip_get_num_entries(3),
121 zip_name_locate(3),
122 zip_set_default_password(3)
123 .SH "AUTHORS"
124 Dieter Baron <\fIdillo@nih.at\fR>
125 and
126 Thomas Klausner <\fItk@giga.or.at\fR>