blob: c7df3557cd11159b2eb23e7e694f1dc86d99420e [file] [log] [blame]
Dieter Baronbb1453e2003-10-02 14:20:53 +00001.\" zip_open.mdoc -- open zip archive
Thomas Klausnerea8ba492014-09-23 16:54:47 +02002.\" Copyright (C) 2003-2014 Dieter Baron and Thomas Klausner
Dieter Baronbb1453e2003-10-02 14:20:53 +00003.\"
4.\" This file is part of libzip, a library to manipulate ZIP archives.
Dieter Baronb86c4332007-11-07 14:35:13 +01005.\" The authors can be contacted at <libzip@nih.at>
Dieter Baron90288262003-10-01 18:28:10 +00006.\"
Dieter Baronbb1453e2003-10-02 14:20:53 +00007.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in
14.\" the documentation and/or other materials provided with the
15.\" distribution.
16.\" 3. The names of the authors may not be used to endorse or promote
17.\" products derived from this software without specific prior
18.\" written permission.
Thomas Klausnere9faec42003-10-02 15:52:56 +000019.\"
Dieter Baronbb1453e2003-10-02 14:20:53 +000020.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
21.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
24.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
26.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
28.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
30.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31.\"
Thomas Klausner23051812014-11-09 18:14:18 +010032.Dd November 9, 2014
Dieter Baron90288262003-10-01 18:28:10 +000033.Dt ZIP_OPEN 3
34.Os
35.Sh NAME
Thomas Klausner23051812014-11-09 18:14:18 +010036.Nm zip_open ,
37.Nm zip_open_from_source
Dieter Baron90288262003-10-01 18:28:10 +000038.Nd open zip archive
39.Sh LIBRARY
Dieter Baronff551f12003-10-03 12:04:09 +000040libzip (-lzip)
Dieter Baron90288262003-10-01 18:28:10 +000041.Sh SYNOPSIS
Thomas Klausner680c87b2003-10-02 15:32:02 +000042.In zip.h
Dieter Baron1d9dfeb2014-09-28 23:02:54 +020043.Ft zip_t *
Dieter Baron321bc802003-10-06 16:36:54 +000044.Fn zip_open "const char *path" "int flags" "int *errorp"
Thomas Klausner23051812014-11-09 18:14:18 +010045.Ft zip_t *
46.Fn zip_open_from_source "zip_source_t *zs" "int flags" "zip_error_t *ze"
Dieter Baron90288262003-10-01 18:28:10 +000047.Sh DESCRIPTION
Thomas Klausner23051812014-11-09 18:14:18 +010048The
49.Fn zip_open
50function opens the zip archive specified by
Thomas Klausnere9faec42003-10-02 15:52:56 +000051.Ar path
Thomas Klausner23051812014-11-09 18:14:18 +010052and returns a pointer to a
Dieter Baron214922d2003-10-02 15:48:47 +000053.Ft struct zip ,
Thomas Klausner23051812014-11-09 18:14:18 +010054used to manipulate the archive.
Dieter Barondd9afca2003-10-02 14:13:37 +000055The
56.Fa flags
57are specified by
Thomas Klausner680c87b2003-10-02 15:32:02 +000058.Em or Ns No 'ing
Dieter Barondd9afca2003-10-02 14:13:37 +000059the following values, or 0 for none of them.
60.Bl -tag -offset indent -width ZIP_CHECKCONS
Thomas Klausner05f950f2012-02-13 23:11:35 +010061.It Dv ZIP_CHECKCONS
62Perform additional stricter consistency checks on the archive, and
63error if they fail.
Dieter Barondd9afca2003-10-02 14:13:37 +000064.It Dv ZIP_CREATE
65Create the archive if it does not exist.
66.It Dv ZIP_EXCL
67Error if archive already exists.
Thomas Klausner05f950f2012-02-13 23:11:35 +010068.It Dv ZIP_TRUNCATE
69If archive exists, ignore its current contents.
70In other words, handle it the same way as an empty archive.
Thomas Klausnerea8ba492014-09-23 16:54:47 +020071.It Dv ZIP_RDONLY
72Open archive in read-only mode.
Thomas Klausnerb9148ee2003-12-28 00:51:51 +000073.El
Thomas Klausner81225ec2003-10-06 17:02:07 +000074.Pp
75If an error occurs and
Dieter Baron321bc802003-10-06 16:36:54 +000076.Ar errorp
Thomas Klausner23051812014-11-09 18:14:18 +010077is
78.Pf non- Dv NULL ,
79it will be set to the corresponding error code.
80.Pp
81The
82.Fn zip_open_from_source
83function opens a zip archive encapsulated by the zip_source
84.Fa zs
85using the provided
86.Fa flags .
87In case of error, the zip_error
88.Fa ze
89is filled in.
Dieter Baron90288262003-10-01 18:28:10 +000090.Sh RETURN VALUES
91Upon successful completion
Dieter Barondd9afca2003-10-02 14:13:37 +000092.Fn zip_open
Thomas Klausner23051812014-11-09 18:14:18 +010093and
94.Fn zip_open_from_source
95return a
Thomas Klausner680c87b2003-10-02 15:32:02 +000096.Ft struct zip
Dieter Baron90288262003-10-01 18:28:10 +000097pointer.
98Otherwise,
99.Dv NULL
Dieter Baron321bc802003-10-06 16:36:54 +0000100is returned and
Thomas Klausner23051812014-11-09 18:14:18 +0100101.Fn zip_open
102sets
Dieter Baron321bc802003-10-06 16:36:54 +0000103.Ar *errorp
Thomas Klausner23051812014-11-09 18:14:18 +0100104to indicate the error, while
105.Fn zip_open_from source
106sets
107.Ar ze
108to indicate the error.
Dieter Baron214922d2003-10-02 15:48:47 +0000109.Sh ERRORS
Dieter Baron99d31972003-10-07 11:54:17 +0000110The archive specified by
111.Ar path
112is opened unless:
Dieter Baron214922d2003-10-02 15:48:47 +0000113.Bl -tag -width Er
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000114.It Bq Er ZIP_ER_EXISTS
Dieter Baron99d31972003-10-07 11:54:17 +0000115The file specified by
116.Ar path
117exists and
Dieter Baron68d238c2003-10-03 11:19:03 +0000118.Dv ZIP_EXCL
119is set.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000120.It Bq Er ZIP_ER_INCONS
Dieter Baron99d31972003-10-07 11:54:17 +0000121Inconsistencies were found in the file specified by
Thomas Klausnere373e6b2012-02-13 14:53:55 +0100122.Ar path .
123This error is often caused by specifying
Dieter Baron321bc802003-10-06 16:36:54 +0000124.Dv ZIP_CHECKCONS
Thomas Klausnere373e6b2012-02-13 14:53:55 +0100125but can also happen without it.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000126.It Bq Er ZIP_ER_INVAL
Thomas Klausnere9faec42003-10-02 15:52:56 +0000127The
Dieter Baron214922d2003-10-02 15:48:47 +0000128.Ar path
129argument is
130.Dv NULL .
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000131.It Bq Er ZIP_ER_MEMORY
Dieter Baron214922d2003-10-02 15:48:47 +0000132Required memory could not be allocated.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000133.It Bq Er ZIP_ER_NOENT
Dieter Baron99d31972003-10-07 11:54:17 +0000134The file specified by
135.Ar path
136does not exist and
Dieter Baron214922d2003-10-02 15:48:47 +0000137.Dv ZIP_CREATE
138is not set.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000139.It Bq Er ZIP_ER_NOZIP
Dieter Baron99d31972003-10-07 11:54:17 +0000140The file specified by
141.Ar path
142is not a zip archive.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000143.It Bq Er ZIP_ER_OPEN
Dieter Baron99d31972003-10-07 11:54:17 +0000144The file specified by
145.Ar path
146could not be opened.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000147.It Bq Er ZIP_ER_READ
Dieter Baron214922d2003-10-02 15:48:47 +0000148A read error occurred; see
149.Va errno
150for details.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000151.It Bq Er ZIP_ER_SEEK
Dieter Baron99d31972003-10-07 11:54:17 +0000152The file specified by
153.Ar path
154does not allow seeks.
Dieter Baron214922d2003-10-02 15:48:47 +0000155.El
156.Sh SEE ALSO
Thomas Klausnerbec1cfe2005-06-09 18:50:27 +0000157.Xr libzip 3 ,
Thomas Klausnerc2995a52003-12-27 22:37:34 +0000158.Xr zip_close 3 ,
Thomas Klausner89d33182009-02-15 00:53:58 +0100159.Xr zip_error_to_str 3 ,
160.Xr zip_fdopen 3
Thomas Klausnera456cf52005-06-09 21:13:13 +0000161.Sh AUTHORS
162.An -nosplit
Thomas Klausner0acbab42013-07-28 23:29:08 +0200163.An Dieter Baron Aq Mt dillo@nih.at
Thomas Klausner39b5f9e2005-06-09 21:14:54 +0000164and
Thomas Klausner0acbab42013-07-28 23:29:08 +0200165.An Thomas Klausner Aq Mt tk@giga.or.at