mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-04-11 16:37:45 -04:00
rbutil: Upgrade bundled quazip from 0.9.1 to 1.1
Just reducing the delta a little bit. Later versions are more complicated. Change-Id: If0452a529b840383333062ec2604ff257646627a
This commit is contained in:
parent
e11a449031
commit
ee3e630efa
16 changed files with 262 additions and 192 deletions
|
|
@ -3,7 +3,7 @@ These files are distributed under the LGPL v2.1 or later. Only source files
|
|||
actually used in Rockbox Utility are included, further sources have been left
|
||||
out. Check the quazip source distribution for those.
|
||||
|
||||
The source files have been last synced with the projects release 0.9.1 at
|
||||
https://github.com/stachenov/quazip/ on June 8, 2020.
|
||||
The source files have been last synced with the project's release 1.1 at
|
||||
https://github.com/stachenov/quazip/ on October 11, 2020.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,7 @@
|
|||
#include "ioapi.h"
|
||||
#include "quazip_global.h"
|
||||
#include <QtCore/QIODevice>
|
||||
#if (QT_VERSION >= 0x050100)
|
||||
#define QUAZIP_QSAVEFILE_BUG_WORKAROUND
|
||||
#endif
|
||||
#ifdef QUAZIP_QSAVEFILE_BUG_WORKAROUND
|
||||
#include <QtCore/QSaveFile>
|
||||
#endif
|
||||
#include "quazip_qt_compat.h"
|
||||
|
||||
/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
|
||||
|
||||
|
|
@ -39,7 +34,7 @@
|
|||
|
||||
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,voidpf file,int mode)
|
||||
{
|
||||
if (pfilefunc->zfile_func64.zopen64_file != NULL)
|
||||
if (pfilefunc->zfile_func64.zopen64_file != nullptr)
|
||||
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,file,mode);
|
||||
else
|
||||
{
|
||||
|
|
@ -49,7 +44,7 @@ voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,voidpf file,int mod
|
|||
|
||||
int call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)
|
||||
{
|
||||
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
||||
if (pfilefunc->zfile_func64.zseek64_file != nullptr)
|
||||
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
|
||||
else
|
||||
{
|
||||
|
|
@ -63,7 +58,7 @@ int call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPO
|
|||
|
||||
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)
|
||||
{
|
||||
if (pfilefunc->zfile_func64.zseek64_file != NULL)
|
||||
if (pfilefunc->zfile_func64.zseek64_file != nullptr)
|
||||
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
|
||||
else
|
||||
{
|
||||
|
|
@ -105,7 +100,7 @@ voidpf ZCALLBACK qiodevice_open_file_func (
|
|||
&& iodevice->isSequential()) {
|
||||
// We can use sequential devices only for writing.
|
||||
delete d;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
if ((desiredMode & QIODevice::WriteOnly) != 0) {
|
||||
// open for writing, need to seek existing device
|
||||
|
|
@ -119,7 +114,7 @@ voidpf ZCALLBACK qiodevice_open_file_func (
|
|||
return iodevice;
|
||||
} else {
|
||||
delete d;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
iodevice->open(desiredMode);
|
||||
|
|
@ -128,13 +123,13 @@ voidpf ZCALLBACK qiodevice_open_file_func (
|
|||
// We can use sequential devices only for writing.
|
||||
iodevice->close();
|
||||
delete d;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else {
|
||||
return iodevice;
|
||||
}
|
||||
} else {
|
||||
delete d;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -287,17 +282,7 @@ int ZCALLBACK qiodevice_close_file_func (
|
|||
QIODevice_descriptor *d = reinterpret_cast<QIODevice_descriptor*>(opaque);
|
||||
delete d;
|
||||
QIODevice *device = reinterpret_cast<QIODevice*>(stream);
|
||||
#ifdef QUAZIP_QSAVEFILE_BUG_WORKAROUND
|
||||
// QSaveFile terribly breaks the is-a idiom:
|
||||
// it IS a QIODevice, but it is NOT compatible with it: close() is private
|
||||
QSaveFile *file = qobject_cast<QSaveFile*>(device);
|
||||
if (file != NULL) {
|
||||
// We have to call the ugly commit() instead:
|
||||
return file->commit() ? 0 : -1;
|
||||
}
|
||||
#endif
|
||||
device->close();
|
||||
return 0;
|
||||
return quazip_close(device) ? 0 : -1;
|
||||
}
|
||||
|
||||
int ZCALLBACK qiodevice_fakeclose_file_func (
|
||||
|
|
@ -347,17 +332,17 @@ void fill_qiodevice64_filefunc (
|
|||
|
||||
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32)
|
||||
{
|
||||
p_filefunc64_32->zfile_func64.zopen64_file = NULL;
|
||||
p_filefunc64_32->zfile_func64.zopen64_file = nullptr;
|
||||
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
|
||||
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
||||
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
|
||||
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
|
||||
p_filefunc64_32->zfile_func64.ztell64_file = NULL;
|
||||
p_filefunc64_32->zfile_func64.zseek64_file = NULL;
|
||||
p_filefunc64_32->zfile_func64.ztell64_file = nullptr;
|
||||
p_filefunc64_32->zfile_func64.zseek64_file = nullptr;
|
||||
p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file;
|
||||
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
|
||||
p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
|
||||
p_filefunc64_32->zfile_func64.zfakeclose_file = NULL;
|
||||
p_filefunc64_32->zfile_func64.zfakeclose_file = nullptr;
|
||||
p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
|
||||
p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
/*
|
||||
Copyright (C) 2005-2014 Sergey A. Tachenov
|
||||
|
||||
This file is part of QuaZIP.
|
||||
This file is part of QuaZip.
|
||||
|
||||
QuaZIP is free software: you can redistribute it and/or modify
|
||||
QuaZip is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QuaZIP is distributed in the hope that it will be useful,
|
||||
QuaZip is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with QuaZip. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
See COPYING file for the full LGPL text.
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ class QuaZipPrivate {
|
|||
uint osCode;
|
||||
inline QTextCodec *getDefaultFileNameCodec()
|
||||
{
|
||||
if (defaultFileNameCodec == NULL) {
|
||||
if (defaultFileNameCodec == nullptr) {
|
||||
return QTextCodec::codecForLocale();
|
||||
} else {
|
||||
return defaultFileNameCodec;
|
||||
|
|
@ -89,7 +89,7 @@ class QuaZipPrivate {
|
|||
q(q),
|
||||
fileNameCodec(getDefaultFileNameCodec()),
|
||||
commentCodec(QTextCodec::codecForLocale()),
|
||||
ioDevice(NULL),
|
||||
ioDevice(nullptr),
|
||||
mode(QuaZip::mdNotOpen),
|
||||
hasCurrentFile_f(false),
|
||||
zipError(UNZ_OK),
|
||||
|
|
@ -99,8 +99,8 @@ class QuaZipPrivate {
|
|||
utf8(false),
|
||||
osCode(defaultOsCode)
|
||||
{
|
||||
unzFile_f = NULL;
|
||||
zipFile_f = NULL;
|
||||
unzFile_f = nullptr;
|
||||
zipFile_f = nullptr;
|
||||
lastMappedDirectoryEntry.num_of_file = 0;
|
||||
lastMappedDirectoryEntry.pos_in_zip_directory = 0;
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ class QuaZipPrivate {
|
|||
fileNameCodec(getDefaultFileNameCodec()),
|
||||
commentCodec(QTextCodec::codecForLocale()),
|
||||
zipName(zipName),
|
||||
ioDevice(NULL),
|
||||
ioDevice(nullptr),
|
||||
mode(QuaZip::mdNotOpen),
|
||||
hasCurrentFile_f(false),
|
||||
zipError(UNZ_OK),
|
||||
|
|
@ -120,8 +120,8 @@ class QuaZipPrivate {
|
|||
utf8(false),
|
||||
osCode(defaultOsCode)
|
||||
{
|
||||
unzFile_f = NULL;
|
||||
zipFile_f = NULL;
|
||||
unzFile_f = nullptr;
|
||||
zipFile_f = nullptr;
|
||||
lastMappedDirectoryEntry.num_of_file = 0;
|
||||
lastMappedDirectoryEntry.pos_in_zip_directory = 0;
|
||||
}
|
||||
|
|
@ -140,8 +140,8 @@ class QuaZipPrivate {
|
|||
utf8(false),
|
||||
osCode(defaultOsCode)
|
||||
{
|
||||
unzFile_f = NULL;
|
||||
zipFile_f = NULL;
|
||||
unzFile_f = nullptr;
|
||||
zipFile_f = nullptr;
|
||||
lastMappedDirectoryEntry.num_of_file = 0;
|
||||
lastMappedDirectoryEntry.pos_in_zip_directory = 0;
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ class QuaZipPrivate {
|
|||
static uint defaultOsCode;
|
||||
};
|
||||
|
||||
QTextCodec *QuaZipPrivate::defaultFileNameCodec = NULL;
|
||||
QTextCodec *QuaZipPrivate::defaultFileNameCodec = nullptr;
|
||||
uint QuaZipPrivate::defaultOsCode = QUAZIP_OS_UNIX;
|
||||
|
||||
void QuaZipPrivate::clearDirectoryMap()
|
||||
|
|
@ -241,7 +241,7 @@ bool QuaZip::open(Mode mode, zlib_filefunc_def* ioApi)
|
|||
return false;
|
||||
}
|
||||
QIODevice *ioDevice = p->ioDevice;
|
||||
if (ioDevice == NULL) {
|
||||
if (ioDevice == nullptr) {
|
||||
if (p->zipName.isEmpty()) {
|
||||
qWarning("QuaZip::open(): set either ZIP file name or IO device first");
|
||||
return false;
|
||||
|
|
@ -252,14 +252,14 @@ bool QuaZip::open(Mode mode, zlib_filefunc_def* ioApi)
|
|||
unsigned flags = 0;
|
||||
switch(mode) {
|
||||
case mdUnzip:
|
||||
if (ioApi == NULL) {
|
||||
if (ioApi == nullptr) {
|
||||
if (p->autoClose)
|
||||
flags |= UNZ_AUTO_CLOSE;
|
||||
p->unzFile_f=unzOpenInternal(ioDevice, NULL, 1, flags);
|
||||
p->unzFile_f=unzOpenInternal(ioDevice, nullptr, 1, flags);
|
||||
} else {
|
||||
// QuaZIP pre-zip64 compatibility mode
|
||||
// QuaZip pre-zip64 compatibility mode
|
||||
p->unzFile_f=unzOpen2(ioDevice, ioApi);
|
||||
if (p->unzFile_f != NULL) {
|
||||
if (p->unzFile_f != nullptr) {
|
||||
if (p->autoClose) {
|
||||
unzSetFlags(p->unzFile_f, UNZ_AUTO_CLOSE);
|
||||
} else {
|
||||
|
|
@ -267,7 +267,7 @@ bool QuaZip::open(Mode mode, zlib_filefunc_def* ioApi)
|
|||
}
|
||||
}
|
||||
}
|
||||
if(p->unzFile_f!=NULL) {
|
||||
if(p->unzFile_f!=nullptr) {
|
||||
if (ioDevice->isSequential()) {
|
||||
unzClose(p->unzFile_f);
|
||||
if (!p->zipName.isEmpty())
|
||||
|
|
@ -289,7 +289,7 @@ bool QuaZip::open(Mode mode, zlib_filefunc_def* ioApi)
|
|||
case mdCreate:
|
||||
case mdAppend:
|
||||
case mdAdd:
|
||||
if (ioApi == NULL) {
|
||||
if (ioApi == nullptr) {
|
||||
if (p->autoClose)
|
||||
flags |= ZIP_AUTO_CLOSE;
|
||||
if (p->dataDescriptorWritingEnabled)
|
||||
|
|
@ -300,23 +300,23 @@ bool QuaZip::open(Mode mode, zlib_filefunc_def* ioApi)
|
|||
mode==mdCreate?APPEND_STATUS_CREATE:
|
||||
mode==mdAppend?APPEND_STATUS_CREATEAFTER:
|
||||
APPEND_STATUS_ADDINZIP,
|
||||
NULL, NULL, flags);
|
||||
nullptr, nullptr, flags);
|
||||
} else {
|
||||
// QuaZIP pre-zip64 compatibility mode
|
||||
// QuaZip pre-zip64 compatibility mode
|
||||
p->zipFile_f=zipOpen2(ioDevice,
|
||||
mode==mdCreate?APPEND_STATUS_CREATE:
|
||||
mode==mdAppend?APPEND_STATUS_CREATEAFTER:
|
||||
APPEND_STATUS_ADDINZIP,
|
||||
NULL,
|
||||
nullptr,
|
||||
ioApi);
|
||||
if (p->zipFile_f != NULL) {
|
||||
if (p->zipFile_f != nullptr) {
|
||||
zipSetFlags(p->zipFile_f, flags);
|
||||
}
|
||||
}
|
||||
if(p->zipFile_f!=NULL) {
|
||||
if(p->zipFile_f!=nullptr) {
|
||||
if (ioDevice->isSequential()) {
|
||||
if (mode != mdCreate) {
|
||||
zipClose(p->zipFile_f, NULL);
|
||||
zipClose(p->zipFile_f, nullptr);
|
||||
qWarning("QuaZip::open(): "
|
||||
"only mdCreate can be used with "
|
||||
"sequential devices");
|
||||
|
|
@ -357,7 +357,7 @@ void QuaZip::close()
|
|||
case mdCreate:
|
||||
case mdAppend:
|
||||
case mdAdd:
|
||||
p->zipError=zipClose(p->zipFile_f, p->comment.isNull() ? NULL : isUtf8Enabled()
|
||||
p->zipError=zipClose(p->zipFile_f, p->comment.isNull() ? nullptr : isUtf8Enabled()
|
||||
? p->comment.toUtf8().constData()
|
||||
: p->commentCodec->fromUnicode(p->comment).constData());
|
||||
break;
|
||||
|
|
@ -368,7 +368,7 @@ void QuaZip::close()
|
|||
// opened by name, need to delete the internal IO device
|
||||
if (!p->zipName.isEmpty()) {
|
||||
delete p->ioDevice;
|
||||
p->ioDevice = NULL;
|
||||
p->ioDevice = nullptr;
|
||||
}
|
||||
p->clearDirectoryMap();
|
||||
if(p->zipError==UNZ_OK)
|
||||
|
|
@ -382,7 +382,7 @@ void QuaZip::setZipName(const QString& zipName)
|
|||
return;
|
||||
}
|
||||
p->zipName=zipName;
|
||||
p->ioDevice = NULL;
|
||||
p->ioDevice = nullptr;
|
||||
}
|
||||
|
||||
void QuaZip::setIoDevice(QIODevice *ioDevice)
|
||||
|
|
@ -442,7 +442,7 @@ bool QuaZip::setCurrentFile(const QString& fileName, CaseSensitivity cs)
|
|||
return true;
|
||||
}
|
||||
// Unicode-aware reimplementation of the unzLocateFile function
|
||||
if(p->unzFile_f==NULL) {
|
||||
if(p->unzFile_f==nullptr) {
|
||||
p->zipError=UNZ_PARAMERROR;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -517,7 +517,7 @@ bool QuaZip::goToNextFile()
|
|||
bool QuaZip::getCurrentFileInfo(QuaZipFileInfo *info)const
|
||||
{
|
||||
QuaZipFileInfo64 info64;
|
||||
if (info == NULL) { // Very unlikely because of the overloads
|
||||
if (info == nullptr) { // Very unlikely because of the overloads
|
||||
return false;
|
||||
}
|
||||
if (getCurrentFileInfo(&info64)) {
|
||||
|
|
@ -540,14 +540,14 @@ bool QuaZip::getCurrentFileInfo(QuaZipFileInfo64 *info)const
|
|||
QByteArray fileName;
|
||||
QByteArray extra;
|
||||
QByteArray comment;
|
||||
if(info==NULL) return false;
|
||||
if(info==nullptr) return false;
|
||||
if(!isOpen()||!hasCurrentFile()) return false;
|
||||
if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, &info_z, NULL, 0, NULL, 0, NULL, 0))!=UNZ_OK)
|
||||
if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, &info_z, nullptr, 0, nullptr, 0, nullptr, 0))!=UNZ_OK)
|
||||
return false;
|
||||
fileName.resize(info_z.size_filename);
|
||||
extra.resize(info_z.size_file_extra);
|
||||
comment.resize(info_z.size_file_comment);
|
||||
if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, NULL,
|
||||
if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, nullptr,
|
||||
fileName.data(), fileName.size(),
|
||||
extra.data(), extra.size(),
|
||||
comment.data(), comment.size()))!=UNZ_OK)
|
||||
|
|
@ -585,7 +585,7 @@ QString QuaZip::getCurrentFileName()const
|
|||
QByteArray fileName(MAX_FILE_NAME_LENGTH, 0);
|
||||
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)
|
||||
nullptr, 0, nullptr, 0))!=UNZ_OK)
|
||||
return QString();
|
||||
fileName.resize(file_info.size_filename);
|
||||
QString result = (file_info.flag & UNZ_ENCODING_UTF8)
|
||||
|
|
@ -645,7 +645,7 @@ QString QuaZip::getZipName() const
|
|||
QIODevice *QuaZip::getIoDevice() const
|
||||
{
|
||||
if (!p->zipName.isEmpty()) // opened by name, using an internal QIODevice
|
||||
return NULL;
|
||||
return nullptr;
|
||||
return p->ioDevice;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,20 +4,20 @@
|
|||
/*
|
||||
Copyright (C) 2005-2014 Sergey A. Tachenov
|
||||
|
||||
This file is part of QuaZIP.
|
||||
This file is part of QuaZip.
|
||||
|
||||
QuaZIP is free software: you can redistribute it and/or modify
|
||||
QuaZip is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QuaZIP is distributed in the hope that it will be useful,
|
||||
QuaZip is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with QuaZip. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
See COPYING file for the full LGPL text.
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ quazip/(un)zip.h files for details, basically it's zlib license.
|
|||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QTextCodec>
|
||||
#include "quazip_qt_compat.h"
|
||||
|
||||
#include "zip.h"
|
||||
#include "unzip.h"
|
||||
|
|
@ -116,7 +116,7 @@ class QUAZIP_EXPORT QuaZip {
|
|||
csSensitive=1, ///< Case sensitive.
|
||||
csInsensitive=2 ///< Case insensitive.
|
||||
};
|
||||
/// Returns the actual case sensitivity for the specified QuaZIP one.
|
||||
/// Returns the actual case sensitivity for the specified QuaZip one.
|
||||
/**
|
||||
\param cs The value to convert.
|
||||
\returns If CaseSensitivity::csDefault, then returns the default
|
||||
|
|
@ -153,17 +153,17 @@ class QUAZIP_EXPORT QuaZip {
|
|||
*
|
||||
* If the ZIP file is accessed via explicitly set QIODevice, then
|
||||
* this device is opened in the necessary mode. If the device was
|
||||
* already opened by some other means, then QuaZIP checks if the
|
||||
* already opened by some other means, then QuaZip checks if the
|
||||
* open mode is compatible to the mode needed for the requested operation.
|
||||
* If necessary, seeking is performed to position the device properly.
|
||||
*
|
||||
* \return \c true if successful, \c false otherwise.
|
||||
*
|
||||
* \note ZIP/UNZIP API open calls do not return error code - they
|
||||
* just return \c NULL indicating an error. But to make things
|
||||
* just return \c null indicating an error. But to make things
|
||||
* easier, quazip.h header defines additional error code \c
|
||||
* UNZ_ERROROPEN and getZipError() will return it if the open call
|
||||
* of the ZIP/UNZIP API returns \c NULL.
|
||||
* of the ZIP/UNZIP API returns \c null.
|
||||
*
|
||||
* Argument \a ioApi specifies IO function set for ZIP/UNZIP
|
||||
* package to use. See unzip.h, zip.h and ioapi.h for details. Note
|
||||
|
|
@ -177,12 +177,12 @@ class QUAZIP_EXPORT QuaZip {
|
|||
* QIODevice instead of file name, but also has a nice side effect
|
||||
* 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
|
||||
* \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.
|
||||
*
|
||||
* \note If the \ref QuaZip::setAutoClose() "no-auto-close" feature is used,
|
||||
* then the \a ioApi argument \em should be NULL because the old API
|
||||
* then the \a ioApi argument \em should be null because the old API
|
||||
* doesn't support the 'fake close' operation, causing slight memory leaks
|
||||
* and other possible troubles (like closing the output device in case
|
||||
* when an error occurs during opening).
|
||||
|
|
@ -190,7 +190,7 @@ class QUAZIP_EXPORT QuaZip {
|
|||
* In short: just forget about the \a ioApi argument and you'll be
|
||||
* fine.
|
||||
**/
|
||||
bool open(Mode mode, zlib_filefunc_def *ioApi =NULL);
|
||||
bool open(Mode mode, zlib_filefunc_def *ioApi =nullptr);
|
||||
/// Closes ZIP file.
|
||||
/** Call getZipError() to determine if the close was successful.
|
||||
*
|
||||
|
|
@ -206,7 +206,7 @@ class QUAZIP_EXPORT QuaZip {
|
|||
* by making close() private and crashing the application if it is called
|
||||
* from the base class where it is public. It is an excellent example
|
||||
* of poor design that illustrates why you should never ever break
|
||||
* an is-a relationship between the base class and a subclass. QuaZIP
|
||||
* an is-a relationship between the base class and a subclass. QuaZip
|
||||
* works around this bug by checking if the QIODevice is an instance
|
||||
* of QSaveFile, using qobject_cast<>, and if it is, calls
|
||||
* QSaveFile::commit() instead of close(). It is a really ugly hack,
|
||||
|
|
@ -427,7 +427,7 @@ class QUAZIP_EXPORT QuaZip {
|
|||
According to the ZIP format specification, a file inside archive
|
||||
may have a data descriptor immediately following the file
|
||||
data. This is reflected by a special flag in the local file header
|
||||
and in the central directory. By default, QuaZIP sets this flag
|
||||
and in the central directory. By default, QuaZip sets this flag
|
||||
and writes the data descriptor unless both method and level were
|
||||
set to 0, in which case it operates in 1.0-compatible mode and
|
||||
never writes data descriptors.
|
||||
|
|
@ -539,14 +539,14 @@ class QUAZIP_EXPORT QuaZip {
|
|||
bool isAutoClose() const;
|
||||
/// Sets or unsets the auto-close flag.
|
||||
/**
|
||||
By default, QuaZIP opens the underlying QIODevice when open() is called,
|
||||
By default, QuaZip opens the underlying QIODevice when open() is called,
|
||||
and closes it when close() is called. In some cases, when the device
|
||||
is set explicitly using setIoDevice(), it may be desirable to
|
||||
leave the device open. If the auto-close flag is unset using this method,
|
||||
then the device isn't closed automatically if it was set explicitly.
|
||||
|
||||
If it is needed to clear this flag, it is recommended to do so before
|
||||
opening the archive because otherwise QuaZIP may close the device
|
||||
opening the archive because otherwise QuaZip may close the device
|
||||
during the open() call if an error is encountered after the device
|
||||
is opened.
|
||||
|
||||
|
|
@ -567,7 +567,7 @@ class QUAZIP_EXPORT QuaZip {
|
|||
* The codec specified here can be overriden by calling setFileNameCodec().
|
||||
* If neither function is called, QTextCodec::codecForLocale() will be used
|
||||
* 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 overriding
|
||||
* your setting or can rely on the default encoding, thus failing
|
||||
* mysteriously if you change it. For these reasons, it isn't recommended
|
||||
|
|
@ -576,7 +576,7 @@ class QUAZIP_EXPORT QuaZip {
|
|||
* encoding.
|
||||
*
|
||||
* In most cases, using setFileNameCodec() instead is the right choice.
|
||||
* However, if you depend on third-party code that uses QuaZIP, then the
|
||||
* However, if you depend on third-party code that uses QuaZip, then the
|
||||
* reasons stated above can actually become a reason to use this function
|
||||
* in case the third-party code in question fails because it doesn't
|
||||
* understand the encoding you need and doesn't provide a way to specify it.
|
||||
|
|
@ -587,7 +587,7 @@ class QUAZIP_EXPORT QuaZip {
|
|||
* setDefaultFileNameCodec() when you don't have access to the QuaZip
|
||||
* instance.
|
||||
*
|
||||
* @param codec The codec to use by default. If NULL, resets to default.
|
||||
* @param codec The codec to use by default. If null, resets to default.
|
||||
*/
|
||||
static void setDefaultFileNameCodec(QTextCodec *codec);
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
SOURCES += \
|
||||
$$PWD/quazip.cpp \
|
||||
$$PWD/quazipfile.cpp \
|
||||
$$PWD/quazipnewinfo.cpp \
|
||||
$$PWD/quazipfileinfo.cpp \
|
||||
$$PWD/qioapi.cpp \
|
||||
$$PWD/unzip.c \
|
||||
$$PWD/zip.c \
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/minizip_crypt.h \
|
||||
$$PWD/ioapi.h \
|
||||
$$PWD/quazipfile.h \
|
||||
$$PWD/quazipfileinfo.h \
|
||||
$$PWD/quazipnewinfo.h \
|
||||
$$PWD/quazip.h \
|
||||
$$PWD/quazipnewinfo.h \
|
||||
$$PWD/quazip_global.h \
|
||||
$$PWD/unzip.h \
|
||||
$$PWD/zip.h \
|
||||
|
||||
DEFINES += \
|
||||
QUAZIP_STATIC
|
||||
|
||||
120
utils/rbutilqt/quazip/quazip_qt_compat.h
Normal file
120
utils/rbutilqt/quazip/quazip_qt_compat.h
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
#ifndef QUAZIP_QT_COMPAT_H
|
||||
#define QUAZIP_QT_COMPAT_H
|
||||
|
||||
/*
|
||||
* For some reason, Qt 5.14 and 5.15 introduced a whole mess of seemingly random
|
||||
* moves and deprecations. To avoid populating code with #ifs,
|
||||
* we handle this stuff here, as well as some other compatibility issues.
|
||||
*
|
||||
* Some includes are repeated just in case we want to split this file later.
|
||||
*/
|
||||
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
|
||||
// Legacy encodings are still everywhere, but the Qt team decided we
|
||||
// don't need them anymore and moved them out of Core in Qt 6.
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
# include <QtCore5Compat/QTextCodec>
|
||||
#else
|
||||
# include <QtCore/QTextCodec>
|
||||
#endif
|
||||
|
||||
// QSaveFile terribly breaks the is-a idiom (Liskov substitution principle):
|
||||
// QSaveFile is-a QIODevice, but it makes close() private and aborts
|
||||
// if you call it through the base class. Hence this ugly hack:
|
||||
#if (QT_VERSION >= 0x050100)
|
||||
#include <QtCore/QSaveFile>
|
||||
inline bool quazip_close(QIODevice *device) {
|
||||
QSaveFile *file = qobject_cast<QSaveFile*>(device);
|
||||
if (file != nullptr) {
|
||||
// We have to call the ugly commit() instead:
|
||||
return file->commit();
|
||||
} else {
|
||||
device->close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#else
|
||||
inline bool quazip_close(QIODevice *device) {
|
||||
device->close();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// this is yet another stupid move and deprecation
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
using Qt::SkipEmptyParts;
|
||||
#else
|
||||
#include <QString>
|
||||
const auto SkipEmptyParts = QString::SplitBehavior::SkipEmptyParts;
|
||||
#endif
|
||||
|
||||
// and yet another... (why didn't they just make qSort delegate to std::sort?)
|
||||
#include <QList>
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
|
||||
#include <algorithm>
|
||||
template<typename T, typename C>
|
||||
inline void quazip_sort(T begin, T end, C comparator) {
|
||||
std::sort(begin, end, comparator);
|
||||
}
|
||||
#else
|
||||
#include <QtAlgorithms>
|
||||
template<typename T, typename C>
|
||||
inline void quazip_sort(T begin, T end, C comparator) {
|
||||
qSort(begin, end, comparator);
|
||||
}
|
||||
#endif
|
||||
|
||||
// this is a stupid rename...
|
||||
#include <QDateTime>
|
||||
#include <QFileInfo>
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
inline QDateTime quazip_ctime(const QFileInfo &fi) {
|
||||
return fi.birthTime();
|
||||
}
|
||||
#else
|
||||
inline QDateTime quazip_ctime(const QFileInfo &fi) {
|
||||
return fi.created();
|
||||
}
|
||||
#endif
|
||||
|
||||
// this is not a deprecation but an improvement, for a change
|
||||
#include <QDateTime>
|
||||
#if (QT_VERSION >= 0x040700)
|
||||
inline quint64 quazip_ntfs_ticks(const QDateTime &time, int fineTicks) {
|
||||
QDateTime base(QDate(1601, 1, 1), QTime(0, 0), Qt::UTC);
|
||||
return base.msecsTo(time) * 10000 + fineTicks;
|
||||
}
|
||||
#else
|
||||
inline quint64 quazip_ntfs_ticks(const QDateTime &time, int fineTicks) {
|
||||
QDateTime base(QDate(1601, 1, 1), QTime(0, 0), Qt::UTC);
|
||||
QDateTime utc = time.toUTC();
|
||||
return (static_cast<qint64>(base.date().daysTo(utc.date()))
|
||||
* Q_INT64_C(86400000)
|
||||
+ static_cast<qint64>(base.time().msecsTo(utc.time())))
|
||||
* Q_INT64_C(10000) + fineTicks;
|
||||
}
|
||||
#endif
|
||||
|
||||
// yet another improvement...
|
||||
#include <QDateTime>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) // Yay! Finally a way to get time as qint64!
|
||||
inline qint64 quazip_to_time64_t(const QDateTime &time) {
|
||||
return time.toSecsSinceEpoch();
|
||||
}
|
||||
#else
|
||||
inline qint64 quazip_to_time64_t(const QDateTime &time) {
|
||||
return static_cast<qint64>(time.toTime_t()); // 32 bits only, but better than nothing
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <QTextStream>
|
||||
// and another stupid move
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
const auto quazip_endl = Qt::endl;
|
||||
#else
|
||||
const auto quazip_endl = endl;
|
||||
#endif
|
||||
|
||||
#endif // QUAZIP_QT_COMPAT_H
|
||||
|
|
@ -1,20 +1,20 @@
|
|||
/*
|
||||
Copyright (C) 2005-2014 Sergey A. Tachenov
|
||||
|
||||
This file is part of QuaZIP.
|
||||
This file is part of QuaZip.
|
||||
|
||||
QuaZIP is free software: you can redistribute it and/or modify
|
||||
QuaZip is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QuaZIP is distributed in the hope that it will be useful,
|
||||
QuaZip is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with QuaZip. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
See COPYING file for the full LGPL text.
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ class QuaZipFilePrivate {
|
|||
/// The constructor for the corresponding QuaZipFile constructor.
|
||||
inline QuaZipFilePrivate(QuaZipFile *q):
|
||||
q(q),
|
||||
zip(NULL),
|
||||
zip(nullptr),
|
||||
caseSensitivity(QuaZip::csDefault),
|
||||
raw(false),
|
||||
writePos(0),
|
||||
|
|
@ -177,18 +177,18 @@ QuaZipFile::~QuaZipFile()
|
|||
|
||||
QString QuaZipFile::getZipName() const
|
||||
{
|
||||
return p->zip==NULL ? QString() : p->zip->getZipName();
|
||||
return p->zip==nullptr ? QString() : p->zip->getZipName();
|
||||
}
|
||||
|
||||
QuaZip *QuaZipFile::getZip() const
|
||||
{
|
||||
return p->internal ? NULL : p->zip;
|
||||
return p->internal ? nullptr : p->zip;
|
||||
}
|
||||
|
||||
QString QuaZipFile::getActualFileName()const
|
||||
{
|
||||
p->setZipError(UNZ_OK);
|
||||
if (p->zip == NULL || (openMode() & WriteOnly))
|
||||
if (p->zip == nullptr || (openMode() & WriteOnly))
|
||||
return QString();
|
||||
QString name=p->zip->getCurrentFileName();
|
||||
if(name.isNull())
|
||||
|
|
@ -202,7 +202,7 @@ void QuaZipFile::setZipName(const QString& zipName)
|
|||
qWarning("QuaZipFile::setZipName(): file is already open - can not set ZIP name");
|
||||
return;
|
||||
}
|
||||
if(p->zip!=NULL && p->internal)
|
||||
if(p->zip!=nullptr && p->internal)
|
||||
delete p->zip;
|
||||
p->zip=new QuaZip(zipName);
|
||||
p->internal=true;
|
||||
|
|
@ -214,7 +214,7 @@ void QuaZipFile::setZip(QuaZip *zip)
|
|||
qWarning("QuaZipFile::setZip(): file is already open - can not set ZIP");
|
||||
return;
|
||||
}
|
||||
if(p->zip!=NULL && p->internal)
|
||||
if(p->zip!=nullptr && p->internal)
|
||||
delete p->zip;
|
||||
p->zip=zip;
|
||||
p->fileName=QString();
|
||||
|
|
@ -223,7 +223,7 @@ void QuaZipFile::setZip(QuaZip *zip)
|
|||
|
||||
void QuaZipFile::setFileName(const QString& fileName, QuaZip::CaseSensitivity cs)
|
||||
{
|
||||
if(p->zip==NULL) {
|
||||
if(p->zip==nullptr) {
|
||||
qWarning("QuaZipFile::setFileName(): call setZipName() first");
|
||||
return;
|
||||
}
|
||||
|
|
@ -253,7 +253,7 @@ void QuaZipFilePrivate::setZipError(int zipError) const
|
|||
|
||||
bool QuaZipFile::open(OpenMode mode)
|
||||
{
|
||||
return open(mode, NULL);
|
||||
return open(mode, nullptr);
|
||||
}
|
||||
|
||||
bool QuaZipFile::open(OpenMode mode, int *method, int *level, bool raw, const char *password)
|
||||
|
|
@ -279,8 +279,8 @@ bool QuaZipFile::open(OpenMode mode, int *method, int *level, bool raw, const ch
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
if(p->zip==NULL) {
|
||||
qWarning("QuaZipFile::open(): zip is NULL");
|
||||
if(p->zip==nullptr) {
|
||||
qWarning("QuaZipFile::open(): zip is null");
|
||||
return false;
|
||||
}
|
||||
if(p->zip->getMode()!=QuaZip::mdUnzip) {
|
||||
|
|
@ -321,8 +321,8 @@ bool QuaZipFile::open(OpenMode mode, const QuaZipNewInfo& info,
|
|||
qWarning("QuaZipFile::open(): write mode is incompatible with internal QuaZip approach");
|
||||
return false;
|
||||
}
|
||||
if(p->zip==NULL) {
|
||||
qWarning("QuaZipFile::open(): zip is NULL");
|
||||
if(p->zip==nullptr) {
|
||||
qWarning("QuaZipFile::open(): zip is null");
|
||||
return false;
|
||||
}
|
||||
if(p->zip->getMode()!=QuaZip::mdCreate&&p->zip->getMode()!=QuaZip::mdAppend&&p->zip->getMode()!=QuaZip::mdAdd) {
|
||||
|
|
@ -382,7 +382,7 @@ bool QuaZipFile::isSequential()const
|
|||
|
||||
qint64 QuaZipFile::pos()const
|
||||
{
|
||||
if(p->zip==NULL) {
|
||||
if(p->zip==nullptr) {
|
||||
qWarning("QuaZipFile::pos(): call setZipName() or setZip() first");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -401,7 +401,7 @@ qint64 QuaZipFile::pos()const
|
|||
|
||||
bool QuaZipFile::atEnd()const
|
||||
{
|
||||
if(p->zip==NULL) {
|
||||
if(p->zip==nullptr) {
|
||||
qWarning("QuaZipFile::atEnd(): call setZipName() or setZip() first");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -433,8 +433,8 @@ qint64 QuaZipFile::csize()const
|
|||
{
|
||||
unz_file_info64 info_z;
|
||||
p->setZipError(UNZ_OK);
|
||||
if(p->zip==NULL||p->zip->getMode()!=QuaZip::mdUnzip) return -1;
|
||||
p->setZipError(unzGetCurrentFileInfo64(p->zip->getUnzFile(), &info_z, NULL, 0, NULL, 0, NULL, 0));
|
||||
if(p->zip==nullptr||p->zip->getMode()!=QuaZip::mdUnzip) return -1;
|
||||
p->setZipError(unzGetCurrentFileInfo64(p->zip->getUnzFile(), &info_z, nullptr, 0, nullptr, 0, nullptr, 0));
|
||||
if(p->zipError!=UNZ_OK)
|
||||
return -1;
|
||||
return info_z.compressed_size;
|
||||
|
|
@ -444,8 +444,8 @@ qint64 QuaZipFile::usize()const
|
|||
{
|
||||
unz_file_info64 info_z;
|
||||
p->setZipError(UNZ_OK);
|
||||
if(p->zip==NULL||p->zip->getMode()!=QuaZip::mdUnzip) return -1;
|
||||
p->setZipError(unzGetCurrentFileInfo64(p->zip->getUnzFile(), &info_z, NULL, 0, NULL, 0, NULL, 0));
|
||||
if(p->zip==nullptr||p->zip->getMode()!=QuaZip::mdUnzip) return -1;
|
||||
p->setZipError(unzGetCurrentFileInfo64(p->zip->getUnzFile(), &info_z, nullptr, 0, nullptr, 0, nullptr, 0));
|
||||
if(p->zipError!=UNZ_OK)
|
||||
return -1;
|
||||
return info_z.uncompressed_size;
|
||||
|
|
@ -464,7 +464,7 @@ bool QuaZipFile::getFileInfo(QuaZipFileInfo *info)
|
|||
|
||||
bool QuaZipFile::getFileInfo(QuaZipFileInfo64 *info)
|
||||
{
|
||||
if(p->zip==NULL||p->zip->getMode()!=QuaZip::mdUnzip) return false;
|
||||
if(p->zip==nullptr||p->zip->getMode()!=QuaZip::mdUnzip) return false;
|
||||
p->zip->getCurrentFileInfo(info);
|
||||
p->setZipError(p->zip->getZipError());
|
||||
return p->zipError==UNZ_OK;
|
||||
|
|
@ -473,7 +473,7 @@ bool QuaZipFile::getFileInfo(QuaZipFileInfo64 *info)
|
|||
void QuaZipFile::close()
|
||||
{
|
||||
p->resetZipError();
|
||||
if(p->zip==NULL||!p->zip->isOpen()) return;
|
||||
if(p->zip==nullptr||!p->zip->isOpen()) return;
|
||||
if(!isOpen()) {
|
||||
qWarning("QuaZipFile::close(): file isn't open");
|
||||
return;
|
||||
|
|
@ -544,7 +544,7 @@ qint64 QuaZipFile::bytesAvailable() const
|
|||
|
||||
QByteArray QuaZipFile::getLocalExtraField()
|
||||
{
|
||||
int size = unzGetLocalExtrafield(p->zip->getUnzFile(), NULL, 0);
|
||||
int size = unzGetLocalExtrafield(p->zip->getUnzFile(), nullptr, 0);
|
||||
QByteArray extra(size, '\0');
|
||||
int err = unzGetLocalExtrafield(p->zip->getUnzFile(), extra.data(), static_cast<uint>(extra.size()));
|
||||
if (err < 0) {
|
||||
|
|
|
|||
|
|
@ -4,20 +4,20 @@
|
|||
/*
|
||||
Copyright (C) 2005-2014 Sergey A. Tachenov
|
||||
|
||||
This file is part of QuaZIP.
|
||||
This file is part of QuaZip.
|
||||
|
||||
QuaZIP is free software: you can redistribute it and/or modify
|
||||
QuaZip is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QuaZIP is distributed in the hope that it will be useful,
|
||||
QuaZip is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with QuaZip. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
See COPYING file for the full LGPL text.
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ class QuaZipFilePrivate;
|
|||
* interface to the ZIP/UNZIP package, but also integrates it with Qt by
|
||||
* subclassing QIODevice. This makes possible to access files inside ZIP
|
||||
* archive using QTextStream or QDataStream, for example. Actually, this
|
||||
* is the main purpose of the whole QuaZIP library.
|
||||
* is the main purpose of the whole QuaZip library.
|
||||
*
|
||||
* You can either use existing QuaZip instance to create instance of
|
||||
* this class or pass ZIP archive file name to this class, in which case
|
||||
|
|
@ -107,7 +107,7 @@ class QUAZIP_EXPORT QuaZipFile: public QIODevice {
|
|||
* QuaZipFile constructed by this constructor can be used for read
|
||||
* only access. Use QuaZipFile(QuaZip*,QObject*) for writing.
|
||||
**/
|
||||
QuaZipFile(const QString& zipName, QObject *parent =NULL);
|
||||
QuaZipFile(const QString& zipName, QObject *parent =nullptr);
|
||||
/// Constructs a QuaZipFile instance.
|
||||
/** \a parent argument specifies this object's parent object, \a
|
||||
* zipName specifies ZIP archive file name and \a fileName and \a cs
|
||||
|
|
@ -119,7 +119,7 @@ class QUAZIP_EXPORT QuaZipFile: public QIODevice {
|
|||
* \sa QuaZip::setCurrentFile()
|
||||
**/
|
||||
QuaZipFile(const QString& zipName, const QString& fileName,
|
||||
QuaZip::CaseSensitivity cs =QuaZip::csDefault, QObject *parent =NULL);
|
||||
QuaZip::CaseSensitivity cs =QuaZip::csDefault, QObject *parent =nullptr);
|
||||
/// Constructs a QuaZipFile instance.
|
||||
/** \a parent argument specifies this object's parent object.
|
||||
*
|
||||
|
|
@ -169,7 +169,7 @@ class QUAZIP_EXPORT QuaZipFile: public QIODevice {
|
|||
* zip.close();
|
||||
* \endcode
|
||||
**/
|
||||
QuaZipFile(QuaZip *zip, QObject *parent =NULL);
|
||||
QuaZipFile(QuaZip *zip, QObject *parent =nullptr);
|
||||
/// Destroys a QuaZipFile instance.
|
||||
/** Closes file if open, destructs internal QuaZip object (if it
|
||||
* exists and \em is internal, of course).
|
||||
|
|
@ -296,7 +296,7 @@ class QUAZIP_EXPORT QuaZipFile: public QIODevice {
|
|||
* it is NULL then this function behaves just like open(OpenMode).
|
||||
**/
|
||||
inline bool open(OpenMode mode, const char *password)
|
||||
{return open(mode, NULL, NULL, false, password);}
|
||||
{return open(mode, nullptr, nullptr, false, password);}
|
||||
/// Opens a file for reading.
|
||||
/** \overload
|
||||
* Argument \a password specifies a password to decrypt the file.
|
||||
|
|
@ -309,7 +309,7 @@ class QUAZIP_EXPORT QuaZipFile: public QIODevice {
|
|||
* \a method should not be \c NULL. \a level can be \c NULL if you
|
||||
* don't want to know the compression level.
|
||||
**/
|
||||
bool open(OpenMode mode, int *method, int *level, bool raw, const char *password =NULL);
|
||||
bool open(OpenMode mode, int *method, int *level, bool raw, const char *password =nullptr);
|
||||
/// Opens a file for writing.
|
||||
/** \a info argument specifies information about file. It should at
|
||||
* least specify a correct file name. Also, it is a good idea to
|
||||
|
|
@ -339,7 +339,7 @@ class QUAZIP_EXPORT QuaZipFile: public QIODevice {
|
|||
* algorithms tuning. See deflateInit2() in zlib.
|
||||
**/
|
||||
bool open(OpenMode mode, const QuaZipNewInfo& info,
|
||||
const char *password =NULL, quint32 crc =0,
|
||||
const char *password =nullptr, quint32 crc =0,
|
||||
int method =Z_DEFLATED, int level =Z_DEFAULT_COMPRESSION, bool raw =false,
|
||||
int windowBits =-MAX_WBITS, int memLevel =DEF_MEM_LEVEL, int strategy =Z_DEFAULT_STRATEGY);
|
||||
/// Returns \c true, but \ref quazipfile-sequential "beware"!
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
/*
|
||||
Copyright (C) 2005-2014 Sergey A. Tachenov
|
||||
|
||||
This file is part of QuaZIP.
|
||||
This file is part of QuaZip.
|
||||
|
||||
QuaZIP is free software: you can redistribute it and/or modify
|
||||
QuaZip is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QuaZIP is distributed in the hope that it will be useful,
|
||||
QuaZip is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with QuaZip. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
See COPYING file for the full LGPL text.
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ see quazip/(un)zip.h files for details. Basically it's the zlib license.
|
|||
|
||||
static QFile::Permissions permissionsFromExternalAttr(quint32 externalAttr) {
|
||||
quint32 uPerm = (externalAttr & 0xFFFF0000u) >> 16;
|
||||
QFile::Permissions perm = QFile::Permissions();
|
||||
QFile::Permissions perm;
|
||||
if ((uPerm & 0400) != 0)
|
||||
perm |= QFile::ReadOwner;
|
||||
if ((uPerm & 0200) != 0)
|
||||
|
|
@ -115,9 +115,11 @@ static QDateTime getNTFSTime(const QByteArray &extra, int position,
|
|||
timeReader.device()->seek(position);
|
||||
quint64 time;
|
||||
timeReader >> time;
|
||||
if (time == 0)
|
||||
return dateTime;
|
||||
QDateTime base(QDate(1601, 1, 1), QTime(0, 0), Qt::UTC);
|
||||
dateTime = base.addMSecs(time / 10000);
|
||||
if (fineTicks != NULL) {
|
||||
if (fineTicks != nullptr) {
|
||||
*fineTicks = static_cast<int>(time % 10000);
|
||||
}
|
||||
return dateTime;
|
||||
|
|
|
|||
|
|
@ -4,20 +4,20 @@
|
|||
/*
|
||||
Copyright (C) 2005-2014 Sergey A. Tachenov
|
||||
|
||||
This file is part of QuaZIP.
|
||||
This file is part of QuaZip.
|
||||
|
||||
QuaZIP is free software: you can redistribute it and/or modify
|
||||
QuaZip is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QuaZIP is distributed in the hope that it will be useful,
|
||||
QuaZip is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with QuaZip. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
See COPYING file for the full LGPL text.
|
||||
|
||||
|
|
@ -140,7 +140,7 @@ struct QUAZIP_EXPORT QuaZipFileInfo64 {
|
|||
/**
|
||||
* The getNTFS*Time() functions only work if there is an NTFS extra field
|
||||
* present. Otherwise, they all return invalid null timestamps.
|
||||
* @param fineTicks If not NULL, the fractional part of milliseconds returned
|
||||
* @param fineTicks If not null, the fractional part of milliseconds returned
|
||||
* there, measured in 100-nanosecond ticks. Will be set to
|
||||
* zero if there is no NTFS extra field.
|
||||
* @sa dateTime
|
||||
|
|
@ -148,12 +148,12 @@ struct QUAZIP_EXPORT QuaZipFileInfo64 {
|
|||
* @sa getNTFScTime()
|
||||
* @return The NTFS modification time, UTC
|
||||
*/
|
||||
QDateTime getNTFSmTime(int *fineTicks = NULL) const;
|
||||
QDateTime getNTFSmTime(int *fineTicks = nullptr) const;
|
||||
/// Returns the NTFS access time
|
||||
/**
|
||||
* The getNTFS*Time() functions only work if there is an NTFS extra field
|
||||
* present. Otherwise, they all return invalid null timestamps.
|
||||
* @param fineTicks If not NULL, the fractional part of milliseconds returned
|
||||
* @param fineTicks If not null, the fractional part of milliseconds returned
|
||||
* there, measured in 100-nanosecond ticks. Will be set to
|
||||
* zero if there is no NTFS extra field.
|
||||
* @sa dateTime
|
||||
|
|
@ -161,12 +161,12 @@ struct QUAZIP_EXPORT QuaZipFileInfo64 {
|
|||
* @sa getNTFScTime()
|
||||
* @return The NTFS access time, UTC
|
||||
*/
|
||||
QDateTime getNTFSaTime(int *fineTicks = NULL) const;
|
||||
QDateTime getNTFSaTime(int *fineTicks = nullptr) const;
|
||||
/// Returns the NTFS creation time
|
||||
/**
|
||||
* The getNTFS*Time() functions only work if there is an NTFS extra field
|
||||
* present. Otherwise, they all return invalid null timestamps.
|
||||
* @param fineTicks If not NULL, the fractional part of milliseconds returned
|
||||
* @param fineTicks If not null, the fractional part of milliseconds returned
|
||||
* there, measured in 100-nanosecond ticks. Will be set to
|
||||
* zero if there is no NTFS extra field.
|
||||
* @sa dateTime
|
||||
|
|
@ -174,7 +174,7 @@ struct QUAZIP_EXPORT QuaZipFileInfo64 {
|
|||
* @sa getNTFSaTime()
|
||||
* @return The NTFS creation time, UTC
|
||||
*/
|
||||
QDateTime getNTFScTime(int *fineTicks = NULL) const;
|
||||
QDateTime getNTFScTime(int *fineTicks = nullptr) const;
|
||||
/// Returns the extended modification timestamp
|
||||
/**
|
||||
* The getExt*Time() functions only work if there is an extended timestamp
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
/*
|
||||
Copyright (C) 2005-2014 Sergey A. Tachenov
|
||||
|
||||
This file is part of QuaZIP.
|
||||
This file is part of QuaZip.
|
||||
|
||||
QuaZIP is free software: you can redistribute it and/or modify
|
||||
QuaZip is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QuaZIP is distributed in the hope that it will be useful,
|
||||
QuaZip is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with QuaZip. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
See COPYING file for the full LGPL text.
|
||||
|
||||
|
|
@ -25,6 +25,7 @@ see quazip/(un)zip.h files for details. Basically it's the zlib license.
|
|||
#include <QtCore/QFileInfo>
|
||||
|
||||
#include "quazipnewinfo.h"
|
||||
#include "quazip_qt_compat.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -134,11 +135,7 @@ 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
|
||||
setFileNTFScTime(quazip_ctime(fi));
|
||||
}
|
||||
|
||||
static void setNTFSTime(QByteArray &extra, const QDateTime &time, int position,
|
||||
|
|
@ -251,16 +248,7 @@ static void setNTFSTime(QByteArray &extra, const QDateTime &time, int position,
|
|||
extra[timesPos + 2] = static_cast<char>(ntfsTimesLength);
|
||||
extra[timesPos + 3] = static_cast<char>(ntfsTimesLength >> 8);
|
||||
}
|
||||
QDateTime base(QDate(1601, 1, 1), QTime(0, 0), Qt::UTC);
|
||||
#if (QT_VERSION >= 0x040700)
|
||||
quint64 ticks = base.msecsTo(time) * 10000 + fineTicks;
|
||||
#else
|
||||
QDateTime utc = time.toUTC();
|
||||
quint64 ticks = (static_cast<qint64>(base.date().daysTo(utc.date()))
|
||||
* Q_INT64_C(86400000)
|
||||
+ static_cast<qint64>(base.time().msecsTo(utc.time())))
|
||||
* Q_INT64_C(10000) + fineTicks;
|
||||
#endif
|
||||
quint64 ticks = quazip_ntfs_ticks(time, fineTicks);
|
||||
extra[timesPos + 4 + position] = static_cast<char>(ticks);
|
||||
extra[timesPos + 5 + position] = static_cast<char>(ticks >> 8);
|
||||
extra[timesPos + 6 + position] = static_cast<char>(ticks >> 16);
|
||||
|
|
|
|||
|
|
@ -4,20 +4,20 @@
|
|||
/*
|
||||
Copyright (C) 2005-2014 Sergey A. Tachenov
|
||||
|
||||
This file is part of QuaZIP.
|
||||
This file is part of QuaZip.
|
||||
|
||||
QuaZIP is free software: you can redistribute it and/or modify
|
||||
QuaZip is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QuaZIP is distributed in the hope that it will be useful,
|
||||
QuaZip is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with QuaZip. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
See COPYING file for the full LGPL text.
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
Modifications for Zip64 support on both zip and unzip
|
||||
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
|
||||
|
||||
Modifications for QIODevice support and other QuaZIP fixes
|
||||
Modifications for QIODevice support and other QuaZip fixes
|
||||
Copyright (C) 2005-2014 Sergey A. Tachenov
|
||||
|
||||
For more info read MiniZip_info.txt
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ extern unzFile ZEXPORT unzOpen2_64 OF((voidpf file,
|
|||
|
||||
|
||||
/*
|
||||
* Exported by Sergey A. Tachenov to implement some QuaZIP features. This
|
||||
* Exported by Sergey A. Tachenov to implement some QuaZip features. This
|
||||
* function MAY change signature in order to implement even more features.
|
||||
* You have been warned!
|
||||
* */
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
For more info read MiniZip_info.txt
|
||||
|
||||
Modifications for QIODevice support and other QuaZIP fixes
|
||||
Modifications for QIODevice support and other QuaZip fixes
|
||||
Copyright (C) 2005-2014 Sergey A. Tachenov
|
||||
|
||||
Fixing static code analysis issues
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ extern zipFile ZEXPORT zipOpen OF((voidpf file, int append));
|
|||
extern zipFile ZEXPORT zipOpen64 OF((voidpf file, int append));
|
||||
/*
|
||||
Create a zipfile.
|
||||
the file argument depends on the API used, for QuaZIP it's a QIODevice
|
||||
the file argument depends on the API used, for QuaZip it's a QIODevice
|
||||
pointer.
|
||||
if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip
|
||||
will be created at the end of the file.
|
||||
|
|
@ -157,9 +157,9 @@ extern zipFile ZEXPORT zipOpen2_64 OF((voidpf file,
|
|||
zlib_filefunc64_def* pzlib_filefunc_def));
|
||||
|
||||
/*
|
||||
* Exported by Sergey A. Tachenov to suit the needs of QuaZIP.
|
||||
* Exported by Sergey A. Tachenov to suit the needs of QuaZip.
|
||||
* Note that this function MAY change signature in order to
|
||||
* provide new QuaZIP features. You have been warned!
|
||||
* provide new QuaZip features. You have been warned!
|
||||
* */
|
||||
extern zipFile ZEXPORT zipOpen3 (voidpf file,
|
||||
int append,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue