1 | /** @file
|
---|
2 | * IPRT - Compression.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2022 Oracle and/or its affiliates.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox base platform packages, as
|
---|
9 | * available from https://www.virtualbox.org.
|
---|
10 | *
|
---|
11 | * This program is free software; you can redistribute it and/or
|
---|
12 | * modify it under the terms of the GNU General Public License
|
---|
13 | * as published by the Free Software Foundation, in version 3 of the
|
---|
14 | * License.
|
---|
15 | *
|
---|
16 | * This program is distributed in the hope that it will be useful, but
|
---|
17 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
19 | * General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
23 | *
|
---|
24 | * The contents of this file may alternatively be used under the terms
|
---|
25 | * of the Common Development and Distribution License Version 1.0
|
---|
26 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
27 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
28 | * CDDL are applicable instead of those of the GPL.
|
---|
29 | *
|
---|
30 | * You may elect to license modified versions of this file under the
|
---|
31 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
32 | *
|
---|
33 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef IPRT_INCLUDED_zip_h
|
---|
37 | #define IPRT_INCLUDED_zip_h
|
---|
38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
39 | # pragma once
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #include <iprt/cdefs.h>
|
---|
43 | #include <iprt/types.h>
|
---|
44 |
|
---|
45 | RT_C_DECLS_BEGIN
|
---|
46 |
|
---|
47 | /** @defgroup grp_rt_zip RTZip - Compression
|
---|
48 | * @ingroup grp_rt
|
---|
49 | * @{
|
---|
50 | */
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Callback function for consuming compressed data during compression.
|
---|
56 | *
|
---|
57 | * @returns iprt status code.
|
---|
58 | * @param pvUser User argument.
|
---|
59 | * @param pvBuf Compressed data.
|
---|
60 | * @param cbBuf Size of the compressed data.
|
---|
61 | */
|
---|
62 | typedef DECLCALLBACKTYPE(int, FNRTZIPOUT,(void *pvUser, const void *pvBuf, size_t cbBuf));
|
---|
63 | /** Pointer to FNRTZIPOUT() function. */
|
---|
64 | typedef FNRTZIPOUT *PFNRTZIPOUT;
|
---|
65 |
|
---|
66 | /**
|
---|
67 | * Callback function for supplying compressed data during decompression.
|
---|
68 | *
|
---|
69 | * @returns iprt status code.
|
---|
70 | * @param pvUser User argument.
|
---|
71 | * @param pvBuf Where to store the compressed data.
|
---|
72 | * @param cbBuf Size of the buffer.
|
---|
73 | * @param pcbBuf Number of bytes actually stored in the buffer.
|
---|
74 | */
|
---|
75 | typedef DECLCALLBACKTYPE(int, FNRTZIPIN,(void *pvUser, void *pvBuf, size_t cbBuf, size_t *pcbBuf));
|
---|
76 | /** Pointer to FNRTZIPIN() function. */
|
---|
77 | typedef FNRTZIPIN *PFNRTZIPIN;
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Compression type.
|
---|
81 | * (Be careful with these they are stored in files!)
|
---|
82 | */
|
---|
83 | typedef enum RTZIPTYPE
|
---|
84 | {
|
---|
85 | /** Invalid. */
|
---|
86 | RTZIPTYPE_INVALID = 0,
|
---|
87 | /** Choose best fitting one. */
|
---|
88 | RTZIPTYPE_AUTO,
|
---|
89 | /** Store the data. */
|
---|
90 | RTZIPTYPE_STORE,
|
---|
91 | /** Zlib compression the data. */
|
---|
92 | RTZIPTYPE_ZLIB,
|
---|
93 | /** BZlib compress. */
|
---|
94 | RTZIPTYPE_BZLIB,
|
---|
95 | /** libLZF compress. */
|
---|
96 | RTZIPTYPE_LZF,
|
---|
97 | /** Lempel-Ziv-Jeff-Bonwick compression. */
|
---|
98 | RTZIPTYPE_LZJB,
|
---|
99 | /** Lempel-Ziv-Oberhumer compression. */
|
---|
100 | RTZIPTYPE_LZO,
|
---|
101 | /* Zlib compression the data without zlib header. */
|
---|
102 | RTZIPTYPE_ZLIB_NO_HEADER,
|
---|
103 | /** End of valid the valid compression types. */
|
---|
104 | RTZIPTYPE_END
|
---|
105 | } RTZIPTYPE;
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * Compression level.
|
---|
109 | */
|
---|
110 | typedef enum RTZIPLEVEL
|
---|
111 | {
|
---|
112 | /** Store, don't compress. */
|
---|
113 | RTZIPLEVEL_STORE = 0,
|
---|
114 | /** Fast compression. */
|
---|
115 | RTZIPLEVEL_FAST,
|
---|
116 | /** Default compression. */
|
---|
117 | RTZIPLEVEL_DEFAULT,
|
---|
118 | /** Maximal compression. */
|
---|
119 | RTZIPLEVEL_MAX
|
---|
120 | } RTZIPLEVEL;
|
---|
121 |
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * Create a stream compressor instance.
|
---|
125 | *
|
---|
126 | * @returns iprt status code.
|
---|
127 | * @param ppZip Where to store the instance handle.
|
---|
128 | * @param pvUser User argument which will be passed on to pfnOut and pfnIn.
|
---|
129 | * @param pfnOut Callback for consuming output of compression.
|
---|
130 | * @param enmType Type of compressor to create.
|
---|
131 | * @param enmLevel Compression level.
|
---|
132 | */
|
---|
133 | RTDECL(int) RTZipCompCreate(PRTZIPCOMP *ppZip, void *pvUser, PFNRTZIPOUT pfnOut, RTZIPTYPE enmType, RTZIPLEVEL enmLevel);
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Compresses a chunk of memory.
|
---|
137 | *
|
---|
138 | * @returns iprt status code.
|
---|
139 | * @param pZip The compressor instance.
|
---|
140 | * @param pvBuf Pointer to buffer containing the bits to compress.
|
---|
141 | * @param cbBuf Number of bytes to compress.
|
---|
142 | */
|
---|
143 | RTDECL(int) RTZipCompress(PRTZIPCOMP pZip, const void *pvBuf, size_t cbBuf);
|
---|
144 |
|
---|
145 | /**
|
---|
146 | * Finishes the compression.
|
---|
147 | * This will flush all data and terminate the compression data stream.
|
---|
148 | *
|
---|
149 | * @returns iprt status code.
|
---|
150 | * @param pZip The stream compressor instance.
|
---|
151 | */
|
---|
152 | RTDECL(int) RTZipCompFinish(PRTZIPCOMP pZip);
|
---|
153 |
|
---|
154 | /**
|
---|
155 | * Destroys the stream compressor instance.
|
---|
156 | *
|
---|
157 | * @returns iprt status code.
|
---|
158 | * @param pZip The compressor instance.
|
---|
159 | */
|
---|
160 | RTDECL(int) RTZipCompDestroy(PRTZIPCOMP pZip);
|
---|
161 |
|
---|
162 |
|
---|
163 | /**
|
---|
164 | * Create a stream decompressor instance.
|
---|
165 | *
|
---|
166 | * @returns iprt status code.
|
---|
167 | * @param ppZip Where to store the instance handle.
|
---|
168 | * @param pvUser User argument which will be passed on to pfnOut and pfnIn.
|
---|
169 | * @param pfnIn Callback for producing input for decompression.
|
---|
170 | */
|
---|
171 | RTDECL(int) RTZipDecompCreate(PRTZIPDECOMP *ppZip, void *pvUser, PFNRTZIPIN pfnIn);
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * Decompresses a chunk of memory.
|
---|
175 | *
|
---|
176 | * @returns iprt status code.
|
---|
177 | * @param pZip The stream decompressor instance.
|
---|
178 | * @param pvBuf Where to store the decompressed data.
|
---|
179 | * @param cbBuf Number of bytes to produce. If pcbWritten is set
|
---|
180 | * any number of bytes up to cbBuf might be returned.
|
---|
181 | * @param pcbWritten Number of bytes actually written to the buffer. If NULL
|
---|
182 | * cbBuf number of bytes must be written.
|
---|
183 | */
|
---|
184 | RTDECL(int) RTZipDecompress(PRTZIPDECOMP pZip, void *pvBuf, size_t cbBuf, size_t *pcbWritten);
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * Destroys the stream decompressor instance.
|
---|
188 | *
|
---|
189 | * @returns iprt status code.
|
---|
190 | * @param pZip The decompressor instance.
|
---|
191 | */
|
---|
192 | RTDECL(int) RTZipDecompDestroy(PRTZIPDECOMP pZip);
|
---|
193 |
|
---|
194 |
|
---|
195 | /**
|
---|
196 | * Compress a chunk of memory into a block.
|
---|
197 | *
|
---|
198 | * @returns IPRT status code.
|
---|
199 | *
|
---|
200 | * @param enmType The compression type.
|
---|
201 | * @param enmLevel The compression level.
|
---|
202 | * @param fFlags Flags reserved for future extensions, MBZ.
|
---|
203 | * @param pvSrc Pointer to the input block.
|
---|
204 | * @param cbSrc Size of the input block.
|
---|
205 | * @param pvDst Pointer to the output buffer.
|
---|
206 | * @param cbDst The size of the output buffer.
|
---|
207 | * @param pcbDstActual Where to return the compressed size.
|
---|
208 | */
|
---|
209 | RTDECL(int) RTZipBlockCompress(RTZIPTYPE enmType, RTZIPLEVEL enmLevel, uint32_t fFlags,
|
---|
210 | void const *pvSrc, size_t cbSrc,
|
---|
211 | void *pvDst, size_t cbDst, size_t *pcbDstActual) RT_NO_THROW_PROTO;
|
---|
212 |
|
---|
213 |
|
---|
214 | /**
|
---|
215 | * Decompress a block.
|
---|
216 | *
|
---|
217 | * @returns IPRT status code.
|
---|
218 | *
|
---|
219 | * @param enmType The compression type.
|
---|
220 | * @param fFlags Flags reserved for future extensions, MBZ.
|
---|
221 | * @param pvSrc Pointer to the input block.
|
---|
222 | * @param cbSrc Size of the input block.
|
---|
223 | * @param pcbSrcActual Where to return the compressed size.
|
---|
224 | * @param pvDst Pointer to the output buffer.
|
---|
225 | * @param cbDst The size of the output buffer.
|
---|
226 | * @param pcbDstActual Where to return the decompressed size.
|
---|
227 | */
|
---|
228 | RTDECL(int) RTZipBlockDecompress(RTZIPTYPE enmType, uint32_t fFlags,
|
---|
229 | void const *pvSrc, size_t cbSrc, size_t *pcbSrcActual,
|
---|
230 | void *pvDst, size_t cbDst, size_t *pcbDstActual) RT_NO_THROW_PROTO;
|
---|
231 |
|
---|
232 |
|
---|
233 | /**
|
---|
234 | * Opens a gzip decompression I/O stream.
|
---|
235 | *
|
---|
236 | * @returns IPRT status code.
|
---|
237 | *
|
---|
238 | * @param hVfsIosIn The compressed input stream (must be readable).
|
---|
239 | * The reference is not consumed, instead another
|
---|
240 | * one is retained.
|
---|
241 | * @param fFlags Flags, MBZ.
|
---|
242 | * @param phVfsIosGunzip Where to return the handle to the gunzipped I/O
|
---|
243 | * stream (read).
|
---|
244 | */
|
---|
245 | RTDECL(int) RTZipGzipDecompressIoStream(RTVFSIOSTREAM hVfsIosIn, uint32_t fFlags, PRTVFSIOSTREAM phVfsIosGunzip);
|
---|
246 |
|
---|
247 | /** @name RTZipGzipDecompressIoStream flags.
|
---|
248 | * @{ */
|
---|
249 | /** Allow the smaller ZLIB header as well as the regular GZIP header. */
|
---|
250 | #define RTZIPGZIPDECOMP_F_ALLOW_ZLIB_HDR RT_BIT(0)
|
---|
251 | /** @} */
|
---|
252 |
|
---|
253 |
|
---|
254 | /**
|
---|
255 | * Opens a gzip decompression I/O stream.
|
---|
256 | *
|
---|
257 | * @returns IPRT status code.
|
---|
258 | *
|
---|
259 | * @param hVfsIosDst The compressed output stream (must be writable).
|
---|
260 | * The reference is not consumed, instead another
|
---|
261 | * one is retained.
|
---|
262 | * @param fFlags Flags, MBZ.
|
---|
263 | * @param uLevel The gzip compression level, 1 thru 9.
|
---|
264 | * @param phVfsIosGzip Where to return the gzip input I/O stream handle
|
---|
265 | * (you write to this).
|
---|
266 | */
|
---|
267 | RTDECL(int) RTZipGzipCompressIoStream(RTVFSIOSTREAM hVfsIosDst, uint32_t fFlags, uint8_t uLevel, PRTVFSIOSTREAM phVfsIosGzip);
|
---|
268 |
|
---|
269 | /**
|
---|
270 | * A mini GZIP program.
|
---|
271 | *
|
---|
272 | * @returns Program exit code.
|
---|
273 | *
|
---|
274 | * @param cArgs The number of arguments.
|
---|
275 | * @param papszArgs The argument vector. (Note that this may be
|
---|
276 | * reordered, so the memory must be writable.)
|
---|
277 | */
|
---|
278 | RTDECL(RTEXITCODE) RTZipGzipCmd(unsigned cArgs, char **papszArgs);
|
---|
279 |
|
---|
280 | /**
|
---|
281 | * Opens a TAR filesystem stream.
|
---|
282 | *
|
---|
283 | * This is used to extract, list or check a TAR archive.
|
---|
284 | *
|
---|
285 | * @returns IPRT status code.
|
---|
286 | *
|
---|
287 | * @param hVfsIosIn The input stream. The reference is not
|
---|
288 | * consumed, instead another one is retained.
|
---|
289 | * @param fFlags Flags, MBZ.
|
---|
290 | * @param phVfsFss Where to return the handle to the TAR
|
---|
291 | * filesystem stream.
|
---|
292 | */
|
---|
293 | RTDECL(int) RTZipTarFsStreamFromIoStream(RTVFSIOSTREAM hVfsIosIn, uint32_t fFlags, PRTVFSFSSTREAM phVfsFss);
|
---|
294 |
|
---|
295 | /** TAR format type. */
|
---|
296 | typedef enum RTZIPTARFORMAT
|
---|
297 | {
|
---|
298 | /** Customary invalid zero value. */
|
---|
299 | RTZIPTARFORMAT_INVALID = 0,
|
---|
300 | /** Default format (GNU). */
|
---|
301 | RTZIPTARFORMAT_DEFAULT,
|
---|
302 | /** The GNU format. */
|
---|
303 | RTZIPTARFORMAT_GNU,
|
---|
304 | /** USTAR format from POSIX.1-1988. */
|
---|
305 | RTZIPTARFORMAT_USTAR,
|
---|
306 | /** PAX format from POSIX.1-2001. */
|
---|
307 | RTZIPTARFORMAT_PAX,
|
---|
308 | /** End of valid formats. */
|
---|
309 | RTZIPTARFORMAT_END,
|
---|
310 | /** Make sure the type is at least 32 bits wide. */
|
---|
311 | RTZIPTARFORMAT_32BIT_HACK = 0x7fffffff
|
---|
312 | } RTZIPTARFORMAT;
|
---|
313 |
|
---|
314 | /**
|
---|
315 | * Opens a TAR filesystem stream for the purpose of create a new TAR archive.
|
---|
316 | *
|
---|
317 | * @returns IPRT status code.
|
---|
318 | *
|
---|
319 | * @param hVfsIosOut The output stream, i.e. where the tar stuff is
|
---|
320 | * written. The reference is not consumed, instead
|
---|
321 | * another one is retained.
|
---|
322 | * @param enmFormat The desired output format.
|
---|
323 | * @param fFlags RTZIPTAR_C_XXX, except RTZIPTAR_C_UPDATE.
|
---|
324 | * @param phVfsFss Where to return the handle to the TAR
|
---|
325 | * filesystem stream.
|
---|
326 | */
|
---|
327 | RTDECL(int) RTZipTarFsStreamToIoStream(RTVFSIOSTREAM hVfsIosOut, RTZIPTARFORMAT enmFormat,
|
---|
328 | uint32_t fFlags, PRTVFSFSSTREAM phVfsFss);
|
---|
329 |
|
---|
330 | /** @name RTZIPTAR_C_XXX - TAR creation flags (RTZipTarFsStreamToIoStream).
|
---|
331 | * @{ */
|
---|
332 | /** Check for sparse files.
|
---|
333 | * @note Only supported when adding file objects. The files will be read
|
---|
334 | * twice. */
|
---|
335 | #define RTZIPTAR_C_SPARSE RT_BIT_32(0)
|
---|
336 | /** Set if opening for updating. */
|
---|
337 | #define RTZIPTAR_C_UPDATE RT_BIT_32(1)
|
---|
338 | /** Valid bits. */
|
---|
339 | #define RTZIPTAR_C_VALID_MASK UINT32_C(0x00000003)
|
---|
340 | /** @} */
|
---|
341 |
|
---|
342 | /**
|
---|
343 | * Opens a TAR filesystem stream for the purpose of create a new TAR archive or
|
---|
344 | * updating an existing one.
|
---|
345 | *
|
---|
346 | * @returns IPRT status code.
|
---|
347 | *
|
---|
348 | * @param hVfsFile The TAR file handle, i.e. where the tar stuff is
|
---|
349 | * written and optionally read/update. The
|
---|
350 | * reference is not consumed, instead another one
|
---|
351 | * is retained.
|
---|
352 | * @param enmFormat The desired output format.
|
---|
353 | * @param fFlags RTZIPTAR_C_XXX.
|
---|
354 | * @param phVfsFss Where to return the handle to the TAR
|
---|
355 | * filesystem stream.
|
---|
356 | */
|
---|
357 | RTDECL(int) RTZipTarFsStreamForFile(RTVFSFILE hVfsFile, RTZIPTARFORMAT enmFormat, uint32_t fFlags, PRTVFSFSSTREAM phVfsFss);
|
---|
358 |
|
---|
359 | /**
|
---|
360 | * Set the owner to store the archive entries with.
|
---|
361 | *
|
---|
362 | * @returns IPRT status code.
|
---|
363 | * @param hVfsFss The handle to a TAR creator.
|
---|
364 | * @param uid The UID value to set. Passing NIL_RTUID makes
|
---|
365 | * it use the value found in RTFSOBJINFO.
|
---|
366 | * @param pszOwner The owner name to store. Passing NULL makes it
|
---|
367 | * use the value found in RTFSOBJINFO.
|
---|
368 | */
|
---|
369 | RTDECL(int) RTZipTarFsStreamSetOwner(RTVFSFSSTREAM hVfsFss, RTUID uid, const char *pszOwner);
|
---|
370 |
|
---|
371 | /**
|
---|
372 | * Set the group to store the archive entries with.
|
---|
373 | *
|
---|
374 | * @returns IPRT status code.
|
---|
375 | * @param hVfsFss The handle to a TAR creator.
|
---|
376 | * @param gid The GID value to set. Passing NIL_RTUID makes
|
---|
377 | * it use the value found in RTFSOBJINFO.
|
---|
378 | * @param pszGroup The group name to store. Passing NULL makes it
|
---|
379 | * use the value found in RTFSOBJINFO.
|
---|
380 | */
|
---|
381 | RTDECL(int) RTZipTarFsStreamSetGroup(RTVFSFSSTREAM hVfsFss, RTGID gid, const char *pszGroup);
|
---|
382 |
|
---|
383 | /**
|
---|
384 | * Set path prefix to store the archive entries with.
|
---|
385 | *
|
---|
386 | * @returns IPRT status code.
|
---|
387 | * @param hVfsFss The handle to a TAR creator.
|
---|
388 | * @param pszPrefix The path prefix to join the names with. Pass
|
---|
389 | * NULL for no prefix.
|
---|
390 | */
|
---|
391 | RTDECL(int) RTZipTarFsStreamSetPrefix(RTVFSFSSTREAM hVfsFss, const char *pszPrefix);
|
---|
392 |
|
---|
393 | /**
|
---|
394 | * Set the AND and OR masks to apply to file (non-dir) modes in the archive.
|
---|
395 | *
|
---|
396 | * @returns IPRT status code.
|
---|
397 | * @param hVfsFss The handle to a TAR creator.
|
---|
398 | * @param fAndMode The bits to keep
|
---|
399 | * @param fOrMode The bits to set.
|
---|
400 | */
|
---|
401 | RTDECL(int) RTZipTarFsStreamSetFileMode(RTVFSFSSTREAM hVfsFss, RTFMODE fAndMode, RTFMODE fOrMode);
|
---|
402 |
|
---|
403 | /**
|
---|
404 | * Set the AND and OR masks to apply to directory modes in the archive.
|
---|
405 | *
|
---|
406 | * @returns IPRT status code.
|
---|
407 | * @param hVfsFss The handle to a TAR creator.
|
---|
408 | * @param fAndMode The bits to keep
|
---|
409 | * @param fOrMode The bits to set.
|
---|
410 | */
|
---|
411 | RTDECL(int) RTZipTarFsStreamSetDirMode(RTVFSFSSTREAM hVfsFss, RTFMODE fAndMode, RTFMODE fOrMode);
|
---|
412 |
|
---|
413 | /**
|
---|
414 | * Set the modification time to store the archive entires with.
|
---|
415 | *
|
---|
416 | * @returns IPRT status code.
|
---|
417 | * @param hVfsFss The handle to a TAR creator.
|
---|
418 | * @param pModificationTime The modification time to use. Pass NULL to use
|
---|
419 | * the value found in RTFSOBJINFO.
|
---|
420 | */
|
---|
421 | RTDECL(int) RTZipTarFsStreamSetMTime(RTVFSFSSTREAM hVfsFss, PCRTTIMESPEC pModificationTime);
|
---|
422 |
|
---|
423 | /**
|
---|
424 | * Truncates a TAR creator stream in update mode.
|
---|
425 | *
|
---|
426 | * Use RTVfsFsStrmNext to examine the TAR stream and locate the cut-off point.
|
---|
427 | *
|
---|
428 | * After performing this call, the stream will be in write mode and
|
---|
429 | * RTVfsFsStrmNext will stop working (VERR_WRONG_ORDER). The RTVfsFsStrmAdd()
|
---|
430 | * and RTVfsFsStrmPushFile() can be used to add new object to the TAR file,
|
---|
431 | * starting at the trunction point. RTVfsFsStrmEnd() is used to finish the TAR
|
---|
432 | * file (this performs the actual file trunction).
|
---|
433 | *
|
---|
434 | * @returns IPRT status code.
|
---|
435 | * @param hVfsFss The handle to a TAR creator in update mode.
|
---|
436 | * @param hVfsObj Object returned by RTVfsFsStrmNext that the
|
---|
437 | * trunction is relative to. This doesn't have to
|
---|
438 | * be the current stream object, it can be an
|
---|
439 | * earlier one too.
|
---|
440 | * @param fAfter If set, @a hVfsObj will remain in the update TAR
|
---|
441 | * file. If clear, @a hVfsObj will not be
|
---|
442 | * included.
|
---|
443 | */
|
---|
444 | RTDECL(int) RTZipTarFsStreamTruncate(RTVFSFSSTREAM hVfsFss, RTVFSOBJ hVfsObj, bool fAfter);
|
---|
445 |
|
---|
446 | /**
|
---|
447 | * A mini TAR program.
|
---|
448 | *
|
---|
449 | * @returns Program exit code.
|
---|
450 | *
|
---|
451 | * @param cArgs The number of arguments.
|
---|
452 | * @param papszArgs The argument vector. (Note that this may be
|
---|
453 | * reordered, so the memory must be writable.)
|
---|
454 | */
|
---|
455 | RTDECL(RTEXITCODE) RTZipTarCmd(unsigned cArgs, char **papszArgs);
|
---|
456 |
|
---|
457 | /**
|
---|
458 | * Opens a ZIP filesystem stream.
|
---|
459 | *
|
---|
460 | * This is used to extract, list or check a ZIP archive.
|
---|
461 | *
|
---|
462 | * @returns IPRT status code.
|
---|
463 | *
|
---|
464 | * @param hVfsIosIn The compressed input stream. The reference is
|
---|
465 | * not consumed, instead another one is retained.
|
---|
466 | * @param fFlags Flags, MBZ.
|
---|
467 | * @param phVfsFss Where to return the handle to the TAR
|
---|
468 | * filesystem stream.
|
---|
469 | */
|
---|
470 | RTDECL(int) RTZipPkzipFsStreamFromIoStream(RTVFSIOSTREAM hVfsIosIn, uint32_t fFlags, PRTVFSFSSTREAM phVfsFss);
|
---|
471 |
|
---|
472 | /**
|
---|
473 | * A mini UNZIP program.
|
---|
474 | *
|
---|
475 | * @returns Program exit code.
|
---|
476 | * @
|
---|
477 | * @param cArgs The number of arguments.
|
---|
478 | * @param papszArgs The argument vector. (Note that this may be
|
---|
479 | * reordered, so the memory must be writable.)
|
---|
480 | */
|
---|
481 | RTDECL(RTEXITCODE) RTZipUnzipCmd(unsigned cArgs, char **papszArgs);
|
---|
482 |
|
---|
483 | /**
|
---|
484 | * Helper for decompressing files of a ZIP file located in memory.
|
---|
485 | *
|
---|
486 | * @returns IPRT status code.
|
---|
487 | *
|
---|
488 | * @param ppvDst Where to store the pointer to the allocated
|
---|
489 | * buffer. To be freed with RTMemFree().
|
---|
490 | * @param pcbDst Where to store the pointer to the size of the
|
---|
491 | * allocated buffer.
|
---|
492 | * @param pvSrc Pointer to the buffer containing the .zip file.
|
---|
493 | * @param cbSrc Size of the buffer containing the .zip file.
|
---|
494 | * @param pszObject Name of the object to extract.
|
---|
495 | */
|
---|
496 | RTDECL(int) RTZipPkzipMemDecompress(void **ppvDst, size_t *pcbDst, const void *pvSrc, size_t cbSrc, const char *pszObject);
|
---|
497 |
|
---|
498 | /**
|
---|
499 | * Opens a XAR filesystem stream.
|
---|
500 | *
|
---|
501 | * This is used to extract, list or check a XAR archive.
|
---|
502 | *
|
---|
503 | * @returns IPRT status code.
|
---|
504 | *
|
---|
505 | * @param hVfsIosIn The compressed input stream. The reference is
|
---|
506 | * not consumed, instead another one is retained.
|
---|
507 | * @param fFlags Flags, MBZ.
|
---|
508 | * @param phVfsFss Where to return the handle to the XAR filesystem
|
---|
509 | * stream.
|
---|
510 | */
|
---|
511 | RTDECL(int) RTZipXarFsStreamFromIoStream(RTVFSIOSTREAM hVfsIosIn, uint32_t fFlags, PRTVFSFSSTREAM phVfsFss);
|
---|
512 |
|
---|
513 | /**
|
---|
514 | * Opens a CPIO filesystem stream.
|
---|
515 | *
|
---|
516 | * This is used to extract, list or check a CPIO archive.
|
---|
517 | *
|
---|
518 | * @returns IPRT status code.
|
---|
519 | *
|
---|
520 | * @param hVfsIosIn The input stream. The reference is not
|
---|
521 | * consumed, instead another one is retained.
|
---|
522 | * @param fFlags Flags, MBZ.
|
---|
523 | * @param phVfsFss Where to return the handle to the CPIO
|
---|
524 | * filesystem stream.
|
---|
525 | */
|
---|
526 | RTDECL(int) RTZipCpioFsStreamFromIoStream(RTVFSIOSTREAM hVfsIosIn, uint32_t fFlags, PRTVFSFSSTREAM phVfsFss);
|
---|
527 |
|
---|
528 | /** @} */
|
---|
529 |
|
---|
530 | RT_C_DECLS_END
|
---|
531 |
|
---|
532 | #endif /* !IPRT_INCLUDED_zip_h */
|
---|
533 |
|
---|