Update quazip to the latest version

This commit is contained in:
Tasos Sahanidis
2019-09-04 04:05:21 +03:00
parent e7815b952c
commit 00c44947a8
21 changed files with 300 additions and 270 deletions
-1
View File
@@ -59,7 +59,6 @@ target_sources(
quazipfileinfo.cpp
quazipnewinfo.cpp
JlCompress.h
crypt.h
ioapi.h
quaadler32.h
quachecksum32.h
+20 -9
View File
@@ -92,7 +92,7 @@ bool JlCompress::compressSubDir(QuaZip* zip, QString dir, QString origDir, bool
if (dir != origDir) {
QuaZipFile dirZipFile(zip);
if (!dirZipFile.open(QIODevice::WriteOnly,
QuaZipNewInfo(origDirectory.relativeFilePath(dir) + "/", dir), 0, 0, 0)) {
QuaZipNewInfo(origDirectory.relativeFilePath(dir) + QLatin1String("/"), dir), 0, 0, 0)) {
return false;
}
dirZipFile.close();
@@ -103,7 +103,12 @@ bool JlCompress::compressSubDir(QuaZip* zip, QString dir, QString origDir, bool
if (recursive) {
// Per ogni sotto cartella
QFileInfoList files = directory.entryInfoList(QDir::AllDirs|QDir::NoDotAndDotDot|filters);
Q_FOREACH (QFileInfo file, files) {
for (int index = 0; index < files.size(); ++index ) {
const QFileInfo & file( files.at( index ) );
#if QT_VERSION < QT_VERSION_CHECK(4, 7, 4)
if (!file.isDir())
continue;
#endif
// Comprimo la sotto cartella
if(!compressSubDir(zip,file.absoluteFilePath(),origDir,recursive,filters)) return false;
}
@@ -111,7 +116,8 @@ bool JlCompress::compressSubDir(QuaZip* zip, QString dir, QString origDir, bool
// Per ogni file nella cartella
QFileInfoList files = directory.entryInfoList(QDir::Files|filters);
Q_FOREACH (QFileInfo file, files) {
for (int index = 0; index < files.size(); ++index ) {
const QFileInfo & file( files.at( index ) );
// Se non e un file o e il file compresso che sto creando
if(!file.isFile()||file.absoluteFilePath()==zip->getZipName()) continue;
@@ -142,7 +148,7 @@ bool JlCompress::extractFile(QuaZip* zip, QString fileName, QString fileDest) {
// Controllo esistenza cartella file risultato
QDir curDir;
if (fileDest.endsWith('/')) {
if (fileDest.endsWith(QLatin1String("/"))) {
if (!curDir.mkpath(fileDest)) {
return false;
}
@@ -157,7 +163,7 @@ bool JlCompress::extractFile(QuaZip* zip, QString fileName, QString fileDest) {
return false;
QFile::Permissions srcPerm = info.getPermissions();
if (fileDest.endsWith('/') && QFileInfo(fileDest).isDir()) {
if (fileDest.endsWith(QLatin1String("/")) && QFileInfo(fileDest).isDir()) {
if (srcPerm != 0) {
QFile(fileDest).setPermissions(srcPerm);
}
@@ -236,7 +242,8 @@ bool JlCompress::compressFiles(QString fileCompressed, QStringList files) {
// Comprimo i file
QFileInfo info;
Q_FOREACH (QString file, files) {
for (int index = 0; index < files.size(); ++index ) {
const QString & file( files.at( index ) );
info.setFile(file);
if (!info.exists() || !compressFile(&zip,file,info.fileName())) {
QFile::remove(fileCompressed);
@@ -357,8 +364,9 @@ QStringList JlCompress::extractDir(QuaZip &zip, const QString &dir)
if(!zip.open(QuaZip::mdUnzip)) {
return QStringList();
}
QDir directory(dir);
QString cleanDir = QDir::cleanPath(dir);
QDir directory(cleanDir);
QString absCleanDir = directory.absolutePath();
QStringList extracted;
if (!zip.goToFirstFile()) {
return QStringList();
@@ -366,7 +374,10 @@ QStringList JlCompress::extractDir(QuaZip &zip, const QString &dir)
do {
QString name = zip.getCurrentFileName();
QString absFilePath = directory.absoluteFilePath(name);
if (!extractFile(&zip, "", absFilePath)) {
QString absCleanPath = QDir::cleanPath(absFilePath);
if (!absCleanPath.startsWith(absCleanDir + QLatin1String("/")))
continue;
if (!extractFile(&zip, QLatin1String(""), absFilePath)) {
removeFile(extracted);
return QStringList();
}
-135
View File
@@ -1,135 +0,0 @@
/* crypt.h -- base code for crypt/uncrypt ZIPfile
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
This code is a modified version of crypting code in Infozip distribution
The encryption/decryption parts of this source code (as opposed to the
non-echoing password parts) were originally written in Europe. The
whole source package can be freely distributed, including from the USA.
(Prior to January 2000, re-export from the US was a violation of US law.)
This encryption code is a direct transcription of the algorithm from
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
file (appnote.txt) is distributed with the PKZIP program (even in the
version without encryption capabilities).
If you don't need crypting in your application, just define symbols
NOCRYPT and NOUNCRYPT.
This code support the "Traditional PKWARE Encryption".
The new AES encryption added on Zip format by Winzip (see the page
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
Encryption is not supported.
*/
#include "quazip_global.h"
#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
static int decrypt_byte(unsigned long* pkeys, const z_crc_t FAR * pcrc_32_tab UNUSED)
{
//(void) pcrc_32_tab; /* avoid "unused parameter" warning */
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
}
/***********************************************************************
* Update the encryption keys with the next byte of plain text
*/
static int update_keys(unsigned long* pkeys,const z_crc_t FAR * pcrc_32_tab,int c)
{
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
{
register int keyshift = (int)((*(pkeys+1)) >> 24);
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
}
return c;
}
/***********************************************************************
* Initialize the encryption keys and the random header according to
* the given password.
*/
static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t FAR * pcrc_32_tab)
{
*(pkeys+0) = 305419896L;
*(pkeys+1) = 591751049L;
*(pkeys+2) = 878082192L;
while (*passwd != '\0') {
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
passwd++;
}
}
#define zdecode(pkeys,pcrc_32_tab,c) \
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))
#define zencode(pkeys,pcrc_32_tab,c,t) \
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
#define RAND_HEAD_LEN 12
/* "last resort" source for second part of crypt seed pattern */
# ifndef ZCR_SEED2
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
# endif
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
const char *passwd; /* password string */
unsigned char *buf; /* where to write header */
int bufSize;
unsigned long* pkeys;
const z_crc_t FAR * pcrc_32_tab;
unsigned long crcForCrypting;
{
int n; /* index in random header */
int t; /* temporary */
int c; /* random byte */
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
static unsigned calls = 0; /* ensure different random header each time */
if (bufSize<RAND_HEAD_LEN)
return 0;
/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
* output of rand() to get less predictability, since rand() is
* often poorly implemented.
*/
if (++calls == 1)
{
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
}
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
c = (rand() >> 7) & 0xff;
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
}
/* Encrypt random header (last two bytes is high word of crc) */
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
}
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
return n;
}
#endif
+1 -1
View File
@@ -44,7 +44,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "zlib.h"
#include <zlib.h>
#if defined(USE_FILE32API)
#define fopen64 fopen
+1 -1
View File
@@ -11,8 +11,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
#include "zlib.h"
#include "ioapi.h"
#include "quazip_global.h"
#include <QIODevice>
+1 -1
View File
@@ -25,7 +25,7 @@ see quazip/(un)zip.h files for details. Basically it's the zlib license.
#include "quaadler32.h"
#include "zlib.h"
#include <zlib.h>
QuaAdler32::QuaAdler32()
{
+1 -1
View File
@@ -24,7 +24,7 @@ see quazip/(un)zip.h files for details. Basically it's the zlib license.
#include "quacrc32.h"
#include "zlib.h"
#include <zlib.h>
QuaCrc32::QuaCrc32()
{
+4 -4
View File
@@ -57,13 +57,13 @@ bool QuaGzipFilePrivate::open(FileId id, QIODevice::OpenMode mode,
char modeString[2];
modeString[0] = modeString[1] = '\0';
if ((mode & QIODevice::Append) != 0) {
error = QuaGzipFile::trUtf8("QIODevice::Append is not "
error = QuaGzipFile::tr("QIODevice::Append is not "
"supported for GZIP");
return false;
}
if ((mode & QIODevice::ReadOnly) != 0
&& (mode & QIODevice::WriteOnly) != 0) {
error = QuaGzipFile::trUtf8("Opening gzip for both reading"
error = QuaGzipFile::tr("Opening gzip for both reading"
" and writing is not supported");
return false;
} else if ((mode & QIODevice::ReadOnly) != 0) {
@@ -71,13 +71,13 @@ bool QuaGzipFilePrivate::open(FileId id, QIODevice::OpenMode mode,
} else if ((mode & QIODevice::WriteOnly) != 0) {
modeString[0] = 'w';
} else {
error = QuaGzipFile::trUtf8("You can open a gzip either for reading"
error = QuaGzipFile::tr("You can open a gzip either for reading"
" or for writing. Which is it?");
return false;
}
gzd = open(id, modeString);
if (gzd == NULL) {
error = QuaGzipFile::trUtf8("Could not gzopen() file");
error = QuaGzipFile::tr("Could not gzopen() file");
return false;
}
return true;
+53 -43
View File
@@ -30,9 +30,10 @@ see quazip/(un)zip.h files for details. Basically it's the zlib license.
/// \cond internal
class QuaZIODevicePrivate {
friend class QuaZIODevice;
QuaZIODevicePrivate(QIODevice *io);
QuaZIODevicePrivate(QIODevice *io, QuaZIODevice *q);
~QuaZIODevicePrivate();
QIODevice *io;
QuaZIODevice *q;
z_stream zins;
z_stream zouts;
char *inBuf;
@@ -43,11 +44,13 @@ class QuaZIODevicePrivate {
int outBufSize;
bool zBufError;
bool atEnd;
bool flush(int sync);
int doFlush(QString &error);
};
QuaZIODevicePrivate::QuaZIODevicePrivate(QIODevice *io):
QuaZIODevicePrivate::QuaZIODevicePrivate(QIODevice *io, QuaZIODevice *q):
io(io),
q(q),
inBuf(NULL),
inBufPos(0),
inBufSize(0),
@@ -86,7 +89,45 @@ QuaZIODevicePrivate::~QuaZIODevicePrivate()
if (inBuf != NULL)
delete[] inBuf;
if (outBuf != NULL)
delete[] outBuf;
delete[] outBuf;
}
bool QuaZIODevicePrivate::flush(int sync)
{
QString error;
if (doFlush(error) < 0) {
q->setErrorString(error);
return false;
}
// can't flush buffer, some data is still waiting
if (outBufPos < outBufSize)
return true;
Bytef c = 0;
zouts.next_in = &c; // fake input buffer
zouts.avail_in = 0; // of zero size
do {
zouts.next_out = (Bytef *) outBuf;
zouts.avail_out = QUAZIO_OUTBUFSIZE;
int result = deflate(&zouts, sync);
switch (result) {
case Z_OK:
case Z_STREAM_END:
outBufSize = (char *) zouts.next_out - outBuf;
if (doFlush(error) < 0) {
q->setErrorString(error);
return false;
}
if (outBufPos < outBufSize)
return true;
break;
case Z_BUF_ERROR: // nothing to write?
return true;
default:
q->setErrorString(QString::fromLocal8Bit(zouts.msg));
return false;
}
} while (zouts.avail_out == 0);
return true;
}
int QuaZIODevicePrivate::doFlush(QString &error)
@@ -124,7 +165,7 @@ static QFile indebug;
QuaZIODevice::QuaZIODevice(QIODevice *io, QObject *parent):
QIODevice(parent),
d(new QuaZIODevicePrivate(io))
d(new QuaZIODevicePrivate(io, this))
{
connect(io, SIGNAL(readyRead()), SIGNAL(readyRead()));
}
@@ -144,24 +185,24 @@ QIODevice *QuaZIODevice::getIoDevice() const
bool QuaZIODevice::open(QIODevice::OpenMode mode)
{
if ((mode & QIODevice::Append) != 0) {
setErrorString(trUtf8("QIODevice::Append is not supported for"
setErrorString(tr("QIODevice::Append is not supported for"
" QuaZIODevice"));
return false;
}
if ((mode & QIODevice::ReadWrite) == QIODevice::ReadWrite) {
setErrorString(trUtf8("QIODevice::ReadWrite is not supported for"
setErrorString(tr("QIODevice::ReadWrite is not supported for"
" QuaZIODevice"));
return false;
}
if ((mode & QIODevice::ReadOnly) != 0) {
if (inflateInit(&d->zins) != Z_OK) {
setErrorString(d->zins.msg);
setErrorString(QString::fromLocal8Bit(d->zins.msg));
return false;
}
}
if ((mode & QIODevice::WriteOnly) != 0) {
if (deflateInit(&d->zouts, Z_DEFAULT_COMPRESSION) != Z_OK) {
setErrorString(d->zouts.msg);
setErrorString(QString::fromLocal8Bit(d->zouts.msg));
return false;
}
}
@@ -172,13 +213,13 @@ void QuaZIODevice::close()
{
if ((openMode() & QIODevice::ReadOnly) != 0) {
if (inflateEnd(&d->zins) != Z_OK) {
setErrorString(d->zins.msg);
setErrorString(QString::fromLocal8Bit(d->zins.msg));
}
}
if ((openMode() & QIODevice::WriteOnly) != 0) {
flush();
d->flush(Z_FINISH);
if (deflateEnd(&d->zouts) != Z_OK) {
setErrorString(d->zouts.msg);
setErrorString(QString::fromLocal8Bit(d->zouts.msg));
}
}
QIODevice::close();
@@ -283,38 +324,7 @@ qint64 QuaZIODevice::writeData(const char *data, qint64 maxSize)
bool QuaZIODevice::flush()
{
QString error;
if (d->doFlush(error) < 0) {
setErrorString(error);
return false;
}
// can't flush buffer, some data is still waiting
if (d->outBufPos < d->outBufSize)
return true;
Bytef c = 0;
d->zouts.next_in = &c; // fake input buffer
d->zouts.avail_in = 0; // of zero size
do {
d->zouts.next_out = (Bytef *) d->outBuf;
d->zouts.avail_out = QUAZIO_OUTBUFSIZE;
switch (deflate(&d->zouts, Z_SYNC_FLUSH)) {
case Z_OK:
d->outBufSize = (char *) d->zouts.next_out - d->outBuf;
if (d->doFlush(error) < 0) {
setErrorString(error);
return false;
}
if (d->outBufPos < d->outBufSize)
return true;
break;
case Z_BUF_ERROR: // nothing to write?
return true;
default:
setErrorString(QString::fromLocal8Bit(d->zouts.msg));
return false;
}
} while (d->zouts.avail_out == 0);
return true;
return d->flush(Z_SYNC_FLUSH);
}
bool QuaZIODevice::isSequential() const
+1
View File
@@ -39,6 +39,7 @@ class QuaZIODevicePrivate;
example.
*/
class QUAZIP_EXPORT QuaZIODevice: public QIODevice {
friend class QuaZIODevicePrivate;
Q_OBJECT
public:
/// Constructor.
+66 -15
View File
@@ -28,6 +28,8 @@ quazip/(un)zip.h files for details, basically it's zlib license.
#include "quazip.h"
#define QUAZIP_OS_UNIX 3u
/// All the internal stuff for the QuaZip class.
/**
\internal
@@ -42,9 +44,9 @@ class QuaZipPrivate {
Q_DISABLE_COPY(QuaZipPrivate)
/// The pointer to the corresponding QuaZip instance.
QuaZip *q;
/// The codec for file names.
/// The codec for file names (used when UTF-8 is not enabled).
QTextCodec *fileNameCodec;
/// The codec for comments.
/// The codec for comments (used when UTF-8 is not enabled).
QTextCodec *commentCodec;
/// The archive file name.
QString zipName;
@@ -70,6 +72,10 @@ class QuaZipPrivate {
bool zip64;
/// The auto-close flag.
bool autoClose;
/// The UTF-8 flag.
bool utf8;
/// The OS code.
uint osCode;
inline QTextCodec *getDefaultFileNameCodec()
{
if (defaultFileNameCodec == NULL) {
@@ -89,7 +95,9 @@ class QuaZipPrivate {
zipError(UNZ_OK),
dataDescriptorWritingEnabled(true),
zip64(false),
autoClose(true)
autoClose(true),
utf8(false),
osCode(defaultOsCode)
{
unzFile_f = NULL;
zipFile_f = NULL;
@@ -108,7 +116,9 @@ class QuaZipPrivate {
zipError(UNZ_OK),
dataDescriptorWritingEnabled(true),
zip64(false),
autoClose(true)
autoClose(true),
utf8(false),
osCode(defaultOsCode)
{
unzFile_f = NULL;
zipFile_f = NULL;
@@ -117,7 +127,7 @@ class QuaZipPrivate {
}
/// The constructor for the corresponding QuaZip constructor.
inline QuaZipPrivate(QuaZip *q, QIODevice *ioDevice):
q(q),
q(q),
fileNameCodec(getDefaultFileNameCodec()),
commentCodec(QTextCodec::codecForLocale()),
ioDevice(ioDevice),
@@ -126,7 +136,9 @@ class QuaZipPrivate {
zipError(UNZ_OK),
dataDescriptorWritingEnabled(true),
zip64(false),
autoClose(true)
autoClose(true),
utf8(false),
osCode(defaultOsCode)
{
unzFile_f = NULL;
zipFile_f = NULL;
@@ -145,9 +157,11 @@ class QuaZipPrivate {
QHash<QString, unz64_file_pos> directoryCaseInsensitive;
unz64_file_pos lastMappedDirectoryEntry;
static QTextCodec *defaultFileNameCodec;
static uint defaultOsCode;
};
QTextCodec *QuaZipPrivate::defaultFileNameCodec = NULL;
uint QuaZipPrivate::defaultOsCode = QUAZIP_OS_UNIX;
void QuaZipPrivate::clearDirectoryMap()
{
@@ -280,6 +294,8 @@ bool QuaZip::open(Mode mode, zlib_filefunc_def* ioApi)
flags |= ZIP_AUTO_CLOSE;
if (p->dataDescriptorWritingEnabled)
flags |= ZIP_WRITE_DATA_DESCRIPTOR;
if (p->utf8)
flags |= ZIP_ENCODING_UTF8;
p->zipFile_f=zipOpen3(ioDevice,
mode==mdCreate?APPEND_STATUS_CREATE:
mode==mdAppend?APPEND_STATUS_CREATEAFTER:
@@ -341,9 +357,9 @@ void QuaZip::close()
case mdCreate:
case mdAppend:
case mdAdd:
p->zipError=zipClose(p->zipFile_f,
p->comment.isNull() ? NULL
: p->commentCodec->fromUnicode(p->comment).constData());
p->zipError=zipClose(p->zipFile_f, p->comment.isNull() ? NULL : isUtf8Enabled()
? p->comment.toUtf8().constData()
: p->commentCodec->fromUnicode(p->comment).constData());
break;
default:
qWarning("QuaZip::close(): unknown mode: %d", (int)p->mode);
@@ -409,7 +425,9 @@ QString QuaZip::getComment()const
if((fakeThis->p->zipError=unzGetGlobalComment(p->unzFile_f, comment.data(), comment.size())) < 0)
return QString();
fakeThis->p->zipError = UNZ_OK;
return p->commentCodec->toUnicode(comment);
unsigned flags = 0;
return (unzGetFileFlags(p->unzFile_f, &flags) == UNZ_OK) && (flags & UNZ_ENCODING_UTF8)
? QString::fromUtf8(comment) : p->commentCodec->toUnicode(comment);
}
bool QuaZip::setCurrentFile(const QString& fileName, CaseSensitivity cs)
@@ -544,8 +562,8 @@ bool QuaZip::getCurrentFileInfo(QuaZipFileInfo64 *info)const
info->diskNumberStart=info_z.disk_num_start;
info->internalAttr=info_z.internal_fa;
info->externalAttr=info_z.external_fa;
info->name=p->fileNameCodec->toUnicode(fileName);
info->comment=p->commentCodec->toUnicode(comment);
info->name=(info->flags & UNZ_ENCODING_UTF8) ? QString::fromUtf8(fileName) : p->fileNameCodec->toUnicode(fileName);
info->comment=(info->flags & UNZ_ENCODING_UTF8) ? QString::fromUtf8(comment) : p->commentCodec->toUnicode(comment);
info->extra=extra;
info->dateTime=QDateTime(
QDate(info_z.tmu_date.tm_year, info_z.tmu_date.tm_mon+1, info_z.tmu_date.tm_mday),
@@ -565,10 +583,13 @@ QString QuaZip::getCurrentFileName()const
}
if(!isOpen()||!hasCurrentFile()) return QString();
QByteArray fileName(MAX_FILE_NAME_LENGTH, 0);
if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, NULL, fileName.data(), fileName.size(),
unz_file_info64 file_info;
if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, &file_info, fileName.data(), fileName.size(),
NULL, 0, NULL, 0))!=UNZ_OK)
return QString();
QString result = p->fileNameCodec->toUnicode(fileName.constData());
fileName.resize(file_info.size_filename);
QString result = (file_info.flag & UNZ_ENCODING_UTF8)
? QString::fromUtf8(fileName) : p->fileNameCodec->toUnicode(fileName);
if (result.isEmpty())
return result;
// Add to directory map
@@ -583,7 +604,17 @@ void QuaZip::setFileNameCodec(QTextCodec *fileNameCodec)
void QuaZip::setFileNameCodec(const char *fileNameCodecName)
{
p->fileNameCodec=QTextCodec::codecForName(fileNameCodecName);
p->fileNameCodec=QTextCodec::codecForName(fileNameCodecName);
}
void QuaZip::setOsCode(uint osCode)
{
p->osCode = osCode;
}
uint QuaZip::getOsCode() const
{
return p->osCode;
}
QTextCodec *QuaZip::getFileNameCodec()const
@@ -774,6 +805,16 @@ void QuaZip::setDefaultFileNameCodec(const char *codecName)
setDefaultFileNameCodec(QTextCodec::codecForName(codecName));
}
void QuaZip::setDefaultOsCode(uint osCode)
{
QuaZipPrivate::defaultOsCode = osCode;
}
uint QuaZip::getDefaultOsCode()
{
return QuaZipPrivate::defaultOsCode;
}
void QuaZip::setZip64Enabled(bool zip64)
{
p->zip64 = zip64;
@@ -784,6 +825,16 @@ bool QuaZip::isZip64Enabled() const
return p->zip64;
}
void QuaZip::setUtf8Enabled(bool utf8)
{
p->utf8 = utf8;
}
bool QuaZip::isUtf8Enabled() const
{
return p->utf8;
}
bool QuaZip::isAutoClose() const
{
return p->autoClose;
+41 -1
View File
@@ -227,6 +227,14 @@ class QUAZIP_EXPORT QuaZip {
* Equivalent to calling setFileNameCodec(QTextCodec::codecForName(codecName));
**/
void setFileNameCodec(const char *fileNameCodecName);
/// Sets the OS code (highest 8 bits of the “version made by” field) for new files.
/** There is currently no way to specify this for each file individually,
except by calling this function before opening each file. If this function is not called,
then the default OS code will be used. The default code is set by calling
setDefaultOsCode(). The default value at the moment of QuaZip creation will be used. */
void setOsCode(uint osCode);
/// Returns the OS code for new files.
uint getOsCode() const;
/// Returns the codec used to encode/decode comments inside archive.
QTextCodec* getFileNameCodec() const;
/// Sets the codec used to encode/decode comments inside archive.
@@ -502,6 +510,28 @@ class QUAZIP_EXPORT QuaZip {
* \sa setZip64Enabled()
*/
bool isZip64Enabled() const;
/// Enables the use of UTF-8 encoding for file names and comments text.
/**
* @param utf8 If \c true, the UTF-8 mode is enabled, disabled otherwise.
*
* Once this is enabled, the names of all new files and comments text (until
* the mode is disabled again) will be encoded in UTF-8 encoding, and the
* version to extract will be set to 6.3 (63) in ZIP header. By default,
* the UTF-8 mode is off due to compatibility reasons.
*
* Note that when extracting ZIP archives, the UTF-8 mode is determined from
* ZIP file header, not from this flag.
*
* \sa isUtf8Enabled()
*/
void setUtf8Enabled(bool utf8);
/// Returns whether the UTF-8 encoding mode is enabled.
/**
* @return \c true if and only if the UTF-8 mode is enabled.
*
* \sa setUtf8Enabled()
*/
bool isUtf8Enabled() const;
/// Returns the auto-close flag.
/**
@sa setAutoClose()
@@ -563,9 +593,19 @@ class QUAZIP_EXPORT QuaZip {
/**
* @overload
* Equivalent to calling
* setDefltFileNameCodec(QTextCodec::codecForName(codecName)).
* setDefaultFileNameCodec(QTextCodec::codecForName(codecName)).
*/
static void setDefaultFileNameCodec(const char *codecName);
/// Sets default OS code.
/**
* @sa setOsCode()
*/
static void setDefaultOsCode(uint osCode);
/// Returns default OS code.
/**
* @sa getOsCode()
*/
static uint getDefaultOsCode();
};
#endif
+2 -2
View File
@@ -48,9 +48,9 @@ see quazip/(un)zip.h files for details. Basically it's the zlib license.
#endif // QUAZIP_STATIC
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#define QUAZIP_UNUSED __attribute__((__unused__))
#else
#define UNUSED
#define QUAZIP_UNUSED
#endif
#define QUAZIP_EXTRA_NTFS_MAGIC 0x000Au
+38 -34
View File
@@ -55,7 +55,7 @@ QuaZipDir::QuaZipDir(const QuaZipDir &that):
QuaZipDir::QuaZipDir(QuaZip *zip, const QString &dir):
d(new QuaZipDirPrivate(zip, dir))
{
if (d->dir.startsWith('/'))
if (d->dir.startsWith(QLatin1String("/")))
d->dir = d->dir.mid(1);
}
@@ -86,24 +86,24 @@ QuaZip::CaseSensitivity QuaZipDir::caseSensitivity() const
bool QuaZipDir::cd(const QString &directoryName)
{
if (directoryName == "/") {
d->dir = "";
if (directoryName == QLatin1String("/")) {
d->dir = QLatin1String("");
return true;
}
QString dirName = directoryName;
if (dirName.endsWith('/'))
if (dirName.endsWith(QLatin1String("/")))
dirName.chop(1);
if (dirName.contains('/')) {
if (dirName.contains(QLatin1String("/"))) {
QuaZipDir dir(*this);
if (dirName.startsWith('/')) {
if (dirName.startsWith(QLatin1String("/"))) {
#ifdef QUAZIP_QUAZIPDIR_DEBUG
qDebug("QuaZipDir::cd(%s): going to /",
dirName.toUtf8().constData());
#endif
if (!dir.cd("/"))
if (!dir.cd(QLatin1String("/")))
return false;
}
QStringList path = dirName.split('/', QString::SkipEmptyParts);
QStringList path = dirName.split(QLatin1String("/"), QString::SkipEmptyParts);
for (QStringList::const_iterator i = path.constBegin();
i != path.end();
++i) {
@@ -119,15 +119,15 @@ bool QuaZipDir::cd(const QString &directoryName)
d->dir = dir.path();
return true;
} else { // no '/'
if (dirName == ".") {
if (dirName == QLatin1String(".")) {
return true;
} else if (dirName == "..") {
} else if (dirName == QLatin1String("..")) {
if (isRoot()) {
return false;
} else {
int slashPos = d->dir.lastIndexOf('/');
int slashPos = d->dir.lastIndexOf(QLatin1String("/"));
if (slashPos == -1) {
d->dir = "";
d->dir = QLatin1String("");
} else {
d->dir = d->dir.left(slashPos);
}
@@ -138,7 +138,7 @@ bool QuaZipDir::cd(const QString &directoryName)
if (isRoot())
d->dir = dirName;
else
d->dir += "/" + dirName;
d->dir += QLatin1String("/") + dirName;
return true;
} else {
return false;
@@ -149,7 +149,7 @@ bool QuaZipDir::cd(const QString &directoryName)
bool QuaZipDir::cdUp()
{
return cd("..");
return cd(QLatin1String(".."));
}
uint QuaZipDir::count() const
@@ -247,10 +247,10 @@ class QuaZipDirComparator
QString QuaZipDirComparator::getExtension(const QString &name)
{
if (name.endsWith('.') || name.indexOf('.', 1) == -1) {
return "";
if (name.endsWith(QLatin1String(".")) || name.indexOf(QLatin1String("."), 1) == -1) {
return QLatin1String("");
} else {
return name.mid(name.lastIndexOf('.') + 1);
return name.mid(name.lastIndexOf(QLatin1String(".")) + 1);
}
}
@@ -277,9 +277,9 @@ bool QuaZipDirComparator::operator()(const QuaZipFileInfo64 &info1,
& (QDir::Name | QDir::Time | QDir::Size | QDir::Type);
if ((sort & QDir::DirsFirst) == QDir::DirsFirst
|| (sort & QDir::DirsLast) == QDir::DirsLast) {
if (info1.name.endsWith('/') && !info2.name.endsWith('/'))
if (info1.name.endsWith(QLatin1String("/")) && !info2.name.endsWith(QLatin1String("/")))
return (sort & QDir::DirsFirst) == QDir::DirsFirst;
else if (!info1.name.endsWith('/') && info2.name.endsWith('/'))
else if (!info1.name.endsWith(QLatin1String("/")) && info2.name.endsWith(QLatin1String("/")))
return (sort & QDir::DirsLast) == QDir::DirsLast;
}
bool result;
@@ -325,7 +325,7 @@ bool QuaZipDirPrivate::entryInfoList(QStringList nameFilters,
{
QString basePath = simplePath();
if (!basePath.isEmpty())
basePath += "/";
basePath += QLatin1String("/");
int baseLength = basePath.length();
result.clear();
QuaZipDirRestoreCurrent saveCurrent(zip);
@@ -351,8 +351,8 @@ bool QuaZipDirPrivate::entryInfoList(QStringList nameFilters,
continue;
bool isDir = false;
bool isReal = true;
if (relativeName.contains('/')) {
int indexOfSlash = relativeName.indexOf('/');
if (relativeName.contains(QLatin1String("/"))) {
int indexOfSlash = relativeName.indexOf(QLatin1String("/"));
// something like "subdir/"
isReal = indexOfSlash == relativeName.length() - 1;
relativeName = relativeName.left(indexOfSlash + 1);
@@ -390,7 +390,11 @@ bool QuaZipDirPrivate::entryInfoList(QStringList nameFilters,
== Qt::CaseInsensitive)
srt |= QDir::IgnoreCase;
QuaZipDirComparator lessThan(srt);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
std::sort(list.begin(), list.end(), lessThan);
#else
qSort(list.begin(), list.end(), lessThan);
#endif
}
QuaZipDir_convertInfoList(list, result);
return true;
@@ -448,12 +452,12 @@ QStringList QuaZipDir::entryList(QDir::Filters filters,
bool QuaZipDir::exists(const QString &filePath) const
{
if (filePath == "/" || filePath.isEmpty())
if (filePath == QLatin1String("/") || filePath.isEmpty())
return true;
QString fileName = filePath;
if (fileName.endsWith('/'))
if (fileName.endsWith(QLatin1String("/")))
fileName.chop(1);
if (fileName.contains('/')) {
if (fileName.contains(QLatin1String("/"))) {
QFileInfo fileInfo(fileName);
#ifdef QUAZIP_QUAZIPDIR_DEBUG
qDebug("QuaZipDir::exists(): fileName=%s, fileInfo.fileName()=%s, "
@@ -464,9 +468,9 @@ bool QuaZipDir::exists(const QString &filePath) const
QuaZipDir dir(*this);
return dir.cd(fileInfo.path()) && dir.exists(fileInfo.fileName());
} else {
if (fileName == "..") {
if (fileName == QLatin1String("..")) {
return !isRoot();
} else if (fileName == ".") {
} else if (fileName == QLatin1String(".")) {
return true;
} else {
QStringList entries = entryList(QDir::AllEntries, QDir::NoSort);
@@ -482,11 +486,11 @@ bool QuaZipDir::exists(const QString &filePath) const
#endif
Qt::CaseSensitivity cs = QuaZip::convertCaseSensitivity(
d->caseSensitivity);
if (filePath.endsWith('/')) {
if (filePath.endsWith(QLatin1String("/"))) {
return entries.contains(filePath, cs);
} else {
return entries.contains(fileName, cs)
|| entries.contains(fileName + "/", cs);
|| entries.contains(fileName + QLatin1String("/"), cs);
}
}
}
@@ -524,7 +528,7 @@ QString QuaZipDir::path() const
QString QuaZipDir::relativeFilePath(const QString &fileName) const
{
return QDir("/" + d->dir).relativeFilePath(fileName);
return QDir(QLatin1String("/") + d->dir).relativeFilePath(fileName);
}
void QuaZipDir::setCaseSensitivity(QuaZip::CaseSensitivity caseSensitivity)
@@ -545,12 +549,12 @@ void QuaZipDir::setNameFilters(const QStringList &nameFilters)
void QuaZipDir::setPath(const QString &path)
{
QString newDir = path;
if (newDir == "/") {
d->dir = "";
if (newDir == QLatin1String("/")) {
d->dir = QLatin1String("");
} else {
if (newDir.endsWith('/'))
if (newDir.endsWith(QLatin1String("/")))
newDir.chop(1);
if (newDir.startsWith('/'))
if (newDir.startsWith(QLatin1String("/")))
newDir = newDir.mid(1);
d->dir = newDir;
}
+16 -6
View File
@@ -26,6 +26,8 @@ quazip/(un)zip.h files for details, basically it's zlib license.
using namespace std;
#define QUAZIP_VERSION_MADE_BY 0x1Eu
/// The implementation class for QuaZip.
/**
\internal
@@ -112,7 +114,7 @@ class QuaZipFilePrivate {
{
zip=new QuaZip(zipName);
this->fileName=fileName;
if (this->fileName.startsWith('/'))
if (this->fileName.startsWith(QLatin1String("/")))
this->fileName = this->fileName.mid(1);
this->caseSensitivity=cs;
}
@@ -232,7 +234,7 @@ void QuaZipFile::setFileName(const QString& fileName, QuaZip::CaseSensitivity cs
return;
}
p->fileName=fileName;
if (p->fileName.startsWith('/'))
if (p->fileName.startsWith(QLatin1String("/")))
p->fileName = p->fileName.mid(1);
p->caseSensitivity=cs;
}
@@ -339,14 +341,22 @@ bool QuaZipFile::open(OpenMode mode, const QuaZipNewInfo& info,
zipSetFlags(p->zip->getZipFile(), ZIP_WRITE_DATA_DESCRIPTOR);
else
zipClearFlags(p->zip->getZipFile(), ZIP_WRITE_DATA_DESCRIPTOR);
p->setZipError(zipOpenNewFileInZip3_64(p->zip->getZipFile(),
p->zip->getFileNameCodec()->fromUnicode(info.name).constData(), &info_z,
p->setZipError(zipOpenNewFileInZip4_64(p->zip->getZipFile(),
p->zip->isUtf8Enabled()
? info.name.toUtf8().constData()
: p->zip->getFileNameCodec()->fromUnicode(info.name).constData(),
&info_z,
info.extraLocal.constData(), info.extraLocal.length(),
info.extraGlobal.constData(), info.extraGlobal.length(),
p->zip->getCommentCodec()->fromUnicode(info.comment).constData(),
p->zip->isUtf8Enabled()
? info.comment.toUtf8().constData()
: p->zip->getCommentCodec()->fromUnicode(info.comment).constData(),
method, level, (int)raw,
windowBits, memLevel, strategy,
password, (uLong)crc, p->zip->isZip64Enabled()));
password, (uLong)crc,
(p->zip->getOsCode() << 8) | QUAZIP_VERSION_MADE_BY,
0,
p->zip->isZip64Enabled()));
if(p->zipError==UNZ_OK) {
p->writePos=0;
setOpenMode(mode);
+5 -1
View File
@@ -121,7 +121,7 @@ void QuaZipNewInfo::setFilePermissions(const QString &file)
void QuaZipNewInfo::setPermissions(QFile::Permissions permissions)
{
QuaZipNewInfo_setPermissions(this, permissions, name.endsWith('/'));
QuaZipNewInfo_setPermissions(this, permissions, name.endsWith(QLatin1String("/")));
}
void QuaZipNewInfo::setFileNTFSTimes(const QString &fileName)
@@ -134,7 +134,11 @@ void QuaZipNewInfo::setFileNTFSTimes(const QString &fileName)
}
setFileNTFSmTime(fi.lastModified());
setFileNTFSaTime(fi.lastRead());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
setFileNTFScTime(fi.birthTime());
#else
setFileNTFScTime(fi.created());
#endif
}
static void setNTFSTime(QByteArray &extra, const QDateTime &time, int position,
+4 -3
View File
@@ -70,7 +70,7 @@ struct QUAZIP_EXPORT QuaZipNewInfo {
*/
quint32 externalAttr;
/// File comment.
/** Will be encoded using QuaZip::getCommentCodec().
/** Will be encoded in UTF-8 encoding.
**/
QString comment;
/// File local extra field.
@@ -148,8 +148,9 @@ struct QUAZIP_EXPORT QuaZipNewInfo {
/**
* If the file doesn't exist, a warning is printed to the stderr and nothing
* is done. Otherwise, all three times, as reported by
* QFileInfo::lastModified(), QFileInfo::lastRead() and QFileInfo::created(),
* are written to the NTFS extra field record.
* QFileInfo::lastModified(), QFileInfo::lastRead() and
* QFileInfo::birthTime() (>=Qt5.10) or QFileInfo::created(), are written to
* the NTFS extra field record.
*
* The NTFS record is written to
* both the local and the global extra fields, updating the existing record
+19 -3
View File
@@ -15,6 +15,8 @@
For more info read MiniZip_info.txt
Modifications for static code analysis report
Copyright (C) 2016 Intel Deutschland GmbH
------------------------------------------------------------------------------------
Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
@@ -28,7 +30,7 @@
If, for some reason, all these files are missing, the Info-ZIP license
also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h]
crypt.c (full version) by Info-ZIP. Last revised: [see minizip_crypt.h]
The encryption/decryption parts of this source code (as opposed to the
non-echoing password parts) were originally written in Europe. The
@@ -71,7 +73,7 @@
#include <stdlib.h>
#include <string.h>
#include "zlib.h"
#include <zlib.h>
#if (ZLIB_VERNUM < 0x1270)
typedef uLongf z_crc_t;
#endif
@@ -197,7 +199,7 @@ typedef struct
#ifndef NOUNCRYPT
#include "crypt.h"
#include "minizip_crypt.h"
#endif
/* ===========================================================================
@@ -856,6 +858,17 @@ extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info
pglobal_info32->size_comment = s->gi.size_comment;
return UNZ_OK;
}
extern int ZEXPORT unzGetFileFlags (unzFile file, unsigned* pflags)
{
unz64_s* s;
if (file==NULL)
return UNZ_PARAMERROR;
s=(unz64_s*)file;
*pflags = s->flags;
return UNZ_OK;
}
/*
Translate date/time from Dos format to tm_unz (readable more easilty)
*/
@@ -1198,6 +1211,8 @@ extern int ZEXPORT unzGoToFirstFile (unzFile file)
&s->cur_file_info_internal,
NULL,0,NULL,0,NULL,0);
s->current_file_ok = (err == UNZ_OK);
if (s->cur_file_info.flag & UNZ_ENCODING_UTF8)
unzSetFlags(file, UNZ_ENCODING_UTF8);
return err;
}
@@ -1594,6 +1609,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
else
{
TRYFREE(pfile_in_zip_read_info->read_buffer);
TRYFREE(pfile_in_zip_read_info);
return err;
}
+4 -1
View File
@@ -53,7 +53,7 @@ extern "C" {
#endif
#ifndef _ZLIB_H
#include "zlib.h"
#include <zlib.h>
#endif
#ifndef _ZLIBIOAPI_H
@@ -87,6 +87,7 @@ typedef voidp unzFile;
#define UNZ_AUTO_CLOSE 0x01u
#define UNZ_DEFAULT_FLAGS UNZ_AUTO_CLOSE
#define UNZ_ENCODING_UTF8 0x0800u
/* tm_unz contain date/time info */
typedef struct tm_unz_s
@@ -227,6 +228,8 @@ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
unz_global_info64 *pglobal_info));
extern int ZEXPORT unzGetFileFlags OF((unzFile file, unsigned* pflags));
/*
Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed
+21 -7
View File
@@ -12,6 +12,9 @@
Modifications for QIODevice support and other QuaZIP fixes
Copyright (C) 2005-2014 Sergey A. Tachenov
Fixing static code analysis issues
Copyright (C) 2016 Intel Deutschland GmbH
Changes
Oct-2009 - Mathias Svensson - Remove old C style function prototypes
Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives
@@ -29,7 +32,8 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "zlib.h"
#include <zlib.h>
#if (ZLIB_VERNUM < 0x1270)
typedef uLongf z_crc_t;
#endif
@@ -192,7 +196,7 @@ typedef struct
#ifndef NOCRYPT
#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED
#include "crypt.h"
#include "minizip_crypt.h"
#endif
local linkedlist_datablock_internal* allocate_new_datablock()
@@ -527,13 +531,14 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
break;
for (i=(int)uReadSize-3; (i--)>0;)
for (i=(int)uReadSize-3; (i--)>0;){
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
{
uPosFound = uReadPos+i;
break;
}
}
if (uPosFound!=0)
break;
@@ -988,7 +993,9 @@ int Write_LocalFileHeader(zip64_internal* zi, const char* filename,
if (err==ZIP_OK)
{
if(zi->ci.zip64)
if(zi->ci.flag & ZIP_ENCODING_UTF8)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)63,2);/* Version 6.3 is required for Unicode support */
else if(zi->ci.zip64)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);/* version needed to extract */
else
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)version_to_extract,2);
@@ -1146,6 +1153,8 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
}
zi->ci.flag = flagBase;
if (zi->flags & ZIP_ENCODING_UTF8)
zi->ci.flag |= ZIP_ENCODING_UTF8;
if ((level==8) || (level==9))
zi->ci.flag |= 2;
if (level==2)
@@ -1171,6 +1180,9 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
zi->ci.size_centralExtraFree = 32; /* Extra space we have reserved in case we need to add ZIP64 extra info data */
zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader + zi->ci.size_centralExtraFree);
if(!zi->ci.central_header) {
return (Z_MEM_ERROR);
}
zi->ci.size_centralExtra = size_extrafield_global;
zip64local_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4);
@@ -1648,8 +1660,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_s
/*version Made by*/
zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)45,2);
/*version needed*/
zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)45,2);
zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)((zi->ci.flag & ZIP_ENCODING_UTF8) ? 63 : 45),2);
}
zip64local_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/
@@ -1843,7 +1854,7 @@ int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centra
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);
if (err==ZIP_OK) /* version needed */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)((zi->ci.flag & ZIP_ENCODING_UTF8) ? 63 : 45),2);
if (err==ZIP_OK) /* number of this disk */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4);
@@ -2025,6 +2036,9 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
return ZIP_PARAMERROR;
pNewHeader = (char*)ALLOC(*dataLen);
if(!pNewHeader) {
return Z_MEM_ERROR;
}
pTmp = pNewHeader;
while(p < (pData + *dataLen))
+2 -1
View File
@@ -53,7 +53,7 @@ extern "C" {
//#define HAVE_BZIP2
#ifndef _ZLIB_H
#include "zlib.h"
#include <zlib.h>
#endif
#ifndef _ZLIBIOAPI_H
@@ -85,6 +85,7 @@ typedef voidp zipFile;
#define ZIP_WRITE_DATA_DESCRIPTOR 0x8u
#define ZIP_AUTO_CLOSE 0x1u
#define ZIP_SEQUENTIAL 0x2u
#define ZIP_ENCODING_UTF8 0x0800u
#define ZIP_DEFAULT_FLAGS (ZIP_AUTO_CLOSE | ZIP_WRITE_DATA_DESCRIPTOR)
#ifndef DEF_MEM_LEVEL