blob: abcbb3919315965992c1848547d699bb74ffe9e5 [file] [log] [blame]
Thomas Klausner7edc9e22004-11-18 16:48:08 +00001.\" zip_source_file.mdoc -- create data source from a file
Thomas Klausner86a346b2014-08-02 12:10:27 +02002.\" Copyright (C) 2004-2014 Dieter Baron and Thomas Klausner
Thomas Klausner7edc9e22004-11-18 16:48:08 +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>
Thomas Klausner7edc9e22004-11-18 16:48:08 +00006.\"
7.\" 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.
19.\"
20.\" 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 Klausner86a346b2014-08-02 12:10:27 +020032.Dd August 2, 2014
Thomas Klausner7edc9e22004-11-18 16:48:08 +000033.Dt ZIP_SOURCE_FILE 3
34.Os
35.Sh NAME
36.Nm zip_source_file
37.Nd create data source from a file
38.Sh LIBRARY
39libzip (-lzip)
40.Sh SYNOPSIS
Dieter Baron1d9dfeb2014-09-28 23:02:54 +020041.Ft zip_source_t *
42.Fn zip_source_file "zip_t *archive" "const char *fname" \
Dieter Baronc65abed2008-08-01 17:04:17 +020043"zip_uint64_t start" "zip_int64_t len"
Thomas Klausner7edc9e22004-11-18 16:48:08 +000044.Sh DESCRIPTION
45The function
46.Fn zip_source_file
47creates a zip source from a file.
Thomas Klausnerc31082f2005-07-15 14:11:16 +000048.Fn zip_source_file
Thomas Klausner7edc9e22004-11-18 16:48:08 +000049opens
50.Ar fname
51and reads
52.Ar len
53bytes from offset
Thomas Klausnere9f5c292004-12-22 16:37:48 +000054.Ar start
Thomas Klausner7edc9e22004-11-18 16:48:08 +000055from it.
56If
57.Ar len
58is 0 or \-1, the whole file (starting from
59.Ar start )
60is used.
Dieter Baronc65abed2008-08-01 17:04:17 +020061.Pp
62The fie is opened and read when the data from the source is used, usually by
63.Fn zip_close .
Thomas Klausner7edc9e22004-11-18 16:48:08 +000064.Sh RETURN VALUES
65Upon successful completion, the created source is returned.
66Otherwise,
67.Dv NULL
68is returned and the error code in
69.Ar archive
70is set to indicate the error.
71.Sh ERRORS
72.Fn zip_source_file
73fails if:
74.Bl -tag -width Er
75.It Bq Er ZIP_ER_INVAL
76.Ar fname ,
77.Ar start ,
78or
79.Ar len
80are invalid.
81.It Bq Er ZIP_ER_MEMORY
82Required memory could not be allocated.
83.It Bq Er ZIP_ER_OPEN
84Opening
85.Ar fname
86failed.
87.El
88.Sh SEE ALSO
Thomas Klausnerbec1cfe2005-06-09 18:50:27 +000089.Xr libzip 3 ,
Thomas Klausner7edc9e22004-11-18 16:48:08 +000090.Xr zip_add 3 ,
91.Xr zip_replace 3 ,
Thomas Klausner86a346b2014-08-02 12:10:27 +020092.Xr zip_source 3
Thomas Klausnera456cf52005-06-09 21:13:13 +000093.Sh AUTHORS
94.An -nosplit
Thomas Klausner0acbab42013-07-28 23:29:08 +020095.An Dieter Baron Aq Mt dillo@nih.at
Thomas Klausner39b5f9e2005-06-09 21:14:54 +000096and
Thomas Klausner0acbab42013-07-28 23:29:08 +020097.An Thomas Klausner Aq Mt tk@giga.or.at