| ARX 1.0 The next-generation open source augmented reality toolkit.

Loading...
Searching...
No Matches
zip.h
Go to the documentation of this file.
1/* zip.h -- IO on .zip files using zlib
2 Version 1.2.0, September 16th, 2017
3 part of the MiniZip project
4
5 Copyright (C) 2012-2017 Nathan Moinvaziri
6 https://github.com/nmoinvaz/minizip
7 Copyright (C) 2009-2010 Mathias Svensson
8 Modifications for Zip64 support
9 http://result42.com
10 Copyright (C) 1998-2010 Gilles Vollant
11 http://www.winimage.com/zLibDll/minizip.html
12
13 This program is distributed under the terms of the same license as zlib.
14 See the accompanying LICENSE file for the full text of the license.
15*/
16
17#ifndef _ZIP_H
18#define _ZIP_H
19
20#ifdef __cplusplus
21 extern "C" {
22#endif
23
24#ifndef _ZLIB_H
25# include "zlib.h"
26#endif
27
28#ifndef _ZLIBIOAPI_H
29# include "ioapi.h"
30#endif
31
32#ifdef HAVE_BZIP2
33# include "bzlib.h"
34#endif
35
36#define Z_BZIP2ED 12
37
38#if defined(STRICTZIP) || defined(STRICTZIPUNZIP)
39/* like the STRICT of WIN32, we define a pointer that cannot be converted
40 from (void*) without cast */
41 typedef struct TagzipFile__ { int unused; } zip_file__;
42 typedef zip_file__ *zipFile;
43#else
44 typedef voidp zipFile;
45#endif
46
47#define ZIP_OK (0)
48#define ZIP_EOF (0)
49#define ZIP_ERRNO (Z_ERRNO)
50#define ZIP_PARAMERROR (-102)
51#define ZIP_BADZIPFILE (-103)
52#define ZIP_INTERNALERROR (-104)
53
54#ifndef DEF_MEM_LEVEL
55# if MAX_MEM_LEVEL >= 8
56# define DEF_MEM_LEVEL 8
57# else
58# define DEF_MEM_LEVEL MAX_MEM_LEVEL
59# endif
60#endif
61
62 typedef struct
63{
64 uint32_t dos_date;
65 uint16_t internal_fa; /* internal file attributes 2 bytes */
66 uint32_t external_fa; /* external file attributes 4 bytes */
67} zip_fileinfo;
68
69#define APPEND_STATUS_CREATE (0)
70#define APPEND_STATUS_CREATEAFTER (1)
71#define APPEND_STATUS_ADDINZIP (2)
72
73/***************************************************************************/
74/* Writing a zip file */
75
76 extern zipFile ZEXPORT zipOpen(const char *path, int append);
77 extern zipFile ZEXPORT zipOpen64(const void *path, int append);
78/* Create a zipfile.
79
80 path should contain the full path (by example, on a Windows XP computer
81 "c:\\zlib\\zlib113.zip" or on an Unix computer "zlib/zlib113.zip".
82
83 return NULL if zipfile cannot be opened
84 return zipFile handle if no error
85
86 If the file path exist and append == APPEND_STATUS_CREATEAFTER, the zip
87 will be created at the end of the file. (useful if the file contain a self extractor code)
88 If the file path exist and append == APPEND_STATUS_ADDINZIP, we will add files in existing
89 zip (be sure you don't add file that doesn't exist)
90
91 NOTE: There is no delete function into a zipfile. If you want delete file into a zipfile,
92 you must open a zipfile, and create another. Of course, you can use RAW reading and writing to copy
93 the file you did not want delete. */
94
95 extern zipFile ZEXPORT zipOpen2(const char *path, int append, const char **globalcomment,
96 zlib_filefunc_def *pzlib_filefunc_def);
97
98 extern zipFile ZEXPORT zipOpen2_64(const void *path, int append, const char **globalcomment,
99 zlib_filefunc64_def *pzlib_filefunc_def);
100
101 extern zipFile ZEXPORT zipOpen3(const char *path, int append, uint64_t disk_size,
102 const char **globalcomment, zlib_filefunc_def *pzlib_filefunc_def);
103/* Same as zipOpen2 but allows specification of spanned zip size */
104
105 extern zipFile ZEXPORT zipOpen3_64(const void *path, int append, uint64_t disk_size,
106 const char **globalcomment, zlib_filefunc64_def *pzlib_filefunc_def);
107
108 extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char *filename, const zip_fileinfo *zipfi,
109 const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
110 uint16_t size_extrafield_global, const char *comment, uint16_t method, int level);
111/* Open a file in the ZIP for writing.
112
113 filename : the filename in zip (if NULL, '-' without quote will be used
114 *zipfi contain supplemental information
115 extrafield_local buffer to store the local header extra field data, can be NULL
116 size_extrafield_local size of extrafield_local buffer
117 extrafield_global buffer to store the global header extra field data, can be NULL
118 size_extrafield_global size of extrafield_local buffer
119 comment buffer for comment string
120 method contain the compression method (0 for store, Z_DEFLATED for deflate)
121 level contain the level of compression (can be Z_DEFAULT_COMPRESSION)
122 zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
123 this MUST be '1' if the uncompressed size is >= 0xffffffff. */
124
125 extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
126 const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
127 uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int zip64);
128/* Same as zipOpenNewFileInZip with zip64 support */
129
130 extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi,
131 const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
132 uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw);
133/* Same as zipOpenNewFileInZip, except if raw=1, we write raw file */
134
135 extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
136 const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
137 uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int zip64);
138/* Same as zipOpenNewFileInZip3 with zip64 support */
139
140 extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char *filename, const zip_fileinfo *zipfi,
141 const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
142 uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel,
143 int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting);
144/* Same as zipOpenNewFileInZip2, except
145 windowBits, memLevel, strategy : see parameter strategy in deflateInit2
146 password : crypting password (NULL for no crypting)
147 crc_for_crypting : crc of file to compress (needed for crypting) */
148
149 extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
150 const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
151 uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel,
152 int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting, int zip64);
153/* Same as zipOpenNewFileInZip3 with zip64 support */
154
155 extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char *filename, const zip_fileinfo *zipfi,
156 const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
157 uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel,
158 int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting, uint16_t version_madeby, uint16_t flag_base);
159/* Same as zipOpenNewFileInZip3 except versionMadeBy & flag fields */
160
161 extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi,
162 const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global,
163 uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel,
164 int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting, uint16_t version_madeby, uint16_t flag_base, int zip64);
165/* Same as zipOpenNewFileInZip4 with zip64 support */
166
167 extern int ZEXPORT zipOpenNewFileInZip5(zipFile file,
168 const char *filename,
169 const zip_fileinfo *zipfi,
170 const void *extrafield_local,
171 uint16_t size_extrafield_local,
172 const void *extrafield_global,
173 uint16_t size_extrafield_global,
174 const char *comment,
175 uint16_t flag_base,
176 int zip64,
177 uint16_t method,
178 int level,
179 int raw,
180 int windowBits,
181 int memLevel,
182 int strategy,
183 const char *password,
184 int aes);
185/* Allowing optional aes */
186
187 extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void *buf, uint32_t len);
188/* Write data in the zipfile */
189
190 extern int ZEXPORT zipCloseFileInZip(zipFile file);
191/* Close the current file in the zipfile */
192
193 extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uint32_t uncompressed_size, uint32_t crc32);
194 extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, uint64_t uncompressed_size, uint32_t crc32);
195/* Close the current file in the zipfile, for file opened with parameter raw=1 in zipOpenNewFileInZip2
196 where raw is compressed data. Parameters uncompressed_size and crc32 are value for the uncompressed data. */
197
198 extern int ZEXPORT zipClose(zipFile file, const char *global_comment);
199/* Close the zipfile */
200
201 extern int ZEXPORT zipClose_64(zipFile file, const char *global_comment);
202
203 extern int ZEXPORT zipClose2_64(zipFile file, const char *global_comment, uint16_t version_madeby);
204/* Same as zipClose_64 except version_madeby field */
205
206/***************************************************************************/
207
208#ifdef __cplusplus
209}
210#endif
211
212#endif /* _ZIP_H */
ioapi.h
ZIP_UNUSED
#define ZIP_UNUSED
Definition: ioapi.h:32
zip_fileinfo
Definition: zip.h:63
zip_fileinfo::internal_fa
uint16_t internal_fa
Definition: zip.h:65
zip_fileinfo::external_fa
uint32_t external_fa
Definition: zip.h:66
zip_fileinfo::dos_date
uint32_t dos_date
Definition: zip.h:64
zlib_filefunc64_def_s
Definition: ioapi.h:109
zlib_filefunc_def_s
Definition: ioapi.h:91
zipOpen
zipFile ZEXPORT zipOpen(const char *path, int append)
Definition: zip.c:904
zipClose_64
int ZEXPORT zipClose_64(zipFile file, const char *global_comment)
Definition: zip.c:1845
zipClose2_64
int ZEXPORT zipClose2_64(zipFile file, const char *global_comment, uint16_t version_madeby)
Definition: zip.c:1850
zipWriteInFileInZip
int ZEXPORT zipWriteInFileInZip(zipFile file, const void *buf, uint32_t len)
Definition: zip.c:1449
zipOpenNewFileInZip4
int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting, uint16_t version_madeby, uint16_t flag_base)
Definition: zip.c:1299
zipOpen2_64
zipFile ZEXPORT zipOpen2_64(const void *path, int append, const char **globalcomment, zlib_filefunc64_def *pzlib_filefunc_def)
Definition: zip.c:864
zipOpenNewFileInZip2_64
int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int zip64)
Definition: zip.c:1338
zipOpen2
zipFile ZEXPORT zipOpen2(const char *path, int append, const char **globalcomment, zlib_filefunc_def *pzlib_filefunc_def)
Definition: zip.c:852
zipClose
int ZEXPORT zipClose(zipFile file, const char *global_comment)
Definition: zip.c:1840
zipOpenNewFileInZip
int ZEXPORT zipOpenNewFileInZip(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, uint16_t method, int level)
Definition: zip.c:1356
zipOpenNewFileInZip5
int ZEXPORT zipOpenNewFileInZip5(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, uint16_t flag_base, int zip64, uint16_t method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, int aes)
Definition: zip.c:1275
zipOpenNewFileInZip4_64
int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting, uint16_t version_madeby, uint16_t flag_base, int zip64)
Definition: zip.c:1285
zipOpenNewFileInZip3_64
int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting, int zip64)
Definition: zip.c:1319
zipOpen3
zipFile ZEXPORT zipOpen3(const char *path, int append, uint64_t disk_size, const char **globalcomment, zlib_filefunc_def *pzlib_filefunc_def)
Definition: zip.c:878
zipOpenNewFileInZip2
int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw)
Definition: zip.c:1329
zipCloseFileInZipRaw64
int ZEXPORT zipCloseFileInZipRaw64(zipFile file, uint64_t uncompressed_size, uint32_t crc32)
Definition: zip.c:1572
zipCloseFileInZipRaw
int ZEXPORT zipCloseFileInZipRaw(zipFile file, uint32_t uncompressed_size, uint32_t crc32)
Definition: zip.c:1830
zipOpenNewFileInZip64
int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int zip64)
Definition: zip.c:1347
zipCloseFileInZip
int ZEXPORT zipCloseFileInZip(zipFile file)
Definition: zip.c:1835
zipOpen64
zipFile ZEXPORT zipOpen64(const void *path, int append)
Definition: zip.c:909
zipOpen3_64
zipFile ZEXPORT zipOpen3_64(const void *path, int append, uint64_t disk_size, const char **globalcomment, zlib_filefunc64_def *pzlib_filefunc_def)
Definition: zip.c:890
zipFile
voidp zipFile
Definition: zip.h:44
zipOpenNewFileInZip3
int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char *filename, const zip_fileinfo *zipfi, const void *extrafield_local, uint16_t size_extrafield_local, const void *extrafield_global, uint16_t size_extrafield_global, const char *comment, uint16_t method, int level, int raw, int windowBits, int memLevel, int strategy, const char *password, ZIP_UNUSED uint32_t crc_for_crypting)
Definition: zip.c:1309