1ZIP_SOURCE_FILE(3)       BSD Library Functions Manual       ZIP_SOURCE_FILE(3)
2

NAME

4     zip_source_file, zip_source_file_create — create data source from a file
5

LIBRARY

7     libzip (-lzip)
8

SYNOPSIS

10     #include <zip.h>
11
12     zip_source_t *
13     zip_source_file(zip_t *archive, const char *fname, zip_uint64_t start,
14         zip_int64_t len);
15
16     zip_source_t *
17     zip_source_file_create(const char *fname, zip_uint64_t start,
18         zip_int64_t len, zip_error_t *error);
19

DESCRIPTION

21     The functions zip_source_file() and zip_source_file_create() create a zip
22     source from a file.  They open fname and read len bytes from offset start
23     from it.
24
25     When passing ZIP_LENGTH_TO_END (or -1, which is deprecated) as len,
26     zip_source_file determines the file size when it is called and uses that
27     as the expected file size.  If the file size grows between creating and
28     reading from the source, the additional data is ignored.  If the file
29     shrinks, libzip treats it as an error (ZIP_ER_DATA_LENGTH).
30
31     When passing ZIP_LENGTH_UNCHECKED as len, zip_source_file assumes the
32     file's size is unknown.  Reading from the source returns as much data as
33     is there at that time (usually when calling zip_close(3)).
34
35     libzip can do various optimizations if the size of a source is known when
36     it's created, so ZIP_LENGTH_TO_END is preferrable.  If you deal with
37     files that are likely to change while you are processing them, you can
38     use the less efficient ZIP_LENGTH_UNCHECKED.
39
40     If the file supports seek, the source can be used to open a zip archive
41     from.
42
43     The file is opened and read when the data from the source is used, usu‐
44     ally by zip_close() or zip_open_from_source().
45

RETURN VALUES

47     Upon successful completion, the created source is returned.  Otherwise,
48     NULL is returned and the error code in archive or error is set to indi‐
49     cate the error.
50

ERRORS

52     zip_source_file() and zip_source_file_create() fail if:
53
54     [ZIP_ER_INVAL]     fname, start, or len are invalid.
55
56     [ZIP_ER_MEMORY]    Required memory could not be allocated.
57
58     [ZIP_ER_OPEN]      Opening fname failed.
59

SEE ALSO

61     libzip(3), zip_file_add(3), zip_file_replace(3), zip_source(3)
62

HISTORY

64     zip_source_file() and zip_source_file_create() were added in libzip 1.0.
65
66     ZIP_LENGTH_TO_END and ZIP_LENGTH_UNCHECKED were added in libzip 1.10.1.
67

AUTHORS

69     Dieter Baron <dillo@nih.at> and Thomas Klausner <tk@giga.or.at>
70
71BSD                              June 30, 2023                             BSD
Impressum