blob: b0f5f3ed1336a783e62c22c4333da8e7c2412061 [file] [log] [blame]
Thomas Klausnerd0147e92004-11-17 21:55:17 +00001.\" $NiH: zip_open.mdoc,v 1.15 2003/12/28 00:51:51 wiz Exp $
Dieter Baron90288262003-10-01 18:28:10 +00002.\"
Dieter Baronbb1453e2003-10-02 14:20:53 +00003.\" zip_open.mdoc -- open zip archive
4.\" Copyright (C) 2003 Dieter Baron and Thomas Klausner
5.\"
6.\" This file is part of libzip, a library to manipulate ZIP archives.
Dieter Baron90288262003-10-01 18:28:10 +00007.\" The authors can be contacted at <nih@giga.or.at>
8.\"
Dieter Baronbb1453e2003-10-02 14:20:53 +00009.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\" 3. The names of the authors may not be used to endorse or promote
19.\" products derived from this software without specific prior
20.\" written permission.
Thomas Klausnere9faec42003-10-02 15:52:56 +000021.\"
Dieter Baronbb1453e2003-10-02 14:20:53 +000022.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
23.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
26.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
28.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
30.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
32.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33.\"
Thomas Klausnerc2995a52003-12-27 22:37:34 +000034.Dd December 27, 2003
Dieter Baron90288262003-10-01 18:28:10 +000035.Dt ZIP_OPEN 3
36.Os
37.Sh NAME
38.Nm zip_open
39.Nd open zip archive
40.Sh LIBRARY
Dieter Baronff551f12003-10-03 12:04:09 +000041libzip (-lzip)
Dieter Baron90288262003-10-01 18:28:10 +000042.Sh SYNOPSIS
Thomas Klausner680c87b2003-10-02 15:32:02 +000043.In zip.h
Dieter Baron90288262003-10-01 18:28:10 +000044.Ft struct zip *
Dieter Baron321bc802003-10-06 16:36:54 +000045.Fn zip_open "const char *path" "int flags" "int *errorp"
Dieter Baron90288262003-10-01 18:28:10 +000046.Sh DESCRIPTION
Thomas Klausnere9faec42003-10-02 15:52:56 +000047The zip archive specified by
48.Ar path
49is opened and a pointer to a
Dieter Baron214922d2003-10-02 15:48:47 +000050.\" XXX: also marks up ,
51.Ft struct zip ,
Dieter Baron7c43a822003-10-02 16:00:55 +000052used to manipulate the archive, is returned.
Dieter Barondd9afca2003-10-02 14:13:37 +000053The
54.Fa flags
55are specified by
Thomas Klausner680c87b2003-10-02 15:32:02 +000056.Em or Ns No 'ing
Dieter Barondd9afca2003-10-02 14:13:37 +000057the following values, or 0 for none of them.
58.Bl -tag -offset indent -width ZIP_CHECKCONS
59.It Dv ZIP_CREATE
60Create the archive if it does not exist.
61.It Dv ZIP_EXCL
62Error if archive already exists.
63.It Dv ZIP_CHECKCONS
64Perform additional consistency checks on the archive, and error if
65they fail.
Thomas Klausnerb9148ee2003-12-28 00:51:51 +000066.El
Thomas Klausner81225ec2003-10-06 17:02:07 +000067.Pp
68If an error occurs and
Dieter Baron321bc802003-10-06 16:36:54 +000069.Ar errorp
70is non-NULL, it will be set to the corresponding error code.
Dieter Baron90288262003-10-01 18:28:10 +000071.Sh RETURN VALUES
72Upon successful completion
Dieter Barondd9afca2003-10-02 14:13:37 +000073.Fn zip_open
Dieter Baron90288262003-10-01 18:28:10 +000074returns a
Thomas Klausner680c87b2003-10-02 15:32:02 +000075.Ft struct zip
Dieter Baron90288262003-10-01 18:28:10 +000076pointer.
77Otherwise,
78.Dv NULL
Dieter Baron321bc802003-10-06 16:36:54 +000079is returned and
80.Ar *errorp
Dieter Baron90288262003-10-01 18:28:10 +000081is set to indicate the error.
Dieter Baron214922d2003-10-02 15:48:47 +000082.Sh ERRORS
Dieter Baron99d31972003-10-07 11:54:17 +000083The archive specified by
84.Ar path
85is opened unless:
Dieter Baron214922d2003-10-02 15:48:47 +000086.Bl -tag -width Er
Thomas Klausnerd0147e92004-11-17 21:55:17 +000087.It Bq Er ZIP_ER_EXISTS
Dieter Baron99d31972003-10-07 11:54:17 +000088The file specified by
89.Ar path
90exists and
Dieter Baron68d238c2003-10-03 11:19:03 +000091.Dv ZIP_EXCL
92is set.
Thomas Klausnerd0147e92004-11-17 21:55:17 +000093.It Bq Er ZIP_ER_INCONS
Dieter Baron99d31972003-10-07 11:54:17 +000094Inconsistencies were found in the file specified by
Thomas Klausnercdfa8482003-10-09 13:39:08 +000095.Ar path
96and
Dieter Baron321bc802003-10-06 16:36:54 +000097.Dv ZIP_CHECKCONS
98was specified.
Thomas Klausnerd0147e92004-11-17 21:55:17 +000099.It Bq Er ZIP_ER_INVAL
Thomas Klausnere9faec42003-10-02 15:52:56 +0000100The
Dieter Baron214922d2003-10-02 15:48:47 +0000101.Ar path
102argument is
103.Dv NULL .
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000104.It Bq Er ZIP_ER_MEMORY
Dieter Baron214922d2003-10-02 15:48:47 +0000105Required memory could not be allocated.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000106.It Bq Er ZIP_ER_NOENT
Dieter Baron99d31972003-10-07 11:54:17 +0000107The file specified by
108.Ar path
109does not exist and
Dieter Baron214922d2003-10-02 15:48:47 +0000110.Dv ZIP_CREATE
111is not set.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000112.It Bq Er ZIP_ER_NOZIP
Dieter Baron99d31972003-10-07 11:54:17 +0000113The file specified by
114.Ar path
115is not a zip archive.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000116.It Bq Er ZIP_ER_OPEN
Dieter Baron99d31972003-10-07 11:54:17 +0000117The file specified by
118.Ar path
119could not be opened.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000120.It Bq Er ZIP_ER_READ
Dieter Baron214922d2003-10-02 15:48:47 +0000121A read error occurred; see
122.Va errno
123for details.
Thomas Klausnerd0147e92004-11-17 21:55:17 +0000124.It Bq Er ZIP_ER_SEEK
Dieter Baron99d31972003-10-07 11:54:17 +0000125The file specified by
126.Ar path
127does not allow seeks.
Dieter Baron214922d2003-10-02 15:48:47 +0000128.El
129.Sh SEE ALSO
Thomas Klausnerc2995a52003-12-27 22:37:34 +0000130.Xr zip_close 3 ,
131.Xr zip_error_str 3