crypt.h | crypt.h | |||
---|---|---|---|---|
skipping to change at line 36 | skipping to change at line 36 | |||
Encryption is not supported. | Encryption is not supported. | |||
*/ | */ | |||
#include "quazip_global.h" | #include "quazip_global.h" | |||
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8 )) | #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8 )) | |||
/*********************************************************************** | /*********************************************************************** | |||
* Return the next byte in the pseudo-random sequence | * Return the next byte in the pseudo-random sequence | |||
*/ | */ | |||
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_ tab UNUSED) | static int decrypt_byte(unsigned long* pkeys, const z_crc_t FAR * pcrc_32_t ab UNUSED) | |||
{ | { | |||
//(void) pcrc_32_tab; /* avoid "unused parameter" warning */ | //(void) pcrc_32_tab; /* avoid "unused parameter" warning */ | |||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an | |||
* unpredictable manner on 16-bit systems; not a proble m | * unpredictable manner on 16-bit systems; not a proble m | |||
* with any known compiler so far, though */ | * with any known compiler so far, though */ | |||
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; | temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; | |||
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); | return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); | |||
} | } | |||
/*********************************************************************** | /*********************************************************************** | |||
* Update the encryption keys with the next byte of plain text | * Update the encryption keys with the next byte of plain text | |||
*/ | */ | |||
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_ta b,int c) | static int update_keys(unsigned long* pkeys,const z_crc_t FAR * pcrc_32_tab ,int c) | |||
{ | { | |||
(*(pkeys+0)) = CRC32((*(pkeys+0)), c); | (*(pkeys+0)) = CRC32((*(pkeys+0)), c); | |||
(*(pkeys+1)) += (*(pkeys+0)) & 0xff; | (*(pkeys+1)) += (*(pkeys+0)) & 0xff; | |||
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; | |||
{ | { | |||
register int keyshift = (int)((*(pkeys+1)) >> 24); | register int keyshift = (int)((*(pkeys+1)) >> 24); | |||
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); | (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); | |||
} | } | |||
return c; | return c; | |||
} | } | |||
/*********************************************************************** | /*********************************************************************** | |||
* Initialize the encryption keys and the random header according to | * Initialize the encryption keys and the random header according to | |||
* the given password. | * the given password. | |||
*/ | */ | |||
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigne d long* pcrc_32_tab) | static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t FAR * pcrc_32_tab) | |||
{ | { | |||
*(pkeys+0) = 305419896L; | *(pkeys+0) = 305419896L; | |||
*(pkeys+1) = 591751049L; | *(pkeys+1) = 591751049L; | |||
*(pkeys+2) = 878082192L; | *(pkeys+2) = 878082192L; | |||
while (*passwd != '\0') { | while (*passwd != '\0') { | |||
update_keys(pkeys,pcrc_32_tab,(int)*passwd); | update_keys(pkeys,pcrc_32_tab,(int)*passwd); | |||
passwd++; | passwd++; | |||
} | } | |||
} | } | |||
skipping to change at line 96 | skipping to change at line 96 | |||
/* "last resort" source for second part of crypt seed pattern */ | /* "last resort" source for second part of crypt seed pattern */ | |||
# ifndef ZCR_SEED2 | # ifndef ZCR_SEED2 | |||
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */ | # define ZCR_SEED2 3141592654UL /* use PI as default pattern */ | |||
# endif | # endif | |||
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypti ng) | static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypti ng) | |||
const char *passwd; /* password string */ | const char *passwd; /* password string */ | |||
unsigned char *buf; /* where to write header */ | unsigned char *buf; /* where to write header */ | |||
int bufSize; | int bufSize; | |||
unsigned long* pkeys; | unsigned long* pkeys; | |||
const unsigned long* pcrc_32_tab; | const z_crc_t FAR * pcrc_32_tab; | |||
unsigned long crcForCrypting; | unsigned long crcForCrypting; | |||
{ | { | |||
int n; /* index in random header */ | int n; /* index in random header */ | |||
int t; /* temporary */ | int t; /* temporary */ | |||
int c; /* random byte */ | int c; /* random byte */ | |||
unsigned char header[RAND_HEAD_LEN-2]; /* random header */ | unsigned char header[RAND_HEAD_LEN-2]; /* random header */ | |||
static unsigned calls = 0; /* ensure different random header each tim e */ | static unsigned calls = 0; /* ensure different random header each tim e */ | |||
if (bufSize<RAND_HEAD_LEN) | if (bufSize<RAND_HEAD_LEN) | |||
return 0; | return 0; | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 4 lines changed or added | |||
ioapi.h | ioapi.h | |||
---|---|---|---|---|
/* ioapi.h -- IO base function header for compress/uncompress .zip | /* ioapi.h -- IO base function header for compress/uncompress .zip | |||
files using zlib + zip or unzip API | part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip. html ) | |||
Version 1.01e, February 12th, 2005 | Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.wini mage.com/zLibDll/minizip.html ) | |||
Copyright (C) 1998-2005 Gilles Vollant | Modifications for Zip64 support | |||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) | ||||
Modified by Sergey A. Tachenov to integrate with Qt. | Modified by Sergey A. Tachenov to allow QIODevice API usage. | |||
For more info read MiniZip_info.txt | ||||
Changes | ||||
Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux | ||||
. (might need to find a better why for this) | ||||
Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files woul | ||||
d work on linux. | ||||
More if/def section may be needed to support other platforms | ||||
Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they wo | ||||
uld compile on windows. | ||||
(but you should use iowin32.c for windows instead | ||||
) | ||||
*/ | ||||
#ifndef _ZLIBIOAPI64_H | ||||
#define _ZLIBIOAPI64_H | ||||
#if (!defined(_WIN32)) && (!defined(WIN32)) | ||||
// Linux needs this to support file operation on files larger then 4+GB | ||||
// But might need better if/def to select just the platforms that needs t | ||||
hem. | ||||
#ifndef __USE_FILE_OFFSET64 | ||||
#define __USE_FILE_OFFSET64 | ||||
#endif | ||||
#ifndef __USE_LARGEFILE64 | ||||
#define __USE_LARGEFILE64 | ||||
#endif | ||||
#ifndef _LARGEFILE64_SOURCE | ||||
#define _LARGEFILE64_SOURCE | ||||
#endif | ||||
#ifndef _FILE_OFFSET_BIT | ||||
#define _FILE_OFFSET_BIT 64 | ||||
#endif | ||||
#endif | ||||
#include <stdio.h> | ||||
#include <stdlib.h> | ||||
#include "zlib.h" | ||||
#if defined(USE_FILE32API) | ||||
#define fopen64 fopen | ||||
#define ftello64 ftell | ||||
#define fseeko64 fseek | ||||
#else | ||||
#ifdef _MSC_VER | ||||
#define fopen64 fopen | ||||
#if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) | ||||
#define ftello64 _ftelli64 | ||||
#define fseeko64 _fseeki64 | ||||
#else // old MSC | ||||
#define ftello64 ftell | ||||
#define fseeko64 fseek | ||||
#endif | ||||
#endif | ||||
#endif | ||||
/* | ||||
#ifndef ZPOS64_T | ||||
#ifdef _WIN32 | ||||
#define ZPOS64_T fpos_t | ||||
#else | ||||
#include <stdint.h> | ||||
#define ZPOS64_T uint64_t | ||||
#endif | ||||
#endif | ||||
*/ | */ | |||
#ifndef _ZLIBIOAPI_H | #ifdef HAVE_MINIZIP64_CONF_H | |||
#define _ZLIBIOAPI_H | #include "mz64conf.h" | |||
#endif | ||||
/* a type choosen by DEFINE */ | ||||
#ifdef HAVE_64BIT_INT_CUSTOM | ||||
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; | ||||
#else | ||||
#ifdef HAS_STDINT_H | ||||
#include "stdint.h" | ||||
typedef uint64_t ZPOS64_T; | ||||
#else | ||||
#if defined(_MSC_VER) || defined(__BORLANDC__) | ||||
typedef unsigned __int64 ZPOS64_T; | ||||
#else | ||||
typedef unsigned long long int ZPOS64_T; | ||||
#endif | ||||
#endif | ||||
#endif | ||||
#ifdef __cplusplus | ||||
extern "C" { | ||||
#endif | ||||
#ifndef OF | #ifndef OF | |||
#define OF _Z_OF | #define OF _Z_OF | |||
#endif | #endif | |||
#define ZLIB_FILEFUNC_SEEK_CUR (1) | #define ZLIB_FILEFUNC_SEEK_CUR (1) | |||
#define ZLIB_FILEFUNC_SEEK_END (2) | #define ZLIB_FILEFUNC_SEEK_END (2) | |||
#define ZLIB_FILEFUNC_SEEK_SET (0) | #define ZLIB_FILEFUNC_SEEK_SET (0) | |||
#define ZLIB_FILEFUNC_MODE_READ (1) | #define ZLIB_FILEFUNC_MODE_READ (1) | |||
#define ZLIB_FILEFUNC_MODE_WRITE (2) | #define ZLIB_FILEFUNC_MODE_WRITE (2) | |||
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) | |||
#define ZLIB_FILEFUNC_MODE_EXISTING (4) | #define ZLIB_FILEFUNC_MODE_EXISTING (4) | |||
#define ZLIB_FILEFUNC_MODE_CREATE (8) | #define ZLIB_FILEFUNC_MODE_CREATE (8) | |||
#ifndef ZCALLBACK | #ifndef ZCALLBACK | |||
#if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_W | ||||
INDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) | ||||
#define ZCALLBACK CALLBACK | ||||
#else | ||||
#define ZCALLBACK | ||||
#endif | ||||
#endif | ||||
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, voidpf | ||||
file, int mode)); | ||||
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf | ||||
stream, void* buf, uLong size)); | ||||
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf | ||||
stream, const void* buf, uLong size)); | ||||
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf | ||||
stream)); | ||||
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf | ||||
stream)); | ||||
#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined( | typedef uLong (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidp | |||
CALLBACK) && defined (USEWINDOWS_CALLBACK) | f stream)); | |||
#define ZCALLBACK CALLBACK | typedef int (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf | |||
#else | stream, uLong offset, int origin)); | |||
#define ZCALLBACK | ||||
#endif | ||||
#endif | ||||
#ifdef __cplusplus | ||||
extern "C" { | ||||
#endif | ||||
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, voidpf file, | ||||
int mode)); | ||||
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream | ||||
, void* buf, uLong size)); | ||||
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf strea | ||||
m, const void* buf, uLong size)); | ||||
typedef uLong (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf strea | ||||
m)); | ||||
typedef int (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, | ||||
uLong offset, int origin)); | ||||
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf strea | ||||
m)); | ||||
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf s | ||||
tream)); | ||||
/* here is the "old" 32 bits structure structure */ | ||||
typedef struct zlib_filefunc_def_s | typedef struct zlib_filefunc_def_s | |||
{ | { | |||
open_file_func zopen_file; | open_file_func zopen_file; | |||
read_file_func zread_file; | read_file_func zread_file; | |||
write_file_func zwrite_file; | write_file_func zwrite_file; | |||
tell_file_func ztell_file; | tell_file_func ztell_file; | |||
seek_file_func zseek_file; | seek_file_func zseek_file; | |||
close_file_func zclose_file; | close_file_func zclose_file; | |||
testerror_file_func zerror_file; | testerror_file_func zerror_file; | |||
voidpf opaque; | voidpf opaque; | |||
} zlib_filefunc_def; | } zlib_filefunc_def; | |||
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf | ||||
stream)); | ||||
typedef int (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf | ||||
stream, ZPOS64_T offset, int origin)); | ||||
typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, voidpf | ||||
file, int mode)); | ||||
typedef struct zlib_filefunc64_def_s | ||||
{ | ||||
open64_file_func zopen64_file; | ||||
read_file_func zread_file; | ||||
write_file_func zwrite_file; | ||||
tell64_file_func ztell64_file; | ||||
seek64_file_func zseek64_file; | ||||
close_file_func zclose_file; | ||||
testerror_file_func zerror_file; | ||||
voidpf opaque; | ||||
} zlib_filefunc64_def; | ||||
void fill_qiodevice64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def) | ||||
); | ||||
void fill_qiodevice_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); | void fill_qiodevice_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); | |||
#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((fi | /* now internal definition, only for zip.c and unzip.h */ | |||
lefunc).opaque,filestream,buf,size)) | typedef struct zlib_filefunc64_32_def_s | |||
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))(( | { | |||
filefunc).opaque,filestream,buf,size)) | zlib_filefunc64_def zfile_func64; | |||
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).o | open_file_func zopen32_file; | |||
paque,filestream)) | tell_file_func ztell32_file; | |||
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((fi | seek_file_func zseek32_file; | |||
lefunc).opaque,filestream,pos,mode)) | } zlib_filefunc64_32_def; | |||
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc) | ||||
.opaque,filestream)) | #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func | |||
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc) | 64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) | |||
.opaque,filestream)) | #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func | |||
64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) | ||||
//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_fi | ||||
le)) ((filefunc).opaque,filestream)) | ||||
//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_fi | ||||
le)) ((filefunc).opaque,filestream,pos,mode)) | ||||
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func | ||||
64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) | ||||
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func | ||||
64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) | ||||
voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf file | ||||
,int mode)); | ||||
int call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf file | ||||
stream, ZPOS64_T offset, int origin)); | ||||
ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf fi | ||||
lestream)); | ||||
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* | ||||
p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); | ||||
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)) | ||||
,(filename),(mode))) | ||||
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)) | ||||
,(filestream))) | ||||
#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)) | ||||
,(filestream),(pos),(mode))) | ||||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
#endif | #endif | |||
End of changes. 10 change blocks. | ||||
44 lines changed or deleted | 181 lines changed or added | |||
quazip.h | quazip.h | |||
---|---|---|---|---|
skipping to change at line 177 | skipping to change at line 177 | |||
* Argument \a ioApi specifies IO function set for ZIP/UNZIP | * Argument \a ioApi specifies IO function set for ZIP/UNZIP | |||
* package to use. See unzip.h, zip.h and ioapi.h for details. Note | * package to use. See unzip.h, zip.h and ioapi.h for details. Note | |||
* that IO API for QuaZip is different from the original package. | * that IO API for QuaZip is different from the original package. | |||
* The file path argument was changed to be of type \c voidpf, and | * The file path argument was changed to be of type \c voidpf, and | |||
* QuaZip passes a QIODevice pointer there. This QIODevice is either | * QuaZip passes a QIODevice pointer there. This QIODevice is either | |||
* set explicitly via setIoDevice() or the QuaZip(QIODevice*) | * set explicitly via setIoDevice() or the QuaZip(QIODevice*) | |||
* constructor, or it is created internally when opening the archive | * constructor, or it is created internally when opening the archive | |||
* by its file name. The default API (qioapi.cpp) just delegates | * by its file name. The default API (qioapi.cpp) just delegates | |||
* everything to the QIODevice API. Not only this allows to use a | * everything to the QIODevice API. Not only this allows to use a | |||
* QIODevice instead of file name, but also has a nice side effect | * QIODevice instead of file name, but also has a nice side effect | |||
* of raising the file size limit from 2G to 4G. | * of raising the file size limit from 2G to 4G (in non-zip64 archives) | |||
. | ||||
* | ||||
* \note If the zip64 support is needed, the ioApi argument \em must be | ||||
NULL | ||||
* because due to the backwards compatibility issues it can be used to | ||||
* provide a 32-bit API only. | ||||
* | * | |||
* In short: just forget about the \a ioApi argument and you'll be | * In short: just forget about the \a ioApi argument and you'll be | |||
* fine. | * fine. | |||
**/ | **/ | |||
bool open(Mode mode, zlib_filefunc_def *ioApi =NULL); | bool open(Mode mode, zlib_filefunc_def *ioApi =NULL); | |||
/// Closes ZIP file. | /// Closes ZIP file. | |||
/** Call getZipError() to determine if the close was successful. The | /** Call getZipError() to determine if the close was successful. The | |||
* underlying QIODevice is also closed, regardless of whether it was | * underlying QIODevice is also closed, regardless of whether it was | |||
* set explicitly or not. */ | * set explicitly or not. */ | |||
void close(); | void close(); | |||
skipping to change at line 333 | skipping to change at line 337 | |||
/// Retrieves information about the current file. | /// Retrieves information about the current file. | |||
/** Fills the structure pointed by \a info. Returns \c true on | /** Fills the structure pointed by \a info. Returns \c true on | |||
* success, \c false otherwise. In the latter case structure pointed | * success, \c false otherwise. In the latter case structure pointed | |||
* by \a info remains untouched. If there was an error, | * by \a info remains untouched. If there was an error, | |||
* getZipError() returns error code. | * getZipError() returns error code. | |||
* | * | |||
* Should be used only in QuaZip::mdUnzip mode. | * Should be used only in QuaZip::mdUnzip mode. | |||
* | * | |||
* Does nothing and returns \c false in any of the following cases. | * Does nothing and returns \c false in any of the following cases. | |||
* - ZIP is not open; | * - ZIP is not open; | |||
* - ZIP does not have current file; | * - ZIP does not have current file. | |||
* - \a info is \c NULL; | ||||
* | * | |||
* In all these cases getZipError() returns \c UNZ_OK since there | * In both cases getZipError() returns \c UNZ_OK since there | |||
* is no ZIP/UNZIP API call. | * is no ZIP/UNZIP API call. | |||
* | ||||
* This overload doesn't support zip64. | ||||
* | ||||
* \sa getCurrentFileInfo(QuaZipFileInfo64* info)const | ||||
**/ | **/ | |||
bool getCurrentFileInfo(QuaZipFileInfo* info)const; | bool getCurrentFileInfo(QuaZipFileInfo* info)const; | |||
/// Retrieves information about the current file. | ||||
/** \overload | ||||
* | ||||
* This function supports zip64. If the archive doesn't use zip64, it i | ||||
s | ||||
* completely equivalent to getCurrentFileInfo(QuaZipFileInfo* info) | ||||
* except for the argument type. | ||||
* | ||||
* \sa | ||||
**/ | ||||
bool getCurrentFileInfo(QuaZipFileInfo64* info)const; | ||||
/// Returns the current file name. | /// Returns the current file name. | |||
/** Equivalent to calling getCurrentFileInfo() and then getting \c | /** Equivalent to calling getCurrentFileInfo() and then getting \c | |||
* name field of the QuaZipFileInfo structure, but faster and more | * name field of the QuaZipFileInfo structure, but faster and more | |||
* convenient. | * convenient. | |||
* | * | |||
* Should be used only in QuaZip::mdUnzip mode. | * Should be used only in QuaZip::mdUnzip mode. | |||
**/ | **/ | |||
QString getCurrentFileName()const; | QString getCurrentFileName()const; | |||
/// Returns \c unzFile handle. | /// Returns \c unzFile handle. | |||
/** You can use this handle to directly call UNZIP part of the | /** You can use this handle to directly call UNZIP part of the | |||
skipping to change at line 417 | skipping to change at line 434 | |||
*/ | */ | |||
QStringList getFileNameList() const; | QStringList getFileNameList() const; | |||
/// Returns information list about all files inside the archive. | /// Returns information list about all files inside the archive. | |||
/** | /** | |||
\return A list of QuaZipFileInfo objects or an empty list if there | \return A list of QuaZipFileInfo objects or an empty list if there | |||
was an error or if the archive is empty (call getZipError() to | was an error or if the archive is empty (call getZipError() to | |||
figure out which). | figure out which). | |||
\sa getFileNameList() | \sa getFileNameList() | |||
*/ | */ | |||
QList<QuaZipFileInfo> getFileInfoList() const; | QList<QuaZipFileInfo> getFileInfoList() const; | |||
/// Enables the zip64 mode. | ||||
/** | ||||
* @param zip64 If \c true, the zip64 mode is enabled, disabled otherwi | ||||
se. | ||||
* | ||||
* Once this is enabled, all new files (until the mode is disabled agai | ||||
n) | ||||
* will be created in the zip64 mode, thus enabling the ability to writ | ||||
e | ||||
* files larger than 4 GB. By default, the zip64 mode is off due to | ||||
* compatibility reasons. | ||||
* | ||||
* \sa isZip64Enabled() | ||||
*/ | ||||
void setZip64Enabled(bool zip64); | ||||
/// Returns whether the zip64 mode is enabled. | ||||
/** | ||||
* @return \c true if and only if the zip64 mode is enabled. | ||||
* | ||||
* \sa setZip64Enabled() | ||||
*/ | ||||
bool isZip64Enabled() const; | ||||
/// Sets the default file name codec to use. | /// Sets the default file name codec to use. | |||
/** | /** | |||
* The default codec is used by the constructors, so calling this funct ion | * The default codec is used by the constructors, so calling this funct ion | |||
* won't affect the QuaZip instances already created at that moment. | * won't affect the QuaZip instances already created at that moment. | |||
* | * | |||
* The codec specified here can be overriden by calling setFileNameCode c(). | * The codec specified here can be overriden by calling setFileNameCode c(). | |||
* If neither function is called, QTextCodec::codecForLocale() will be used | * If neither function is called, QTextCodec::codecForLocale() will be used | |||
* to decode or encode file names. Use this function with caution if | * to decode or encode file names. Use this function with caution if | |||
* the application uses other libraries that depend on QuaZIP. Those | * the application uses other libraries that depend on QuaZIP. Those | |||
* libraries can either call this function by themselves, thus overridi ng | * libraries can either call this function by themselves, thus overridi ng | |||
End of changes. 6 change blocks. | ||||
4 lines changed or deleted | 46 lines changed or added | |||
quazipfileinfo.h | quazipfileinfo.h | |||
---|---|---|---|---|
skipping to change at line 73 | skipping to change at line 73 | |||
/// Extra field. | /// Extra field. | |||
QByteArray extra; | QByteArray extra; | |||
/// Get the file permissions. | /// Get the file permissions. | |||
/** | /** | |||
Returns the high 16 bits of external attributes converted to | Returns the high 16 bits of external attributes converted to | |||
QFile::Permissions. | QFile::Permissions. | |||
*/ | */ | |||
QFile::Permissions getPermissions() const; | QFile::Permissions getPermissions() const; | |||
}; | }; | |||
/// Information about a file inside archive (with zip64 support). | ||||
/** Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to | ||||
* fill this structure. */ | ||||
struct QUAZIP_EXPORT QuaZipFileInfo64 { | ||||
/// File name. | ||||
QString name; | ||||
/// Version created by. | ||||
quint16 versionCreated; | ||||
/// Version needed to extract. | ||||
quint16 versionNeeded; | ||||
/// General purpose flags. | ||||
quint16 flags; | ||||
/// Compression method. | ||||
quint16 method; | ||||
/// Last modification date and time. | ||||
QDateTime dateTime; | ||||
/// CRC. | ||||
quint32 crc; | ||||
/// Compressed file size. | ||||
quint64 compressedSize; | ||||
/// Uncompressed file size. | ||||
quint64 uncompressedSize; | ||||
/// Disk number start. | ||||
quint16 diskNumberStart; | ||||
/// Internal file attributes. | ||||
quint16 internalAttr; | ||||
/// External file attributes. | ||||
quint32 externalAttr; | ||||
/// Comment. | ||||
QString comment; | ||||
/// Extra field. | ||||
QByteArray extra; | ||||
/// Get the file permissions. | ||||
/** | ||||
Returns the high 16 bits of external attributes converted to | ||||
QFile::Permissions. | ||||
*/ | ||||
QFile::Permissions getPermissions() const; | ||||
}; | ||||
#endif | #endif | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 40 lines changed or added | |||
quazipnewinfo.h | quazipnewinfo.h | |||
---|---|---|---|---|
skipping to change at line 38 | skipping to change at line 38 | |||
#include <QFile> | #include <QFile> | |||
#include <QString> | #include <QString> | |||
#include "quazip_global.h" | #include "quazip_global.h" | |||
/// Information about a file to be created. | /// Information about a file to be created. | |||
/** This structure holds information about a file to be created inside | /** This structure holds information about a file to be created inside | |||
* ZIP archive. At least name should be set to something correct before | * ZIP archive. At least name should be set to something correct before | |||
* passing this structure to | * passing this structure to | |||
* QuaZipFile::open(OpenMode,const QuaZipNewInfo&,int,int,bool). | * QuaZipFile::open(OpenMode,const QuaZipNewInfo&,int,int,bool). | |||
* | ||||
* Zip64 support of this structure is slightly limited: in the raw mode (wh | ||||
en | ||||
* a pre-compressed file is written into a ZIP file as-is), it is necessary | ||||
* to specify the uncompressed file size and the appropriate field is 32 bi | ||||
t. | ||||
* Since the raw mode is used extremely rare, there is no real need to have | ||||
* a separate QuaZipNewInfo64 structure like QuaZipFileInfo64. It may be ad | ||||
ded | ||||
* in the future though, if there is a demand for the raw mode with zip64 | ||||
* archives. | ||||
**/ | **/ | |||
struct QUAZIP_EXPORT QuaZipNewInfo { | struct QUAZIP_EXPORT QuaZipNewInfo { | |||
/// File name. | /// File name. | |||
/** This field holds file name inside archive, including path relative | /** This field holds file name inside archive, including path relative | |||
* to archive root. | * to archive root. | |||
**/ | **/ | |||
QString name; | QString name; | |||
/// File timestamp. | /// File timestamp. | |||
/** This is the last file modification date and time. Will be stored | /** This is the last file modification date and time. Will be stored | |||
* in the archive central directory. It is a good practice to set it | * in the archive central directory. It is a good practice to set it | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 11 lines changed or added | |||
unzip.h | unzip.h | |||
---|---|---|---|---|
/* unzip.h -- IO for uncompress .zip files using zlib | /* unzip.h -- IO for uncompress .zip files using zlib | |||
Version 1.01e, February 12th, 2005 | Version 1.1, February 14h, 2010 | |||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip. | ||||
html ) | ||||
Copyright (C) 1998-2005 Gilles Vollant | Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.wini mage.com/zLibDll/minizip.html ) | |||
This unzip package allow extract file from .ZIP file, compatible with PK | Modifications of Unzip for Zip64 | |||
Zip 2.04g | Copyright (C) 2007-2008 Even Rouault | |||
WinZip, InfoZip tools and compatible. | ||||
Multi volume ZipFile (span) are not supported. | Modifications for Zip64 support on both zip and unzip | |||
Encryption compatible with pkzip 2.04g only supported | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) | |||
Old compressions used by old PKZip 1.x are not supported | ||||
I WAIT FEEDBACK at mail info@winimage.com | For more info read MiniZip_info.txt | |||
Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution | ||||
Condition of use and distribution are the same than zlib : | ------------------------------------------------------------------ | |||
--------------- | ||||
Condition of use and distribution are the same than zlib : | ||||
This software is provided 'as-is', without any express or implied | This software is provided 'as-is', without any express or implied | |||
warranty. In no event will the authors be held liable for any damages | warranty. In no event will the authors be held liable for any damages | |||
arising from the use of this software. | arising from the use of this software. | |||
Permission is granted to anyone to use this software for any purpose, | Permission is granted to anyone to use this software for any purpose, | |||
including commercial applications, and to alter it and redistribute it | including commercial applications, and to alter it and redistribute it | |||
freely, subject to the following restrictions: | freely, subject to the following restrictions: | |||
1. The origin of this software must not be misrepresented; you must not | 1. The origin of this software must not be misrepresented; you must not | |||
claim that you wrote the original software. If you use this software | claim that you wrote the original software. If you use this software | |||
in a product, an acknowledgment in the product documentation would be | in a product, an acknowledgment in the product documentation would be | |||
appreciated but is not required. | appreciated but is not required. | |||
2. Altered source versions must be plainly marked as such, and must not b e | 2. Altered source versions must be plainly marked as such, and must not b e | |||
misrepresented as being the original software. | misrepresented as being the original software. | |||
3. This notice may not be removed or altered from any source distribution . | 3. This notice may not be removed or altered from any source distribution . | |||
Modified by Sergey A. Tachenov to integrate with Qt. | ------------------------------------------------------------------------- -------- | |||
*/ | Changes | |||
See header of unzip64.c | ||||
/* for more info about .ZIP format, see | ||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip | ||||
http://www.info-zip.org/pub/infozip/doc/ | ||||
PkWare has also a specification at : | ||||
ftp://ftp.pkware.com/probdesc.zip | ||||
*/ | */ | |||
#ifndef _unz_H | #ifndef _unz64_H | |||
#define _unz_H | #define _unz64_H | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
#ifndef _ZLIB_H | #ifndef _ZLIB_H | |||
#include "zlib.h" | #include "zlib.h" | |||
#endif | #endif | |||
#ifndef _ZLIBIOAPI_H | #ifndef _ZLIBIOAPI_H | |||
#include "ioapi.h" | #include "ioapi.h" | |||
#endif | #endif | |||
#ifdef HAVE_BZIP2 | ||||
#include "bzlib.h" | ||||
#endif | ||||
#define Z_BZIP2ED 12 | ||||
#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) | #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) | |||
/* like the STRICT of WIN32, we define a pointer that cannot be converted | /* like the STRICT of WIN32, we define a pointer that cannot be converted | |||
from (void*) without cast */ | from (void*) without cast */ | |||
typedef struct TagunzFile__ { int unused; } unzFile__; | typedef struct TagunzFile__ { int unused; } unzFile__; | |||
typedef unzFile__ *unzFile; | typedef unzFile__ *unzFile; | |||
#else | #else | |||
typedef voidp unzFile; | typedef voidp unzFile; | |||
#endif | #endif | |||
#define UNZ_OK (0) | #define UNZ_OK (0) | |||
skipping to change at line 91 | skipping to change at line 95 | |||
uInt tm_sec; /* seconds after the minute - [0,59] */ | uInt tm_sec; /* seconds after the minute - [0,59] */ | |||
uInt tm_min; /* minutes after the hour - [0,59] */ | uInt tm_min; /* minutes after the hour - [0,59] */ | |||
uInt tm_hour; /* hours since midnight - [0,23] */ | uInt tm_hour; /* hours since midnight - [0,23] */ | |||
uInt tm_mday; /* day of the month - [1,31] */ | uInt tm_mday; /* day of the month - [1,31] */ | |||
uInt tm_mon; /* months since January - [0,11] */ | uInt tm_mon; /* months since January - [0,11] */ | |||
uInt tm_year; /* years - [1980..2044] */ | uInt tm_year; /* years - [1980..2044] */ | |||
} tm_unz; | } tm_unz; | |||
/* unz_global_info structure contain global data about the ZIPfile | /* unz_global_info structure contain global data about the ZIPfile | |||
These data comes from the end of central dir */ | These data comes from the end of central dir */ | |||
typedef struct unz_global_info64_s | ||||
{ | ||||
ZPOS64_T number_entry; /* total number of entries in | ||||
the central dir on this disk */ | ||||
uLong size_comment; /* size of the global comment of the zipfil | ||||
e */ | ||||
} unz_global_info64; | ||||
typedef struct unz_global_info_s | typedef struct unz_global_info_s | |||
{ | { | |||
uLong number_entry; /* total number of entries in | uLong number_entry; /* total number of entries in | |||
the central dir on this disk */ | the central dir on this disk */ | |||
uLong size_comment; /* size of the global comment of the zipfil e */ | uLong size_comment; /* size of the global comment of the zipfil e */ | |||
} unz_global_info; | } unz_global_info; | |||
/* unz_file_info contain information about a file in the zipfile */ | /* unz_file_info contain information about a file in the zipfile */ | |||
typedef struct unz_file_info64_s | ||||
{ | ||||
uLong version; /* version made by 2 bytes | ||||
*/ | ||||
uLong version_needed; /* version needed to extract 2 bytes | ||||
*/ | ||||
uLong flag; /* general purpose bit flag 2 bytes | ||||
*/ | ||||
uLong compression_method; /* compression method 2 bytes | ||||
*/ | ||||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes | ||||
*/ | ||||
uLong crc; /* crc-32 4 bytes | ||||
*/ | ||||
ZPOS64_T compressed_size; /* compressed size 8 bytes | ||||
*/ | ||||
ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes | ||||
*/ | ||||
uLong size_filename; /* filename length 2 bytes | ||||
*/ | ||||
uLong size_file_extra; /* extra field length 2 bytes | ||||
*/ | ||||
uLong size_file_comment; /* file comment length 2 bytes | ||||
*/ | ||||
uLong disk_num_start; /* disk number start 2 bytes | ||||
*/ | ||||
uLong internal_fa; /* internal file attributes 2 bytes | ||||
*/ | ||||
uLong external_fa; /* external file attributes 4 bytes | ||||
*/ | ||||
tm_unz tmu_date; | ||||
} unz_file_info64; | ||||
typedef struct unz_file_info_s | typedef struct unz_file_info_s | |||
{ | { | |||
uLong version; /* version made by 2 bytes */ | uLong version; /* version made by 2 bytes */ | |||
uLong version_needed; /* version needed to extract 2 bytes */ | uLong version_needed; /* version needed to extract 2 bytes */ | |||
uLong flag; /* general purpose bit flag 2 bytes */ | uLong flag; /* general purpose bit flag 2 bytes */ | |||
uLong compression_method; /* compression method 2 bytes */ | uLong compression_method; /* compression method 2 bytes */ | |||
uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ | uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ | |||
uLong crc; /* crc-32 4 bytes */ | uLong crc; /* crc-32 4 bytes */ | |||
uLong compressed_size; /* compressed size 4 bytes */ | uLong compressed_size; /* compressed size 4 bytes */ | |||
uLong uncompressed_size; /* uncompressed size 4 bytes */ | uLong uncompressed_size; /* uncompressed size 4 bytes */ | |||
skipping to change at line 133 | skipping to change at line 165 | |||
/* | /* | |||
Compare two filename (fileName1,fileName2). | Compare two filename (fileName1,fileName2). | |||
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) | If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) | |||
If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmp i | If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmp i | |||
or strcasecmp) | or strcasecmp) | |||
If iCaseSenisivity = 0, case sensitivity is defaut of your operating sys tem | If iCaseSenisivity = 0, case sensitivity is defaut of your operating sys tem | |||
(like 1 on Unix, 2 on Windows) | (like 1 on Unix, 2 on Windows) | |||
*/ | */ | |||
extern unzFile ZEXPORT unzOpen OF((voidpf file)); | extern unzFile ZEXPORT unzOpen OF((voidpf file)); | |||
extern unzFile ZEXPORT unzOpen64 OF((voidpf file)); | ||||
/* | /* | |||
Open a Zip file. path contain whatever zopen_file from the IO API | Open a Zip file. path contain the full pathname (by example, | |||
accepts. For Qt implementation it is a pointer to QIODevice, for | on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix compute | |||
fopen() implementation it's a file name. | r | |||
"zlib/zlib113.zip". | ||||
If the zipfile cannot be opened (file don't exist or in not valid), th e | If the zipfile cannot be opened (file don't exist or in not valid), th e | |||
return value is NULL. | return value is NULL. | |||
Else, the return value is a unzFile Handle, usable with other function | Else, the return value is a unzFile Handle, usable with other function | |||
of this unzip package. | of this unzip package. | |||
the "64" function take a const void* pointer, because the path is just | ||||
the | ||||
value passed to the open64_file_func callback. | ||||
Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the | ||||
path | ||||
is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const | ||||
char* | ||||
does not describe the reality | ||||
*/ | */ | |||
extern unzFile ZEXPORT unzOpen2 OF((voidpf file, | extern unzFile ZEXPORT unzOpen2 OF((voidpf file, | |||
zlib_filefunc_def* pzlib_filefunc_def)) ; | zlib_filefunc_def* pzlib_filefunc_def)) ; | |||
/* | /* | |||
Open a Zip file, like unzOpen, but provide a set of file low level API | Open a Zip file, like unzOpen, but provide a set of file low level API | |||
for read/write the zip file (see ioapi.h) | for read/write the zip file (see ioapi.h) | |||
*/ | */ | |||
extern unzFile ZEXPORT unzOpen2_64 OF((voidpf file, | ||||
zlib_filefunc64_def* pzlib_filefunc_def | ||||
)); | ||||
/* | ||||
Open a Zip file, like unz64Open, but provide a set of file low level API | ||||
for read/write the zip file (see ioapi.h) | ||||
*/ | ||||
extern int ZEXPORT unzClose OF((unzFile file)); | extern int ZEXPORT unzClose OF((unzFile file)); | |||
/* | /* | |||
Close a ZipFile opened with unzipOpen. | Close a ZipFile opened with unzipOpen. | |||
If there is files inside the .Zip opened with unzOpenCurrentFile (see lat er), | If there is files inside the .Zip opened with unzOpenCurrentFile (see lat er), | |||
these files MUST be closed with unzipCloseCurrentFile before call unzip Close. | these files MUST be closed with unzipCloseCurrentFile before call unzip Close. | |||
return UNZ_OK if there is no problem. */ | return UNZ_OK if there is no problem. */ | |||
extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, | extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, | |||
unz_global_info *pglobal_info)); | unz_global_info *pglobal_info)); | |||
extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, | ||||
unz_global_info64 *pglobal_info)); | ||||
/* | /* | |||
Write info about the ZipFile in the *pglobal_info structure. | Write info about the ZipFile in the *pglobal_info structure. | |||
No preparation of the structure is needed | No preparation of the structure is needed | |||
return UNZ_OK if there is no problem. */ | return UNZ_OK if there is no problem. */ | |||
extern int ZEXPORT unzGetGlobalComment OF((unzFile file, | extern int ZEXPORT unzGetGlobalComment OF((unzFile file, | |||
char *szComment, | char *szComment, | |||
uLong uSizeBuf)); | uLong uSizeBuf)); | |||
/* | /* | |||
Get the global comment string of the ZipFile, in the szComment buffer. | Get the global comment string of the ZipFile, in the szComment buffer. | |||
skipping to change at line 218 | skipping to change at line 266 | |||
} unz_file_pos; | } unz_file_pos; | |||
extern int ZEXPORT unzGetFilePos( | extern int ZEXPORT unzGetFilePos( | |||
unzFile file, | unzFile file, | |||
unz_file_pos* file_pos); | unz_file_pos* file_pos); | |||
extern int ZEXPORT unzGoToFilePos( | extern int ZEXPORT unzGoToFilePos( | |||
unzFile file, | unzFile file, | |||
unz_file_pos* file_pos); | unz_file_pos* file_pos); | |||
typedef struct unz64_file_pos_s | ||||
{ | ||||
ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */ | ||||
ZPOS64_T num_of_file; /* # of file */ | ||||
} unz64_file_pos; | ||||
extern int ZEXPORT unzGetFilePos64( | ||||
unzFile file, | ||||
unz64_file_pos* file_pos); | ||||
extern int ZEXPORT unzGoToFilePos64( | ||||
unzFile file, | ||||
const unz64_file_pos* file_pos); | ||||
/* ****************************************** */ | /* ****************************************** */ | |||
extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file, | ||||
unz_file_info64 *pfile_info, | ||||
char *szFileName, | ||||
uLong fileNameBufferSize, | ||||
void *extraField, | ||||
uLong extraFieldBufferSize, | ||||
char *szComment, | ||||
uLong commentBufferSize)); | ||||
extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, | extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, | |||
unz_file_info *pfile_info, | unz_file_info *pfile_info, | |||
char *szFileName, | char *szFileName, | |||
uLong fileNameBufferSize, | uLong fileNameBufferSize, | |||
void *extraField, | void *extraField, | |||
uLong extraFieldBufferSize, | uLong extraFieldBufferSize, | |||
char *szComment, | char *szComment, | |||
uLong commentBufferSize)); | uLong commentBufferSize)); | |||
/* | /* | |||
Get Info about the current file | Get Info about the current file | |||
skipping to change at line 241 | skipping to change at line 312 | |||
the current file | the current file | |||
if szFileName!=NULL, the filemane string will be copied in szFileName | if szFileName!=NULL, the filemane string will be copied in szFileName | |||
(fileNameBufferSize is the size of the buffer) | (fileNameBufferSize is the size of the buffer) | |||
if extraField!=NULL, the extra field information will be copied in extraF ield | if extraField!=NULL, the extra field information will be copied in extraF ield | |||
(extraFieldBufferSize is the size of the buffer). | (extraFieldBufferSize is the size of the buffer). | |||
This is the Central-header version of the extra field | This is the Central-header version of the extra field | |||
if szComment!=NULL, the comment string of the file will be copied in szCo mment | if szComment!=NULL, the comment string of the file will be copied in szCo mment | |||
(commentBufferSize is the size of the buffer) | (commentBufferSize is the size of the buffer) | |||
*/ | */ | |||
/** Addition for GDAL : START */ | ||||
extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file)); | ||||
/** Addition for GDAL : END */ | ||||
/************************************************************************** */ | /************************************************************************** */ | |||
/* for reading the content of the current zipfile, you can open it, read da ta | /* for reading the content of the current zipfile, you can open it, read da ta | |||
from it, and close it (you can close it before reading all the file) | from it, and close it (you can close it before reading all the file) | |||
*/ | */ | |||
extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); | extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); | |||
/* | /* | |||
Open for reading data the current file in the zipfile. | Open for reading data the current file in the zipfile. | |||
If there is no error, the return value is UNZ_OK. | If there is no error, the return value is UNZ_OK. | |||
*/ | */ | |||
skipping to change at line 308 | skipping to change at line 385 | |||
buf contain buffer where data must be copied | buf contain buffer where data must be copied | |||
len the size of buf. | len the size of buf. | |||
return the number of byte copied if somes bytes are copied | return the number of byte copied if somes bytes are copied | |||
return 0 if the end of file was reached | return 0 if the end of file was reached | |||
return <0 with error code if there is an error | return <0 with error code if there is an error | |||
(UNZ_ERRNO for IO error, or zLib error for uncompress error) | (UNZ_ERRNO for IO error, or zLib error for uncompress error) | |||
*/ | */ | |||
extern z_off_t ZEXPORT unztell OF((unzFile file)); | extern z_off_t ZEXPORT unztell OF((unzFile file)); | |||
extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); | ||||
/* | /* | |||
Give the current position in uncompressed data | Give the current position in uncompressed data | |||
*/ | */ | |||
extern int ZEXPORT unzeof OF((unzFile file)); | extern int ZEXPORT unzeof OF((unzFile file)); | |||
/* | /* | |||
return 1 if the end of file was reached, 0 elsewhere | return 1 if the end of file was reached, 0 elsewhere | |||
*/ | */ | |||
extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, | extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, | |||
skipping to change at line 336 | skipping to change at line 415 | |||
if buf!=NULL, len is the size of the buffer, the extra header is copied i n | if buf!=NULL, len is the size of the buffer, the extra header is copied i n | |||
buf. | buf. | |||
the return value is the number of bytes copied in buf, or (if <0) | the return value is the number of bytes copied in buf, or (if <0) | |||
the error code | the error code | |||
*/ | */ | |||
/************************************************************************** */ | /************************************************************************** */ | |||
/* Get the current file offset */ | /* Get the current file offset */ | |||
extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file); | ||||
extern uLong ZEXPORT unzGetOffset (unzFile file); | extern uLong ZEXPORT unzGetOffset (unzFile file); | |||
/* Set the current file offset */ | /* Set the current file offset */ | |||
extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos); | ||||
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); | extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
#endif /* _unz_H */ | #endif /* _unz64_H */ | |||
End of changes. 27 change blocks. | ||||
25 lines changed or deleted | 127 lines changed or added | |||
zip.h | zip.h | |||
---|---|---|---|---|
/* zip.h -- IO for compress .zip files using zlib | /* zip.h -- IO on .zip files using zlib | |||
Version 1.01e, February 12th, 2005 | Version 1.1, February 14h, 2010 | |||
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip. | ||||
html ) | ||||
Copyright (C) 1998-2005 Gilles Vollant | Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.wini mage.com/zLibDll/minizip.html ) | |||
This unzip package allow creates .ZIP file, compatible with PKZip 2.04g | Modifications for Zip64 support | |||
WinZip, InfoZip tools and compatible. | Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) | |||
Multi volume ZipFile (span) are not supported. | ||||
Encryption compatible with pkzip 2.04g only supported | ||||
Old compressions used by old PKZip 1.x are not supported | ||||
For uncompress .zip file, look at unzip.h | For more info read MiniZip_info.txt | |||
I WAIT FEEDBACK at mail info@winimage.com | ------------------------------------------------------------------ | |||
Visit also http://www.winimage.com/zLibDll/unzip.html for evolution | --------- | |||
Condition of use and distribution are the same than zlib : | Condition of use and distribution are the same than zlib : | |||
This software is provided 'as-is', without any express or implied | This software is provided 'as-is', without any express or implied | |||
warranty. In no event will the authors be held liable for any damages | warranty. In no event will the authors be held liable for any damages | |||
arising from the use of this software. | arising from the use of this software. | |||
Permission is granted to anyone to use this software for any purpose, | Permission is granted to anyone to use this software for any purpose, | |||
including commercial applications, and to alter it and redistribute it | including commercial applications, and to alter it and redistribute it | |||
freely, subject to the following restrictions: | freely, subject to the following restrictions: | |||
1. The origin of this software must not be misrepresented; you must not | 1. The origin of this software must not be misrepresented; you must not | |||
claim that you wrote the original software. If you use this software | claim that you wrote the original software. If you use this software | |||
in a product, an acknowledgment in the product documentation would be | in a product, an acknowledgment in the product documentation would be | |||
appreciated but is not required. | appreciated but is not required. | |||
2. Altered source versions must be plainly marked as such, and must not b e | 2. Altered source versions must be plainly marked as such, and must not b e | |||
misrepresented as being the original software. | misrepresented as being the original software. | |||
3. This notice may not be removed or altered from any source distribution . | 3. This notice may not be removed or altered from any source distribution . | |||
Modified by Sergey A. Tachenov to integrate with Qt. | ------------------------------------------------------------------- -------- | |||
*/ | Changes | |||
See header of zip.h | ||||
/* for more info about .ZIP format, see | ||||
http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip | ||||
http://www.info-zip.org/pub/infozip/doc/ | ||||
PkWare has also a specification at : | ||||
ftp://ftp.pkware.com/probdesc.zip | ||||
*/ | */ | |||
#ifndef _zip_H | #ifndef _zip12_H | |||
#define _zip_H | #define _zip12_H | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
//#define HAVE_BZIP2 | ||||
#ifndef _ZLIB_H | #ifndef _ZLIB_H | |||
#include "zlib.h" | #include "zlib.h" | |||
#endif | #endif | |||
#ifndef _ZLIBIOAPI_H | #ifndef _ZLIBIOAPI_H | |||
#include "ioapi.h" | #include "ioapi.h" | |||
#endif | #endif | |||
#ifdef HAVE_BZIP2 | ||||
#include "bzlib.h" | ||||
#endif | ||||
#define Z_BZIP2ED 12 | ||||
#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) | #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) | |||
/* like the STRICT of WIN32, we define a pointer that cannot be converted | /* like the STRICT of WIN32, we define a pointer that cannot be converted | |||
from (void*) without cast */ | from (void*) without cast */ | |||
typedef struct TagzipFile__ { int unused; } zipFile__; | typedef struct TagzipFile__ { int unused; } zipFile__; | |||
typedef zipFile__ *zipFile; | typedef zipFile__ *zipFile; | |||
#else | #else | |||
typedef voidp zipFile; | typedef voidp zipFile; | |||
#endif | #endif | |||
#define ZIP_OK (0) | #define ZIP_OK (0) | |||
skipping to change at line 116 | skipping to change at line 118 | |||
uLong external_fa; /* external file attributes 4 bytes */ | uLong external_fa; /* external file attributes 4 bytes */ | |||
} zip_fileinfo; | } zip_fileinfo; | |||
typedef const char* zipcharpc; | typedef const char* zipcharpc; | |||
#define APPEND_STATUS_CREATE (0) | #define APPEND_STATUS_CREATE (0) | |||
#define APPEND_STATUS_CREATEAFTER (1) | #define APPEND_STATUS_CREATEAFTER (1) | |||
#define APPEND_STATUS_ADDINZIP (2) | #define APPEND_STATUS_ADDINZIP (2) | |||
extern zipFile ZEXPORT zipOpen OF((voidpf file, int append)); | extern zipFile ZEXPORT zipOpen OF((voidpf file, int append)); | |||
extern zipFile ZEXPORT zipOpen64 OF((voidpf file, int append)); | ||||
/* | /* | |||
Create a zipfile. | Create a zipfile. | |||
file is whatever the IO API accepts. For Qt IO API it's a pointer to | the file argument depends on the API used, for QuaZIP it's a QIODevice | |||
QIODevice. For fopen() IO API it's a file name (const char*). | pointer. | |||
if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip | if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip | |||
will be created at the end of the file. | will be created at the end of the file. | |||
(useful if the file contain a self extractor code) | (useful if the file contain a self extractor code) | |||
if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will | if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will | |||
add files in existing zip (be sure you don't add file that doesn't e xist) | add files in existing zip (be sure you don't add file that doesn't e xist) | |||
If the zipfile cannot be opened, the return value is NULL. | If the zipfile cannot be opened, the return value is NULL. | |||
Else, the return value is a zipFile Handle, usable with other function | Else, the return value is a zipFile Handle, usable with other function | |||
of this zip package. | of this zip package. | |||
*/ | */ | |||
/* Note : there is no delete function into a zipfile. | /* Note : there is no delete function into a zipfile. | |||
If you want delete file into a zipfile, you must open a zipfile, and cre ate another | If you want delete file into a zipfile, you must open a zipfile, and cre ate another | |||
Of couse, you can use RAW reading and writing to copy the file you did n ot want delte | Of couse, you can use RAW reading and writing to copy the file you did n ot want delte | |||
*/ | */ | |||
extern zipFile ZEXPORT zipOpen2 OF((voidpf file, | extern zipFile ZEXPORT zipOpen2 OF((voidpf file, | |||
int append, | int append, | |||
zipcharpc* globalcomment, | zipcharpc* globalcomment, | |||
zlib_filefunc_def* pzlib_filefunc_def)); | zlib_filefunc_def* pzlib_filefunc_def)); | |||
extern zipFile ZEXPORT zipOpen2_64 OF((voidpf file, | ||||
int append, | ||||
zipcharpc* globalcomment, | ||||
zlib_filefunc64_def* pzlib_filefunc_def) | ||||
); | ||||
extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, | extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, | |||
const char* filename, | const char* filename, | |||
const zip_fileinfo* zipfi, | const zip_fileinfo* zipfi, | |||
const void* extrafield_local, | const void* extrafield_local, | |||
uInt size_extrafield_local, | uInt size_extrafield_local, | |||
const void* extrafield_global, | const void* extrafield_global, | |||
uInt size_extrafield_global, | uInt size_extrafield_global, | |||
const char* comment, | const char* comment, | |||
int method, | int method, | |||
int level)); | int level)); | |||
extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, | ||||
const char* filename, | ||||
const zip_fileinfo* zipfi, | ||||
const void* extrafield_local, | ||||
uInt size_extrafield_local, | ||||
const void* extrafield_global, | ||||
uInt size_extrafield_global, | ||||
const char* comment, | ||||
int method, | ||||
int level, | ||||
int zip64)); | ||||
/* | /* | |||
Open a file in the ZIP for writing. | Open a file in the ZIP for writing. | |||
filename : the filename in zip (if NULL, '-' without quote will be used | filename : the filename in zip (if NULL, '-' without quote will be used | |||
*zipfi contain supplemental information | *zipfi contain supplemental information | |||
if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local | if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local | |||
contains the extrafield data the the local header | contains the extrafield data the the local header | |||
if extrafield_global!=NULL and size_extrafield_global>0, extrafield_globa l | if extrafield_global!=NULL and size_extrafield_global>0, extrafield_globa l | |||
contains the extrafield data the the local header | contains the extrafield data the the local header | |||
if comment != NULL, comment contain the comment string | if comment != NULL, comment contain the comment string | |||
method contain the compression method (0 for store, Z_DEFLATED for deflat e) | method contain the compression method (0 for store, Z_DEFLATED for deflat e) | |||
level contain the level of compression (can be Z_DEFAULT_COMPRESSION) | level contain the level of compression (can be Z_DEFAULT_COMPRESSION) | |||
zip64 is set to 1 if a zip64 extended information block should be added t | ||||
o the local file header. | ||||
this MUST be '1' if the uncompressed size is >= 0xfffff | ||||
fff. | ||||
*/ | */ | |||
extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, | extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, | |||
const char* filename, | const char* filename, | |||
const zip_fileinfo* zipfi, | const zip_fileinfo* zipfi, | |||
const void* extrafield_local, | const void* extrafield_local, | |||
uInt size_extrafield_local, | uInt size_extrafield_local, | |||
const void* extrafield_global, | const void* extrafield_global, | |||
uInt size_extrafield_global, | uInt size_extrafield_global, | |||
const char* comment, | const char* comment, | |||
int method, | int method, | |||
int level, | int level, | |||
int raw)); | int raw)); | |||
extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, | ||||
const char* filename, | ||||
const zip_fileinfo* zipfi, | ||||
const void* extrafield_local, | ||||
uInt size_extrafield_local, | ||||
const void* extrafield_global, | ||||
uInt size_extrafield_global, | ||||
const char* comment, | ||||
int method, | ||||
int level, | ||||
int raw, | ||||
int zip64)); | ||||
/* | /* | |||
Same than zipOpenNewFileInZip, except if raw=1, we write raw file | Same than zipOpenNewFileInZip, except if raw=1, we write raw file | |||
*/ | */ | |||
extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, | extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, | |||
const char* filename, | const char* filename, | |||
const zip_fileinfo* zipfi, | const zip_fileinfo* zipfi, | |||
const void* extrafield_local, | const void* extrafield_local, | |||
uInt size_extrafield_local, | uInt size_extrafield_local, | |||
const void* extrafield_global, | const void* extrafield_global, | |||
uInt size_extrafield_global, | uInt size_extrafield_global, | |||
const char* comment, | const char* comment, | |||
int method, | int method, | |||
int level, | int level, | |||
int raw, | int raw, | |||
int windowBits, | int windowBits, | |||
int memLevel, | int memLevel, | |||
int strategy, | int strategy, | |||
const char* password, | const char* password, | |||
uLong crcForCtypting)); | uLong crcForCrypting)); | |||
extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, | ||||
const char* filename, | ||||
const zip_fileinfo* zipfi, | ||||
const void* extrafield_local, | ||||
uInt size_extrafield_local, | ||||
const void* extrafield_global, | ||||
uInt size_extrafield_global, | ||||
const char* comment, | ||||
int method, | ||||
int level, | ||||
int raw, | ||||
int windowBits, | ||||
int memLevel, | ||||
int strategy, | ||||
const char* password, | ||||
uLong crcForCrypting, | ||||
int zip64 | ||||
)); | ||||
/* | /* | |||
Same than zipOpenNewFileInZip2, except | Same than zipOpenNewFileInZip2, except | |||
windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 | windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 | |||
password : crypting password (NULL for no crypting) | password : crypting password (NULL for no crypting) | |||
crcForCtypting : crc of file to compress (needed for crypting) | crcForCrypting : crc of file to compress (needed for crypting) | |||
*/ | ||||
extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, | ||||
const char* filename, | ||||
const zip_fileinfo* zipfi, | ||||
const void* extrafield_local, | ||||
uInt size_extrafield_local, | ||||
const void* extrafield_global, | ||||
uInt size_extrafield_global, | ||||
const char* comment, | ||||
int method, | ||||
int level, | ||||
int raw, | ||||
int windowBits, | ||||
int memLevel, | ||||
int strategy, | ||||
const char* password, | ||||
uLong crcForCrypting, | ||||
uLong versionMadeBy, | ||||
uLong flagBase | ||||
)); | ||||
extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, | ||||
const char* filename, | ||||
const zip_fileinfo* zipfi, | ||||
const void* extrafield_local, | ||||
uInt size_extrafield_local, | ||||
const void* extrafield_global, | ||||
uInt size_extrafield_global, | ||||
const char* comment, | ||||
int method, | ||||
int level, | ||||
int raw, | ||||
int windowBits, | ||||
int memLevel, | ||||
int strategy, | ||||
const char* password, | ||||
uLong crcForCrypting, | ||||
uLong versionMadeBy, | ||||
uLong flagBase, | ||||
int zip64 | ||||
)); | ||||
/* | ||||
Same than zipOpenNewFileInZip4, except | ||||
versionMadeBy : value for Version made by field | ||||
flag : value for flag field (compression level info will be added) | ||||
*/ | */ | |||
extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, | extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, | |||
const void* buf, | const void* buf, | |||
unsigned len)); | unsigned len)); | |||
/* | /* | |||
Write data in the zipfile | Write data in the zipfile | |||
*/ | */ | |||
extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); | extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); | |||
/* | /* | |||
Close the current file in the zipfile | Close the current file in the zipfile | |||
*/ | */ | |||
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, | extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, | |||
uLong uncompressed_size, | uLong uncompressed_size, | |||
uLong crc32)); | uLong crc32)); | |||
extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, | ||||
ZPOS64_T uncompressed_size, | ||||
uLong crc32)); | ||||
/* | /* | |||
Close the current file in the zipfile, for fiel opened with | Close the current file in the zipfile, for file opened with | |||
parameter raw=1 in zipOpenNewFileInZip2 | parameter raw=1 in zipOpenNewFileInZip2 | |||
uncompressed_size and crc32 are value for the uncompressed size | uncompressed_size and crc32 are value for the uncompressed size | |||
*/ | */ | |||
extern int ZEXPORT zipClose OF((zipFile file, | extern int ZEXPORT zipClose OF((zipFile file, | |||
const char* global_comment)); | const char* global_comment)); | |||
/* | /* | |||
Close the zipfile | Close the zipfile | |||
*/ | */ | |||
extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, s | ||||
hort sHeader)); | ||||
/* | ||||
zipRemoveExtraInfoBlock - Added by Mathias Svensson | ||||
Remove extra information block from a extra information data for the loca | ||||
l file header or central directory header | ||||
It is needed to remove ZIP64 extra information blocks when before data is | ||||
written if using RAW mode. | ||||
0x0001 is the signature header for the ZIP64 extra information blocks | ||||
usage. | ||||
Remove ZIP64 Extra information from a central direc | ||||
tor extra field data | ||||
zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraF | ||||
ieldDataLen, 0x0001); | ||||
Remove ZIP64 Extra information from a Local File He | ||||
ader extra field data | ||||
zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderEx | ||||
traFieldDataLen, 0x0001); | ||||
*/ | ||||
/* | /* | |||
Added by Sergey A. Tachenov to tweak zipping behaviour. | Added by Sergey A. Tachenov to tweak zipping behaviour. | |||
*/ | */ | |||
extern int ZEXPORT zipSetFlags(zipFile file, unsigned flags); | extern int ZEXPORT zipSetFlags(zipFile file, unsigned flags); | |||
extern int ZEXPORT zipClearFlags(zipFile file, unsigned flags); | extern int ZEXPORT zipClearFlags(zipFile file, unsigned flags); | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
#endif /* _zip_H */ | #endif /* _zip64_H */ | |||
End of changes. 24 change blocks. | ||||
26 lines changed or deleted | 162 lines changed or added | |||