1zzip_fopen(3)                zziplib Function List               zzip_fopen(3)
2
3
4

NAME

6       zzip_fopen, zzip_freopen -  start usage.
7

SYNOPSIS

9       #include <zzip/lib.h>
10
11
12       ZZIP_FILE *
13       zzip_fopen(zzip_char_t * filename, zzip_char_t * mode)
14
15       ZZIP_FILE *
16       zzip_freopen(zzip_char_t * filename, zzip_char_t * mode, ZZIP_FILE * stream)
17
18
19
20

DESCRIPTION

22        The zzip_fopen function will fopen(3) a real/zipped file.
23
24        It has some magic functionality builtin - it will first try to open
25       the given <emphasis>filename</emphasis> as a normal file. If it does
26       not exist, the given path to the filename (if any) is split into its
27       directory-part and the file-part. A ".zip" extension is then added to
28       the directory-part to create the name of a zip-archive. That zip-
29       archive (if it exists) is being searched for the file-part, and if
30       found a zzip-handle is returned.
31
32        Note that if the file is found in the normal fs-directory the returned
33       structure is mostly empty and the zzip_read call will use the libc
34       read(2) to obtain data. Otherwise a zzip_file_open is performed and any
35       error mapped to errno(3).
36
37        unlike the posix-wrapper zzip_open the mode-argument is a string which
38       allows for more freedom to support the extra zzip modes called
39       ZZIP_CASEINSENSITIVE and ZZIP_IGNOREPATH. Currently, this zzip_fopen
40       call will convert the following characters in the mode-string into
41       their corrsponding mode-bits:
42
43         "r" : O_RDONLY :  read-only
44
45         "b" : O_BINARY :  binary (win32 specific)
46
47         "f" : O_NOCTTY :  no char device (unix)
48
49         "i" : ZZIP_CASELESS :  inside zip file
50
51         "*" : ZZIP_NOPATHS :  inside zip file only
52
53        all other modes will be ignored for zip-contained entries but they are
54       transferred for compatibility and portability, including these extra
55       sugar bits:
56
57         "x" : O_EXCL : fail if file did exist
58
59         "s" : O_SYNC : synchronized access
60
61         "n" : O_NONBLOCK : nonblocking access
62
63         "z#" : compression level : for zlib
64
65         "g#" : group access : unix access bits
66
67         "u#" : owner access : unix access bits
68
69         "o#" : world access : unix access bits
70
71        ... the access bits are in traditional unix bit format with 7 =
72       read/write/execute, 6 = read/write, 4 = read-only.
73
74        The default access mode is 0664, and the compression level is ignored
75       since the lib can not yet write zip files, otherwise it would be the
76       initialisation value for the zlib deflateInit where 0 = no-compression,
77       1 = best-speed, 9 = best-compression.
78
79        The zzip_fopen function returns a new zzip-handle (use zzip_close to
80       return it). On error the zzip_fopen function will return null setting
81       errno(3).
82
83        The zzip_freopen function receives an additional argument pointing to
84       a ZZIP_FILE* being already in use. If this extra argument is null then
85       the zzip_freopen function is identical with calling zzip_fopen
86
87        Per default, the old file stream is closed and only the internal
88       structures associated with it are kept. These internal structures may
89       be reused for the return value, and this is a lot quicker when the
90       filename matches a zipped file that is incidentally in the very same
91       zip arch as the old filename wrapped in the stream struct.
92
93        That's simply because the zip arch's central directory does not need
94       to be read again. As an extension for the zzip_freopen function, if the
95       mode-string contains a "q" then the old stream is not closed but left
96       untouched, instead it is only given as a hint that a new file handle
97       may share/copy the zip arch structures of the old file handle if that
98       is possible, i.e when they are in the same zip arch.
99
100        The zzip_freopen function returns a new zzip-handle (use zzip_close to
101       return it). On error the zzip_freopen function will return null setting
102       errno(3).
103
104
105

AUTHOR

107        Guido Draheim <guidod@gmx.de> Tomi Ollila <Tomi.Ollila@iki.fi>
108
109
110
112        Copyright (c) Guido Draheim, use under copyleft (LGPL,MPL)
113
114
115

SEE ALSO

117        fopen(2)
118
119
120
121
122
123zziplib                             0.13.72                      zzip_fopen(3)
Impressum