blob: 1f1a5560dbd663bb02abcdbbc8f3dab0673ff728 [file] [log] [blame]
Dieter Baronbb1453e2003-10-02 14:20:53 +00001.\" zip_open.mdoc -- open zip archive
Thomas Klausner89d33182009-02-15 00:53:58 +01002.\" Copyright (C) 2003-2009 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 Klausner89d33182009-02-15 00:53:58 +010032.Dd February 15, 2009
Dieter Baron90288262003-10-01 18:28:10 +000033.Dt ZIP_OPEN 3
34.Os
35.Sh NAME
36.Nm zip_open
37.Nd open zip archive
38.Sh LIBRARY
Dieter Baronff551f12003-10-03 12:04:09 +000039libzip (-lzip)
Dieter Baron90288262003-10-01 18:28:10 +000040.Sh SYNOPSIS
Thomas Klausner680c87b2003-10-02 15:32:02 +000041.In zip.h
Dieter Baron90288262003-10-01 18:28:10 +000042.Ft struct zip *
Dieter Baron321bc802003-10-06 16:36:54 +000043.Fn zip_open "const char *path" "int flags" "int *errorp"
Dieter Baron90288262003-10-01 18:28:10 +000044.Sh DESCRIPTION
Thomas Klausnere9faec42003-10-02 15:52:56 +000045The zip archive specified by
46.Ar path
47is opened and a pointer to a
Dieter Baron214922d2003-10-02 15:48:47 +000048.Ft struct zip ,
Dieter Baron7c43a822003-10-02 16:00:55 +000049used to manipulate the archive, is returned.
Dieter Barondd9afca2003-10-02 14:13:37 +000050The
51.Fa flags
52are specified by
Thomas Klausner680c87b2003-10-02 15:32:02 +000053.Em or Ns No 'ing
Dieter Barondd9afca2003-10-02 14:13:37 +000054the following values, or 0 for none of them.
55.Bl -tag -offset indent -width ZIP_CHECKCONS
56.It Dv ZIP_CREATE
57Create the archive if it does not exist.
58.It Dv ZIP_EXCL
59Error if archive already exists.
60.It Dv ZIP_CHECKCONS
61Perform additional consistency checks on the archive, and error if
62they fail.
Thomas Klausnerb9148ee2003-12-28 00:51:51 +000063.El
Thomas Klausner81225ec2003-10-06 17:02:07 +000064.Pp
65If an error occurs and
Dieter Baron321bc802003-10-06 16:36:54 +000066.Ar errorp
67is non-NULL, it will be set to the corresponding error code.
Dieter Baron90288262003-10-01 18:28:10 +000068.Sh RETURN VALUES
69Upon successful completion
Dieter Barondd9afca2003-10-02 14:13:37 +000070.Fn zip_open
Dieter Baron90288262003-10-01 18:28:10 +000071returns a
Thomas Klausner680c87b2003-10-02 15:32:02 +000072.Ft struct zip
Dieter Baron90288262003-10-01 18:28:10 +000073pointer.
74Otherwise,
75.Dv NULL
Dieter Baron321bc802003-10-06 16:36:54 +000076is returned and
77.Ar *errorp
Dieter Baron90288262003-10-01 18:28:10 +000078is set to indicate the error.
Dieter Baron214922d2003-10-02 15:48:47 +000079.Sh ERRORS
Dieter Baron99d31972003-10-07 11:54:17 +000080The archive specified by
81.Ar path
82is opened unless:
Dieter Baron214922d2003-10-02 15:48:47 +000083.Bl -tag -width Er
Thomas Klausnerd0147e92004-11-17 21:55:17 +000084.It Bq Er ZIP_ER_EXISTS
Dieter Baron99d31972003-10-07 11:54:17 +000085The file specified by
86.Ar path
87exists and
Dieter Baron68d238c2003-10-03 11:19:03 +000088.Dv ZIP_EXCL
89is set.
Thomas Klausnerd0147e92004-11-17 21:55:17 +000090.It Bq Er ZIP_ER_INCONS
Dieter Baron99d31972003-10-07 11:54:17 +000091Inconsistencies were found in the file specified by
Thomas Klausnercdfa8482003-10-09 13:39:08 +000092.Ar path
93and
Dieter Baron321bc802003-10-06 16:36:54 +000094.Dv ZIP_CHECKCONS
95was specified.
Thomas Klausnerd0147e92004-11-17 21:55:17 +000096.It Bq Er ZIP_ER_INVAL
Thomas Klausnere9faec42003-10-02 15:52:56 +000097The
Dieter Baron214922d2003-10-02 15:48:47 +000098.Ar path
99argument is
100.Dv NULL .
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000101.It Bq Er ZIP_ER_MEMORY
Dieter Baron214922d2003-10-02 15:48:47 +0000102Required memory could not be allocated.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000103.It Bq Er ZIP_ER_NOENT
Dieter Baron99d31972003-10-07 11:54:17 +0000104The file specified by
105.Ar path
106does not exist and
Dieter Baron214922d2003-10-02 15:48:47 +0000107.Dv ZIP_CREATE
108is not set.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000109.It Bq Er ZIP_ER_NOZIP
Dieter Baron99d31972003-10-07 11:54:17 +0000110The file specified by
111.Ar path
112is not a zip archive.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000113.It Bq Er ZIP_ER_OPEN
Dieter Baron99d31972003-10-07 11:54:17 +0000114The file specified by
115.Ar path
116could not be opened.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000117.It Bq Er ZIP_ER_READ
Dieter Baron214922d2003-10-02 15:48:47 +0000118A read error occurred; see
119.Va errno
120for details.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000121.It Bq Er ZIP_ER_SEEK
Dieter Baron99d31972003-10-07 11:54:17 +0000122The file specified by
123.Ar path
124does not allow seeks.
Dieter Baron214922d2003-10-02 15:48:47 +0000125.El
126.Sh SEE ALSO
Thomas Klausnerbec1cfe2005-06-09 18:50:27 +0000127.Xr libzip 3 ,
Thomas Klausnerc2995a52003-12-27 22:37:34 +0000128.Xr zip_close 3 ,
Thomas Klausner89d33182009-02-15 00:53:58 +0100129.Xr zip_error_to_str 3 ,
130.Xr zip_fdopen 3
Thomas Klausnera456cf52005-06-09 21:13:13 +0000131.Sh AUTHORS
132.An -nosplit
133.An Dieter Baron Aq dillo@giga.or.at
Thomas Klausner39b5f9e2005-06-09 21:14:54 +0000134and
Thomas Klausnera456cf52005-06-09 21:13:13 +0000135.An Thomas Klausner Aq tk@giga.or.at