remove all dos line endings (#3489)
This commit is contained in:
parent
2621cc09ac
commit
84f6da103f
11 changed files with 4046 additions and 4046 deletions
|
@ -1,36 +1,36 @@
|
||||||
# Find the MS Visual Studio VC redistributable package
|
# Find the MS Visual Studio VC redistributable package
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set(VCREDISTRUNTIME_FOUND "NO")
|
set(VCREDISTRUNTIME_FOUND "NO")
|
||||||
|
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64-bit
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8) # 64-bit
|
||||||
set(REDIST_ARCH x64)
|
set(REDIST_ARCH x64)
|
||||||
else()
|
else()
|
||||||
set(REDIST_ARCH x86)
|
set(REDIST_ARCH x86)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(REDIST_FILE vcredist_${REDIST_ARCH}.exe)
|
set(REDIST_FILE vcredist_${REDIST_ARCH}.exe)
|
||||||
|
|
||||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
|
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
|
||||||
include(InstallRequiredSystemLibraries)
|
include(InstallRequiredSystemLibraries)
|
||||||
|
|
||||||
# Check if the list contains minimum one element, to get the path from
|
# Check if the list contains minimum one element, to get the path from
|
||||||
list(LENGTH CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS libsCount)
|
list(LENGTH CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS libsCount)
|
||||||
if (libsCount GREATER 0)
|
if (libsCount GREATER 0)
|
||||||
list(GET CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS 0 _path)
|
list(GET CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS 0 _path)
|
||||||
|
|
||||||
get_filename_component(_path ${_path} DIRECTORY)
|
get_filename_component(_path ${_path} DIRECTORY)
|
||||||
get_filename_component(_path ${_path}/../../ ABSOLUTE)
|
get_filename_component(_path ${_path}/../../ ABSOLUTE)
|
||||||
|
|
||||||
if (EXISTS "${_path}/${REDIST_FILE}") # VS 2017
|
if (EXISTS "${_path}/${REDIST_FILE}") # VS 2017
|
||||||
set(VCREDISTRUNTIME_FOUND "YES")
|
set(VCREDISTRUNTIME_FOUND "YES")
|
||||||
set(VCREDISTRUNTIME_FILE ${_path}/${REDIST_FILE})
|
set(VCREDISTRUNTIME_FILE ${_path}/${REDIST_FILE})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(VCREDISTRUNTIME_FOUND)
|
if(VCREDISTRUNTIME_FOUND)
|
||||||
message(STATUS "Found VCredist ${VCREDISTRUNTIME_FILE}")
|
message(STATUS "Found VCredist ${VCREDISTRUNTIME_FILE}")
|
||||||
else()
|
else()
|
||||||
message(WARNING "Could not find VCredist package. It's not required for compiling, but needs to be available at runtime.")
|
message(WARNING "Could not find VCredist package. It's not required for compiling, but needs to be available at runtime.")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1,71 +1,71 @@
|
||||||
# Find the OpenSSL runtime libraries (.dll) for Windows that
|
# Find the OpenSSL runtime libraries (.dll) for Windows that
|
||||||
# will be needed by Qt in order to access https urls.
|
# will be needed by Qt in order to access https urls.
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
# Get standard installation paths for OpenSSL under Windows
|
# Get standard installation paths for OpenSSL under Windows
|
||||||
|
|
||||||
# http://www.slproweb.com/products/Win32OpenSSL.html
|
# http://www.slproweb.com/products/Win32OpenSSL.html
|
||||||
|
|
||||||
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
||||||
# target win64
|
# target win64
|
||||||
set(_OPENSSL_ROOT_HINTS
|
set(_OPENSSL_ROOT_HINTS
|
||||||
${OPENSSL_ROOT_DIR}
|
${OPENSSL_ROOT_DIR}
|
||||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
|
||||||
ENV OPENSSL_ROOT_DIR
|
ENV OPENSSL_ROOT_DIR
|
||||||
)
|
)
|
||||||
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
|
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
|
||||||
set(_OPENSSL_ROOT_PATHS
|
set(_OPENSSL_ROOT_PATHS
|
||||||
"C:/Tools/vcpkg/installed/x64-windows/bin"
|
"C:/Tools/vcpkg/installed/x64-windows/bin"
|
||||||
"${_programfiles}/OpenSSL-Win64"
|
"${_programfiles}/OpenSSL-Win64"
|
||||||
"C:/OpenSSL-Win64/"
|
"C:/OpenSSL-Win64/"
|
||||||
)
|
)
|
||||||
unset(_programfiles)
|
unset(_programfiles)
|
||||||
else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
||||||
# target win32
|
# target win32
|
||||||
set(_OPENSSL_ROOT_HINTS
|
set(_OPENSSL_ROOT_HINTS
|
||||||
${OPENSSL_ROOT_DIR}
|
${OPENSSL_ROOT_DIR}
|
||||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
|
||||||
ENV OPENSSL_ROOT_DIR
|
ENV OPENSSL_ROOT_DIR
|
||||||
)
|
)
|
||||||
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
|
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
|
||||||
set(_OPENSSL_ROOT_PATHS
|
set(_OPENSSL_ROOT_PATHS
|
||||||
"C:/Tools/vcpkg/installed/x86-windows/bin"
|
"C:/Tools/vcpkg/installed/x86-windows/bin"
|
||||||
"${_programfiles}/OpenSSL"
|
"${_programfiles}/OpenSSL"
|
||||||
"${_programfiles}/OpenSSL-Win32"
|
"${_programfiles}/OpenSSL-Win32"
|
||||||
"C:/OpenSSL/"
|
"C:/OpenSSL/"
|
||||||
"C:/OpenSSL-Win32/"
|
"C:/OpenSSL-Win32/"
|
||||||
)
|
)
|
||||||
unset(_programfiles)
|
unset(_programfiles)
|
||||||
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
|
||||||
|
|
||||||
else ()
|
else ()
|
||||||
set(_OPENSSL_ROOT_HINTS
|
set(_OPENSSL_ROOT_HINTS
|
||||||
${OPENSSL_ROOT_DIR}
|
${OPENSSL_ROOT_DIR}
|
||||||
ENV OPENSSL_ROOT_DIR
|
ENV OPENSSL_ROOT_DIR
|
||||||
)
|
)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(_OPENSSL_ROOT_HINTS_AND_PATHS
|
set(_OPENSSL_ROOT_HINTS_AND_PATHS
|
||||||
HINTS ${_OPENSSL_ROOT_HINTS}
|
HINTS ${_OPENSSL_ROOT_HINTS}
|
||||||
PATHS ${_OPENSSL_ROOT_PATHS}
|
PATHS ${_OPENSSL_ROOT_PATHS}
|
||||||
)
|
)
|
||||||
|
|
||||||
# For OpenSSL < 1.1, they are named libeay32 and ssleay32 and even if the dll is 64bit, it's still suffixed as *32.dll
|
# For OpenSSL < 1.1, they are named libeay32 and ssleay32 and even if the dll is 64bit, it's still suffixed as *32.dll
|
||||||
# For OpenSSL >= 1.1, they are named libcrypto and libssl with no suffix
|
# For OpenSSL >= 1.1, they are named libcrypto and libssl with no suffix
|
||||||
FIND_FILE(WIN32SSLRUNTIME_LIBEAY NAMES libeay32.dll libcrypto.dll ${_OPENSSL_ROOT_HINTS_AND_PATHS})
|
FIND_FILE(WIN32SSLRUNTIME_LIBEAY NAMES libeay32.dll libcrypto.dll ${_OPENSSL_ROOT_HINTS_AND_PATHS})
|
||||||
FIND_FILE(WIN32SSLRUNTIME_SSLEAY NAMES ssleay32.dll libssl.dll ${_OPENSSL_ROOT_HINTS_AND_PATHS})
|
FIND_FILE(WIN32SSLRUNTIME_SSLEAY NAMES ssleay32.dll libssl.dll ${_OPENSSL_ROOT_HINTS_AND_PATHS})
|
||||||
|
|
||||||
|
|
||||||
IF(WIN32SSLRUNTIME_LIBEAY AND WIN32SSLRUNTIME_SSLEAY)
|
IF(WIN32SSLRUNTIME_LIBEAY AND WIN32SSLRUNTIME_SSLEAY)
|
||||||
SET(WIN32SSLRUNTIME_LIBRARIES "${WIN32SSLRUNTIME_LIBEAY}" "${WIN32SSLRUNTIME_SSLEAY}")
|
SET(WIN32SSLRUNTIME_LIBRARIES "${WIN32SSLRUNTIME_LIBEAY}" "${WIN32SSLRUNTIME_SSLEAY}")
|
||||||
SET(WIN32SSLRUNTIME_FOUND "YES")
|
SET(WIN32SSLRUNTIME_FOUND "YES")
|
||||||
message(STATUS "Found OpenSSL ${WIN32SSLRUNTIME_LIBRARIES}")
|
message(STATUS "Found OpenSSL ${WIN32SSLRUNTIME_LIBRARIES}")
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(WIN32SSLRUNTIME_FOUND "NO")
|
SET(WIN32SSLRUNTIME_FOUND "NO")
|
||||||
message(WARNING "Could not find OpenSSL runtime libraries. They are not required for compiling, but needs to be available at runtime.")
|
message(WARNING "Could not find OpenSSL runtime libraries. They are not required for compiling, but needs to be available at runtime.")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
MARK_AS_ADVANCED(
|
MARK_AS_ADVANCED(
|
||||||
WIN32SSLRUNTIME_LIBEAY
|
WIN32SSLRUNTIME_LIBEAY
|
||||||
WIN32SSLRUNTIME_SSLEAY
|
WIN32SSLRUNTIME_SSLEAY
|
||||||
)
|
)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,152 +1,152 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
** Filename: unzip.h
|
** Filename: unzip.h
|
||||||
** Last updated [dd/mm/yyyy]: 27/03/2011
|
** Last updated [dd/mm/yyyy]: 27/03/2011
|
||||||
**
|
**
|
||||||
** pkzip 2.0 decompression.
|
** pkzip 2.0 decompression.
|
||||||
**
|
**
|
||||||
** Some of the code has been inspired by other open source projects,
|
** Some of the code has been inspired by other open source projects,
|
||||||
** (mainly Info-Zip and Gilles Vollant's minizip).
|
** (mainly Info-Zip and Gilles Vollant's minizip).
|
||||||
** Compression and decompression actually uses the zlib library.
|
** Compression and decompression actually uses the zlib library.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
||||||
**
|
**
|
||||||
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
||||||
**
|
**
|
||||||
** This file may be distributed and/or modified under the terms of the
|
** This file may be distributed and/or modified under the terms of the
|
||||||
** GNU General Public License version 2 as published by the Free Software
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
** packaging of this file.
|
** packaging of this file.
|
||||||
**
|
**
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
**
|
**
|
||||||
** See the file LICENSE.GPL that came with this software distribution or
|
** See the file LICENSE.GPL that came with this software distribution or
|
||||||
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
||||||
**
|
**
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
#ifndef OSDAB_UNZIP__H
|
#ifndef OSDAB_UNZIP__H
|
||||||
#define OSDAB_UNZIP__H
|
#define OSDAB_UNZIP__H
|
||||||
|
|
||||||
#include "zipglobal.h"
|
#include "zipglobal.h"
|
||||||
|
|
||||||
#include <QtCore/QDateTime>
|
#include <QtCore/QDateTime>
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
class QDir;
|
class QDir;
|
||||||
class QFile;
|
class QFile;
|
||||||
class QIODevice;
|
class QIODevice;
|
||||||
class QString;
|
class QString;
|
||||||
class QStringList;
|
class QStringList;
|
||||||
|
|
||||||
OSDAB_BEGIN_NAMESPACE(Zip)
|
OSDAB_BEGIN_NAMESPACE(Zip)
|
||||||
|
|
||||||
class UnzipPrivate;
|
class UnzipPrivate;
|
||||||
|
|
||||||
class OSDAB_ZIP_EXPORT UnZip
|
class OSDAB_ZIP_EXPORT UnZip
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ErrorCode
|
enum ErrorCode
|
||||||
{
|
{
|
||||||
Ok,
|
Ok,
|
||||||
ZlibInit,
|
ZlibInit,
|
||||||
ZlibError,
|
ZlibError,
|
||||||
OpenFailed,
|
OpenFailed,
|
||||||
PartiallyCorrupted,
|
PartiallyCorrupted,
|
||||||
Corrupted,
|
Corrupted,
|
||||||
WrongPassword,
|
WrongPassword,
|
||||||
NoOpenArchive,
|
NoOpenArchive,
|
||||||
FileNotFound,
|
FileNotFound,
|
||||||
ReadFailed,
|
ReadFailed,
|
||||||
WriteFailed,
|
WriteFailed,
|
||||||
SeekFailed,
|
SeekFailed,
|
||||||
CreateDirFailed,
|
CreateDirFailed,
|
||||||
InvalidDevice,
|
InvalidDevice,
|
||||||
InvalidArchive,
|
InvalidArchive,
|
||||||
HeaderConsistencyError,
|
HeaderConsistencyError,
|
||||||
|
|
||||||
Skip, SkipAll // internal use only
|
Skip, SkipAll // internal use only
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ExtractionOption
|
enum ExtractionOption
|
||||||
{
|
{
|
||||||
ExtractPaths = 0x0001,
|
ExtractPaths = 0x0001,
|
||||||
SkipPaths = 0x0002,
|
SkipPaths = 0x0002,
|
||||||
VerifyOnly = 0x0004,
|
VerifyOnly = 0x0004,
|
||||||
NoSilentDirectoryCreation = 0x0008
|
NoSilentDirectoryCreation = 0x0008
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(ExtractionOptions, ExtractionOption)
|
Q_DECLARE_FLAGS(ExtractionOptions, ExtractionOption)
|
||||||
|
|
||||||
enum CompressionMethod
|
enum CompressionMethod
|
||||||
{
|
{
|
||||||
NoCompression, Deflated, UnknownCompression
|
NoCompression, Deflated, UnknownCompression
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FileType
|
enum FileType
|
||||||
{
|
{
|
||||||
File, Directory
|
File, Directory
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ZipEntry
|
struct ZipEntry
|
||||||
{
|
{
|
||||||
ZipEntry();
|
ZipEntry();
|
||||||
|
|
||||||
QString filename;
|
QString filename;
|
||||||
QString comment;
|
QString comment;
|
||||||
|
|
||||||
quint32 compressedSize;
|
quint32 compressedSize;
|
||||||
quint32 uncompressedSize;
|
quint32 uncompressedSize;
|
||||||
quint32 crc32;
|
quint32 crc32;
|
||||||
|
|
||||||
QDateTime lastModified;
|
QDateTime lastModified;
|
||||||
|
|
||||||
CompressionMethod compression;
|
CompressionMethod compression;
|
||||||
FileType type;
|
FileType type;
|
||||||
|
|
||||||
bool encrypted;
|
bool encrypted;
|
||||||
};
|
};
|
||||||
|
|
||||||
UnZip();
|
UnZip();
|
||||||
virtual ~UnZip();
|
virtual ~UnZip();
|
||||||
|
|
||||||
bool isOpen() const;
|
bool isOpen() const;
|
||||||
|
|
||||||
ErrorCode openArchive(const QString& filename);
|
ErrorCode openArchive(const QString& filename);
|
||||||
ErrorCode openArchive(QIODevice* device);
|
ErrorCode openArchive(QIODevice* device);
|
||||||
void closeArchive();
|
void closeArchive();
|
||||||
|
|
||||||
QString archiveComment() const;
|
QString archiveComment() const;
|
||||||
|
|
||||||
QString formatError(UnZip::ErrorCode c) const;
|
QString formatError(UnZip::ErrorCode c) const;
|
||||||
|
|
||||||
bool contains(const QString& file) const;
|
bool contains(const QString& file) const;
|
||||||
|
|
||||||
QStringList fileList() const;
|
QStringList fileList() const;
|
||||||
QList<ZipEntry> entryList() const;
|
QList<ZipEntry> entryList() const;
|
||||||
|
|
||||||
ErrorCode verifyArchive();
|
ErrorCode verifyArchive();
|
||||||
|
|
||||||
ErrorCode extractAll(const QString& dirname, ExtractionOptions options = ExtractPaths);
|
ErrorCode extractAll(const QString& dirname, ExtractionOptions options = ExtractPaths);
|
||||||
ErrorCode extractAll(const QDir& dir, ExtractionOptions options = ExtractPaths);
|
ErrorCode extractAll(const QDir& dir, ExtractionOptions options = ExtractPaths);
|
||||||
|
|
||||||
ErrorCode extractFile(const QString& filename, const QString& dirname, ExtractionOptions options = ExtractPaths);
|
ErrorCode extractFile(const QString& filename, const QString& dirname, ExtractionOptions options = ExtractPaths);
|
||||||
ErrorCode extractFile(const QString& filename, const QDir& dir, ExtractionOptions options = ExtractPaths);
|
ErrorCode extractFile(const QString& filename, const QDir& dir, ExtractionOptions options = ExtractPaths);
|
||||||
ErrorCode extractFile(const QString& filename, QIODevice* device, ExtractionOptions options = ExtractPaths);
|
ErrorCode extractFile(const QString& filename, QIODevice* device, ExtractionOptions options = ExtractPaths);
|
||||||
|
|
||||||
ErrorCode extractFiles(const QStringList& filenames, const QString& dirname, ExtractionOptions options = ExtractPaths);
|
ErrorCode extractFiles(const QStringList& filenames, const QString& dirname, ExtractionOptions options = ExtractPaths);
|
||||||
ErrorCode extractFiles(const QStringList& filenames, const QDir& dir, ExtractionOptions options = ExtractPaths);
|
ErrorCode extractFiles(const QStringList& filenames, const QDir& dir, ExtractionOptions options = ExtractPaths);
|
||||||
|
|
||||||
void setPassword(const QString& pwd);
|
void setPassword(const QString& pwd);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UnzipPrivate* d;
|
UnzipPrivate* d;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(UnZip::ExtractionOptions)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(UnZip::ExtractionOptions)
|
||||||
|
|
||||||
OSDAB_END_NAMESPACE
|
OSDAB_END_NAMESPACE
|
||||||
|
|
||||||
#endif // OSDAB_UNZIP__H
|
#endif // OSDAB_UNZIP__H
|
||||||
|
|
|
@ -1,130 +1,130 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
** Filename: unzip_p.h
|
** Filename: unzip_p.h
|
||||||
** Last updated [dd/mm/yyyy]: 27/03/2011
|
** Last updated [dd/mm/yyyy]: 27/03/2011
|
||||||
**
|
**
|
||||||
** pkzip 2.0 decompression.
|
** pkzip 2.0 decompression.
|
||||||
**
|
**
|
||||||
** Some of the code has been inspired by other open source projects,
|
** Some of the code has been inspired by other open source projects,
|
||||||
** (mainly Info-Zip and Gilles Vollant's minizip).
|
** (mainly Info-Zip and Gilles Vollant's minizip).
|
||||||
** Compression and decompression actually uses the zlib library.
|
** Compression and decompression actually uses the zlib library.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
||||||
**
|
**
|
||||||
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
||||||
**
|
**
|
||||||
** This file may be distributed and/or modified under the terms of the
|
** This file may be distributed and/or modified under the terms of the
|
||||||
** GNU General Public License version 2 as published by the Free Software
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
** packaging of this file.
|
** packaging of this file.
|
||||||
**
|
**
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
**
|
**
|
||||||
** See the file LICENSE.GPL that came with this software distribution or
|
** See the file LICENSE.GPL that came with this software distribution or
|
||||||
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
||||||
**
|
**
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
//
|
//
|
||||||
// W A R N I N G
|
// W A R N I N G
|
||||||
// -------------
|
// -------------
|
||||||
//
|
//
|
||||||
// This file is not part of the Zip/UnZip API. It exists purely as an
|
// This file is not part of the Zip/UnZip API. It exists purely as an
|
||||||
// implementation detail. This header file may change from version to
|
// implementation detail. This header file may change from version to
|
||||||
// version without notice, or even be removed.
|
// version without notice, or even be removed.
|
||||||
//
|
//
|
||||||
// We mean it.
|
// We mean it.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef OSDAB_UNZIP_P__H
|
#ifndef OSDAB_UNZIP_P__H
|
||||||
#define OSDAB_UNZIP_P__H
|
#define OSDAB_UNZIP_P__H
|
||||||
|
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
#include "zipentry_p.h"
|
#include "zipentry_p.h"
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
// zLib authors suggest using larger buffers (128K or 256K) for (de)compression (especially for inflate())
|
// zLib authors suggest using larger buffers (128K or 256K) for (de)compression (especially for inflate())
|
||||||
// we use a 256K buffer here - if you want to use this code on a pre-iceage mainframe please change it ;)
|
// we use a 256K buffer here - if you want to use this code on a pre-iceage mainframe please change it ;)
|
||||||
#define UNZIP_READ_BUFFER (256*1024)
|
#define UNZIP_READ_BUFFER (256*1024)
|
||||||
|
|
||||||
OSDAB_BEGIN_NAMESPACE(Zip)
|
OSDAB_BEGIN_NAMESPACE(Zip)
|
||||||
|
|
||||||
class UnzipPrivate : public QObject
|
class UnzipPrivate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UnzipPrivate();
|
UnzipPrivate();
|
||||||
|
|
||||||
// Replace this with whatever else you use to store/retrieve the password.
|
// Replace this with whatever else you use to store/retrieve the password.
|
||||||
QString password;
|
QString password;
|
||||||
|
|
||||||
bool skipAllEncrypted;
|
bool skipAllEncrypted;
|
||||||
|
|
||||||
QMap<QString,ZipEntryP*>* headers;
|
QMap<QString,ZipEntryP*>* headers;
|
||||||
|
|
||||||
QIODevice* device;
|
QIODevice* device;
|
||||||
QFile* file;
|
QFile* file;
|
||||||
|
|
||||||
char buffer1[UNZIP_READ_BUFFER];
|
char buffer1[UNZIP_READ_BUFFER];
|
||||||
char buffer2[UNZIP_READ_BUFFER];
|
char buffer2[UNZIP_READ_BUFFER];
|
||||||
|
|
||||||
unsigned char* uBuffer;
|
unsigned char* uBuffer;
|
||||||
const quint32* crcTable;
|
const quint32* crcTable;
|
||||||
|
|
||||||
// Central Directory (CD) offset
|
// Central Directory (CD) offset
|
||||||
quint32 cdOffset;
|
quint32 cdOffset;
|
||||||
// End of Central Directory (EOCD) offset
|
// End of Central Directory (EOCD) offset
|
||||||
quint32 eocdOffset;
|
quint32 eocdOffset;
|
||||||
|
|
||||||
// Number of entries in the Central Directory (as to the EOCD record)
|
// Number of entries in the Central Directory (as to the EOCD record)
|
||||||
quint16 cdEntryCount;
|
quint16 cdEntryCount;
|
||||||
|
|
||||||
// The number of detected entries that have been skipped because of a non compatible format
|
// The number of detected entries that have been skipped because of a non compatible format
|
||||||
quint16 unsupportedEntryCount;
|
quint16 unsupportedEntryCount;
|
||||||
|
|
||||||
QString comment;
|
QString comment;
|
||||||
|
|
||||||
UnZip::ErrorCode openArchive(QIODevice* device);
|
UnZip::ErrorCode openArchive(QIODevice* device);
|
||||||
|
|
||||||
UnZip::ErrorCode seekToCentralDirectory();
|
UnZip::ErrorCode seekToCentralDirectory();
|
||||||
UnZip::ErrorCode parseCentralDirectoryRecord();
|
UnZip::ErrorCode parseCentralDirectoryRecord();
|
||||||
UnZip::ErrorCode parseLocalHeaderRecord(const QString& path, const ZipEntryP& entry);
|
UnZip::ErrorCode parseLocalHeaderRecord(const QString& path, const ZipEntryP& entry);
|
||||||
|
|
||||||
void closeArchive();
|
void closeArchive();
|
||||||
|
|
||||||
UnZip::ErrorCode extractFile(const QString& path, const ZipEntryP& entry, const QDir& dir, UnZip::ExtractionOptions options);
|
UnZip::ErrorCode extractFile(const QString& path, const ZipEntryP& entry, const QDir& dir, UnZip::ExtractionOptions options);
|
||||||
UnZip::ErrorCode extractFile(const QString& path, const ZipEntryP& entry, QIODevice* device, UnZip::ExtractionOptions options);
|
UnZip::ErrorCode extractFile(const QString& path, const ZipEntryP& entry, QIODevice* device, UnZip::ExtractionOptions options);
|
||||||
|
|
||||||
UnZip::ErrorCode testPassword(quint32* keys, const QString& file, const ZipEntryP& header);
|
UnZip::ErrorCode testPassword(quint32* keys, const QString& file, const ZipEntryP& header);
|
||||||
bool testKeys(const ZipEntryP& header, quint32* keys);
|
bool testKeys(const ZipEntryP& header, quint32* keys);
|
||||||
|
|
||||||
bool createDirectory(const QString& path);
|
bool createDirectory(const QString& path);
|
||||||
|
|
||||||
inline void decryptBytes(quint32* keys, char* buffer, qint64 read);
|
inline void decryptBytes(quint32* keys, char* buffer, qint64 read);
|
||||||
|
|
||||||
inline quint32 getULong(const unsigned char* data, quint32 offset) const;
|
inline quint32 getULong(const unsigned char* data, quint32 offset) const;
|
||||||
inline quint64 getULLong(const unsigned char* data, quint32 offset) const;
|
inline quint64 getULLong(const unsigned char* data, quint32 offset) const;
|
||||||
inline quint16 getUShort(const unsigned char* data, quint32 offset) const;
|
inline quint16 getUShort(const unsigned char* data, quint32 offset) const;
|
||||||
inline int decryptByte(quint32 key2) const;
|
inline int decryptByte(quint32 key2) const;
|
||||||
inline void updateKeys(quint32* keys, int c) const;
|
inline void updateKeys(quint32* keys, int c) const;
|
||||||
inline void initKeys(const QString& pwd, quint32* keys) const;
|
inline void initKeys(const QString& pwd, quint32* keys) const;
|
||||||
|
|
||||||
inline QDateTime convertDateTime(const unsigned char date[2], const unsigned char time[2]) const;
|
inline QDateTime convertDateTime(const unsigned char date[2], const unsigned char time[2]) const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void deviceDestroyed(QObject*);
|
void deviceDestroyed(QObject*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UnZip::ErrorCode extractStoredFile(const quint32 szComp, quint32** keys,
|
UnZip::ErrorCode extractStoredFile(const quint32 szComp, quint32** keys,
|
||||||
quint32& myCRC, QIODevice* outDev, UnZip::ExtractionOptions options);
|
quint32& myCRC, QIODevice* outDev, UnZip::ExtractionOptions options);
|
||||||
UnZip::ErrorCode inflateFile(const quint32 szComp, quint32** keys,
|
UnZip::ErrorCode inflateFile(const quint32 szComp, quint32** keys,
|
||||||
quint32& myCRC, QIODevice* outDev, UnZip::ExtractionOptions options);
|
quint32& myCRC, QIODevice* outDev, UnZip::ExtractionOptions options);
|
||||||
void do_closeArchive();
|
void do_closeArchive();
|
||||||
};
|
};
|
||||||
|
|
||||||
OSDAB_END_NAMESPACE
|
OSDAB_END_NAMESPACE
|
||||||
|
|
||||||
#endif // OSDAB_UNZIP_P__H
|
#endif // OSDAB_UNZIP_P__H
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,158 +1,158 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
** Filename: zip.h
|
** Filename: zip.h
|
||||||
** Last updated [dd/mm/yyyy]: 27/03/2011
|
** Last updated [dd/mm/yyyy]: 27/03/2011
|
||||||
**
|
**
|
||||||
** pkzip 2.0 file compression.
|
** pkzip 2.0 file compression.
|
||||||
**
|
**
|
||||||
** Some of the code has been inspired by other open source projects,
|
** Some of the code has been inspired by other open source projects,
|
||||||
** (mainly Info-Zip and Gilles Vollant's minizip).
|
** (mainly Info-Zip and Gilles Vollant's minizip).
|
||||||
** Compression and decompression actually uses the zlib library.
|
** Compression and decompression actually uses the zlib library.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
||||||
**
|
**
|
||||||
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
||||||
**
|
**
|
||||||
** This file may be distributed and/or modified under the terms of the
|
** This file may be distributed and/or modified under the terms of the
|
||||||
** GNU General Public License version 2 as published by the Free Software
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
** packaging of this file.
|
** packaging of this file.
|
||||||
**
|
**
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
**
|
**
|
||||||
** See the file LICENSE.GPL that came with this software distribution or
|
** See the file LICENSE.GPL that came with this software distribution or
|
||||||
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
||||||
**
|
**
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
#ifndef OSDAB_ZIP__H
|
#ifndef OSDAB_ZIP__H
|
||||||
#define OSDAB_ZIP__H
|
#define OSDAB_ZIP__H
|
||||||
|
|
||||||
#include "zipglobal.h"
|
#include "zipglobal.h"
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
#include <zlib/zlib.h>
|
#include <zlib/zlib.h>
|
||||||
|
|
||||||
class QIODevice;
|
class QIODevice;
|
||||||
class QFile;
|
class QFile;
|
||||||
class QDir;
|
class QDir;
|
||||||
class QStringList;
|
class QStringList;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
OSDAB_BEGIN_NAMESPACE(Zip)
|
OSDAB_BEGIN_NAMESPACE(Zip)
|
||||||
|
|
||||||
class ZipPrivate;
|
class ZipPrivate;
|
||||||
|
|
||||||
class OSDAB_ZIP_EXPORT Zip
|
class OSDAB_ZIP_EXPORT Zip
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum ErrorCode
|
enum ErrorCode
|
||||||
{
|
{
|
||||||
Ok,
|
Ok,
|
||||||
ZlibInit,
|
ZlibInit,
|
||||||
ZlibError,
|
ZlibError,
|
||||||
FileExists,
|
FileExists,
|
||||||
OpenFailed,
|
OpenFailed,
|
||||||
NoOpenArchive,
|
NoOpenArchive,
|
||||||
FileNotFound,
|
FileNotFound,
|
||||||
ReadFailed,
|
ReadFailed,
|
||||||
WriteFailed,
|
WriteFailed,
|
||||||
SeekFailed,
|
SeekFailed,
|
||||||
InternalError
|
InternalError
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CompressionLevel
|
enum CompressionLevel
|
||||||
{
|
{
|
||||||
Store,
|
Store,
|
||||||
Deflate1 = 1, Deflate2, Deflate3, Deflate4,
|
Deflate1 = 1, Deflate2, Deflate3, Deflate4,
|
||||||
Deflate5, Deflate6, Deflate7, Deflate8, Deflate9,
|
Deflate5, Deflate6, Deflate7, Deflate8, Deflate9,
|
||||||
AutoCPU, AutoMIME, AutoFull
|
AutoCPU, AutoMIME, AutoFull
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CompressionOption
|
enum CompressionOption
|
||||||
{
|
{
|
||||||
/*! Does not preserve absolute paths in the zip file when adding a
|
/*! Does not preserve absolute paths in the zip file when adding a
|
||||||
file or directory (default) */
|
file or directory (default) */
|
||||||
RelativePaths = 0x0001,
|
RelativePaths = 0x0001,
|
||||||
/*! Preserve absolute paths */
|
/*! Preserve absolute paths */
|
||||||
AbsolutePaths = 0x0002,
|
AbsolutePaths = 0x0002,
|
||||||
/*! Do not store paths. All the files are put in the (evtl. user defined)
|
/*! Do not store paths. All the files are put in the (evtl. user defined)
|
||||||
root of the zip file */
|
root of the zip file */
|
||||||
IgnorePaths = 0x0004,
|
IgnorePaths = 0x0004,
|
||||||
/*! Works only with addDirectory(). Adds the directory's contents,
|
/*! Works only with addDirectory(). Adds the directory's contents,
|
||||||
including subdirectories, but does not add an entry for the root
|
including subdirectories, but does not add an entry for the root
|
||||||
directory itself. */
|
directory itself. */
|
||||||
IgnoreRoot = 0x0008,
|
IgnoreRoot = 0x0008,
|
||||||
/*! Used only when compressing a directory or multiple files.
|
/*! Used only when compressing a directory or multiple files.
|
||||||
If set invalid or unreadable files are simply skipped.
|
If set invalid or unreadable files are simply skipped.
|
||||||
*/
|
*/
|
||||||
SkipBadFiles = 0x0020,
|
SkipBadFiles = 0x0020,
|
||||||
/*! Makes sure a file is never added twice to the same zip archive.
|
/*! Makes sure a file is never added twice to the same zip archive.
|
||||||
This check is only necessary in certain usage scenarios and given
|
This check is only necessary in certain usage scenarios and given
|
||||||
that it slows down processing you need to enable it explicitly with
|
that it slows down processing you need to enable it explicitly with
|
||||||
this flag.
|
this flag.
|
||||||
*/
|
*/
|
||||||
CheckForDuplicates = 0x0040
|
CheckForDuplicates = 0x0040
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(CompressionOptions, CompressionOption)
|
Q_DECLARE_FLAGS(CompressionOptions, CompressionOption)
|
||||||
|
|
||||||
Zip();
|
Zip();
|
||||||
virtual ~Zip();
|
virtual ~Zip();
|
||||||
|
|
||||||
bool isOpen() const;
|
bool isOpen() const;
|
||||||
|
|
||||||
void setPassword(const QString& pwd);
|
void setPassword(const QString& pwd);
|
||||||
void clearPassword();
|
void clearPassword();
|
||||||
QString password() const;
|
QString password() const;
|
||||||
|
|
||||||
ErrorCode createArchive(const QString& file, bool overwrite = true);
|
ErrorCode createArchive(const QString& file, bool overwrite = true);
|
||||||
ErrorCode createArchive(QIODevice* device);
|
ErrorCode createArchive(QIODevice* device);
|
||||||
|
|
||||||
QString archiveComment() const;
|
QString archiveComment() const;
|
||||||
void setArchiveComment(const QString& comment);
|
void setArchiveComment(const QString& comment);
|
||||||
|
|
||||||
ErrorCode addDirectoryContents(const QString& path,
|
ErrorCode addDirectoryContents(const QString& path,
|
||||||
CompressionLevel level = AutoFull);
|
CompressionLevel level = AutoFull);
|
||||||
ErrorCode addDirectoryContents(const QString& path, const QString& root,
|
ErrorCode addDirectoryContents(const QString& path, const QString& root,
|
||||||
CompressionLevel level = AutoFull);
|
CompressionLevel level = AutoFull);
|
||||||
|
|
||||||
ErrorCode addDirectory(const QString& path,
|
ErrorCode addDirectory(const QString& path,
|
||||||
CompressionLevel level = AutoFull);
|
CompressionLevel level = AutoFull);
|
||||||
ErrorCode addDirectory(const QString& path, const QString& root,
|
ErrorCode addDirectory(const QString& path, const QString& root,
|
||||||
CompressionLevel level = AutoFull);
|
CompressionLevel level = AutoFull);
|
||||||
ErrorCode addDirectory(const QString& path, const QString& root,
|
ErrorCode addDirectory(const QString& path, const QString& root,
|
||||||
CompressionOptions options, CompressionLevel level = AutoFull,
|
CompressionOptions options, CompressionLevel level = AutoFull,
|
||||||
int* addedFiles = 0);
|
int* addedFiles = 0);
|
||||||
|
|
||||||
ErrorCode addFile(const QString& path,
|
ErrorCode addFile(const QString& path,
|
||||||
CompressionLevel level = AutoFull);
|
CompressionLevel level = AutoFull);
|
||||||
ErrorCode addFile(const QString& path, const QString& root,
|
ErrorCode addFile(const QString& path, const QString& root,
|
||||||
CompressionLevel level = AutoFull);
|
CompressionLevel level = AutoFull);
|
||||||
ErrorCode addFile(const QString& path, const QString& root,
|
ErrorCode addFile(const QString& path, const QString& root,
|
||||||
CompressionOptions options,
|
CompressionOptions options,
|
||||||
CompressionLevel level = AutoFull);
|
CompressionLevel level = AutoFull);
|
||||||
|
|
||||||
ErrorCode addFiles(const QStringList& paths,
|
ErrorCode addFiles(const QStringList& paths,
|
||||||
CompressionLevel level = AutoFull);
|
CompressionLevel level = AutoFull);
|
||||||
ErrorCode addFiles(const QStringList& paths, const QString& root,
|
ErrorCode addFiles(const QStringList& paths, const QString& root,
|
||||||
CompressionLevel level = AutoFull);
|
CompressionLevel level = AutoFull);
|
||||||
ErrorCode addFiles(const QStringList& paths, const QString& root,
|
ErrorCode addFiles(const QStringList& paths, const QString& root,
|
||||||
CompressionOptions options,
|
CompressionOptions options,
|
||||||
CompressionLevel level = AutoFull,
|
CompressionLevel level = AutoFull,
|
||||||
int* addedFiles = 0);
|
int* addedFiles = 0);
|
||||||
|
|
||||||
ErrorCode closeArchive();
|
ErrorCode closeArchive();
|
||||||
|
|
||||||
QString formatError(ErrorCode c) const;
|
QString formatError(ErrorCode c) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ZipPrivate* d;
|
ZipPrivate* d;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Zip::CompressionOptions)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Zip::CompressionOptions)
|
||||||
|
|
||||||
OSDAB_END_NAMESPACE
|
OSDAB_END_NAMESPACE
|
||||||
|
|
||||||
#endif // OSDAB_ZIP__H
|
#endif // OSDAB_ZIP__H
|
||||||
|
|
|
@ -1,133 +1,133 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
** Filename: zip_p.h
|
** Filename: zip_p.h
|
||||||
** Last updated [dd/mm/yyyy]: 27/03/2011
|
** Last updated [dd/mm/yyyy]: 27/03/2011
|
||||||
**
|
**
|
||||||
** pkzip 2.0 file compression.
|
** pkzip 2.0 file compression.
|
||||||
**
|
**
|
||||||
** Some of the code has been inspired by other open source projects,
|
** Some of the code has been inspired by other open source projects,
|
||||||
** (mainly Info-Zip and Gilles Vollant's minizip).
|
** (mainly Info-Zip and Gilles Vollant's minizip).
|
||||||
** Compression and decompression actually uses the zlib library.
|
** Compression and decompression actually uses the zlib library.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
||||||
**
|
**
|
||||||
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
||||||
**
|
**
|
||||||
** This file may be distributed and/or modified under the terms of the
|
** This file may be distributed and/or modified under the terms of the
|
||||||
** GNU General Public License version 2 as published by the Free Software
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
** packaging of this file.
|
** packaging of this file.
|
||||||
**
|
**
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
**
|
**
|
||||||
** See the file LICENSE.GPL that came with this software distribution or
|
** See the file LICENSE.GPL that came with this software distribution or
|
||||||
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
||||||
**
|
**
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
//
|
//
|
||||||
// W A R N I N G
|
// W A R N I N G
|
||||||
// -------------
|
// -------------
|
||||||
//
|
//
|
||||||
// This file is not part of the Zip/UnZip API. It exists purely as an
|
// This file is not part of the Zip/UnZip API. It exists purely as an
|
||||||
// implementation detail. This header file may change from version to
|
// implementation detail. This header file may change from version to
|
||||||
// version without notice, or even be removed.
|
// version without notice, or even be removed.
|
||||||
//
|
//
|
||||||
// We mean it.
|
// We mean it.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef OSDAB_ZIP_P__H
|
#ifndef OSDAB_ZIP_P__H
|
||||||
#define OSDAB_ZIP_P__H
|
#define OSDAB_ZIP_P__H
|
||||||
|
|
||||||
#include "zip.h"
|
#include "zip.h"
|
||||||
#include "zipentry_p.h"
|
#include "zipentry_p.h"
|
||||||
|
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
#include <zlib/zconf.h>
|
#include <zlib/zconf.h>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
zLib authors suggest using larger buffers (128K or 256K) for (de)compression (especially for inflate())
|
zLib authors suggest using larger buffers (128K or 256K) for (de)compression (especially for inflate())
|
||||||
we use a 256K buffer here - if you want to use this code on a pre-iceage mainframe please change it ;)
|
we use a 256K buffer here - if you want to use this code on a pre-iceage mainframe please change it ;)
|
||||||
*/
|
*/
|
||||||
#define ZIP_READ_BUFFER (256*1024)
|
#define ZIP_READ_BUFFER (256*1024)
|
||||||
|
|
||||||
OSDAB_BEGIN_NAMESPACE(Zip)
|
OSDAB_BEGIN_NAMESPACE(Zip)
|
||||||
|
|
||||||
class ZipPrivate : public QObject
|
class ZipPrivate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// uLongf from zconf.h
|
// uLongf from zconf.h
|
||||||
typedef uLongf crc_t;
|
typedef uLongf crc_t;
|
||||||
|
|
||||||
ZipPrivate();
|
ZipPrivate();
|
||||||
virtual ~ZipPrivate();
|
virtual ~ZipPrivate();
|
||||||
|
|
||||||
QMap<QString,ZipEntryP*>* headers;
|
QMap<QString,ZipEntryP*>* headers;
|
||||||
|
|
||||||
QIODevice* device;
|
QIODevice* device;
|
||||||
QFile* file;
|
QFile* file;
|
||||||
|
|
||||||
char buffer1[ZIP_READ_BUFFER];
|
char buffer1[ZIP_READ_BUFFER];
|
||||||
char buffer2[ZIP_READ_BUFFER];
|
char buffer2[ZIP_READ_BUFFER];
|
||||||
|
|
||||||
unsigned char* uBuffer;
|
unsigned char* uBuffer;
|
||||||
|
|
||||||
const crc_t* crcTable;
|
const crc_t* crcTable;
|
||||||
|
|
||||||
QString comment;
|
QString comment;
|
||||||
QString password;
|
QString password;
|
||||||
|
|
||||||
Zip::ErrorCode createArchive(QIODevice* device);
|
Zip::ErrorCode createArchive(QIODevice* device);
|
||||||
Zip::ErrorCode closeArchive();
|
Zip::ErrorCode closeArchive();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
bool zLibInit();
|
bool zLibInit();
|
||||||
|
|
||||||
bool containsEntry(const QFileInfo& info) const;
|
bool containsEntry(const QFileInfo& info) const;
|
||||||
|
|
||||||
Zip::ErrorCode addDirectory(const QString& path, const QString& root,
|
Zip::ErrorCode addDirectory(const QString& path, const QString& root,
|
||||||
Zip::CompressionOptions options, Zip::CompressionLevel level,
|
Zip::CompressionOptions options, Zip::CompressionLevel level,
|
||||||
int hierarchyLevel, int* addedFiles = 0);
|
int hierarchyLevel, int* addedFiles = 0);
|
||||||
Zip::ErrorCode addFiles(const QStringList& paths, const QString& root,
|
Zip::ErrorCode addFiles(const QStringList& paths, const QString& root,
|
||||||
Zip::CompressionOptions options, Zip::CompressionLevel level,
|
Zip::CompressionOptions options, Zip::CompressionLevel level,
|
||||||
int* addedFiles);
|
int* addedFiles);
|
||||||
|
|
||||||
Zip::ErrorCode createEntry(const QFileInfo& file, const QString& root,
|
Zip::ErrorCode createEntry(const QFileInfo& file, const QString& root,
|
||||||
Zip::CompressionLevel level);
|
Zip::CompressionLevel level);
|
||||||
Zip::CompressionLevel detectCompressionByMime(const QString& ext);
|
Zip::CompressionLevel detectCompressionByMime(const QString& ext);
|
||||||
|
|
||||||
inline quint32 updateChecksum(const quint32& crc, const quint32& val) const;
|
inline quint32 updateChecksum(const quint32& crc, const quint32& val) const;
|
||||||
|
|
||||||
inline void encryptBytes(quint32* keys, char* buffer, qint64 read);
|
inline void encryptBytes(quint32* keys, char* buffer, qint64 read);
|
||||||
|
|
||||||
inline void setULong(quint32 v, char* buffer, unsigned int offset);
|
inline void setULong(quint32 v, char* buffer, unsigned int offset);
|
||||||
inline void updateKeys(quint32* keys, int c) const;
|
inline void updateKeys(quint32* keys, int c) const;
|
||||||
inline void initKeys(quint32* keys) const;
|
inline void initKeys(quint32* keys) const;
|
||||||
inline int decryptByte(quint32 key2) const;
|
inline int decryptByte(quint32 key2) const;
|
||||||
|
|
||||||
inline QString extractRoot(const QString& p, Zip::CompressionOptions o);
|
inline QString extractRoot(const QString& p, Zip::CompressionOptions o);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void deviceDestroyed(QObject*);
|
void deviceDestroyed(QObject*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int compressionStrategy(const QString& path, QIODevice& file) const;
|
int compressionStrategy(const QString& path, QIODevice& file) const;
|
||||||
Zip::ErrorCode deflateFile(const QFileInfo& fileInfo,
|
Zip::ErrorCode deflateFile(const QFileInfo& fileInfo,
|
||||||
quint32& crc, qint64& written, const Zip::CompressionLevel& level, quint32** keys);
|
quint32& crc, qint64& written, const Zip::CompressionLevel& level, quint32** keys);
|
||||||
Zip::ErrorCode storeFile(const QString& path, QIODevice& file,
|
Zip::ErrorCode storeFile(const QString& path, QIODevice& file,
|
||||||
quint32& crc, qint64& written, quint32** keys);
|
quint32& crc, qint64& written, quint32** keys);
|
||||||
Zip::ErrorCode compressFile(const QString& path, QIODevice& file,
|
Zip::ErrorCode compressFile(const QString& path, QIODevice& file,
|
||||||
quint32& crc, qint64& written, const Zip::CompressionLevel& level, quint32** keys);
|
quint32& crc, qint64& written, const Zip::CompressionLevel& level, quint32** keys);
|
||||||
Zip::ErrorCode do_closeArchive();
|
Zip::ErrorCode do_closeArchive();
|
||||||
Zip::ErrorCode writeEntry(const QString& fileName, const ZipEntryP* h, quint32& szCentralDir);
|
Zip::ErrorCode writeEntry(const QString& fileName, const ZipEntryP* h, quint32& szCentralDir);
|
||||||
Zip::ErrorCode writeCentralDir(quint32 offCentralDir, quint32 szCentralDir);
|
Zip::ErrorCode writeCentralDir(quint32 offCentralDir, quint32 szCentralDir);
|
||||||
};
|
};
|
||||||
|
|
||||||
OSDAB_END_NAMESPACE
|
OSDAB_END_NAMESPACE
|
||||||
|
|
||||||
#endif // OSDAB_ZIP_P__H
|
#endif // OSDAB_ZIP_P__H
|
||||||
|
|
|
@ -1,91 +1,91 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
** Filename: ZipEntryP.h
|
** Filename: ZipEntryP.h
|
||||||
** Last updated [dd/mm/yyyy]: 27/03/2011
|
** Last updated [dd/mm/yyyy]: 27/03/2011
|
||||||
**
|
**
|
||||||
** Wrapper for a ZIP local header.
|
** Wrapper for a ZIP local header.
|
||||||
**
|
**
|
||||||
** Some of the code has been inspired by other open source projects,
|
** Some of the code has been inspired by other open source projects,
|
||||||
** (mainly Info-Zip and Gilles Vollant's minizip).
|
** (mainly Info-Zip and Gilles Vollant's minizip).
|
||||||
** Compression and decompression actually uses the zlib library.
|
** Compression and decompression actually uses the zlib library.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
||||||
**
|
**
|
||||||
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
||||||
**
|
**
|
||||||
** This file may be distributed and/or modified under the terms of the
|
** This file may be distributed and/or modified under the terms of the
|
||||||
** GNU General Public License version 2 as published by the Free Software
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
** packaging of this file.
|
** packaging of this file.
|
||||||
**
|
**
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
**
|
**
|
||||||
** See the file LICENSE.GPL that came with this software distribution or
|
** See the file LICENSE.GPL that came with this software distribution or
|
||||||
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
||||||
**
|
**
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
//
|
//
|
||||||
// W A R N I N G
|
// W A R N I N G
|
||||||
// -------------
|
// -------------
|
||||||
//
|
//
|
||||||
// This file is not part of the Zip/UnZip API. It exists purely as an
|
// This file is not part of the Zip/UnZip API. It exists purely as an
|
||||||
// implementation detail. This header file may change from version to
|
// implementation detail. This header file may change from version to
|
||||||
// version without notice, or even be removed.
|
// version without notice, or even be removed.
|
||||||
//
|
//
|
||||||
// We mean it.
|
// We mean it.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef OSDAB_ZIPENTRY_P__H
|
#ifndef OSDAB_ZIPENTRY_P__H
|
||||||
#define OSDAB_ZIPENTRY_P__H
|
#define OSDAB_ZIPENTRY_P__H
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
OSDAB_BEGIN_NAMESPACE(Zip)
|
OSDAB_BEGIN_NAMESPACE(Zip)
|
||||||
|
|
||||||
class ZipEntryP
|
class ZipEntryP
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ZipEntryP() :
|
ZipEntryP() :
|
||||||
lhOffset(0),
|
lhOffset(0),
|
||||||
dataOffset(0),
|
dataOffset(0),
|
||||||
gpFlag(),
|
gpFlag(),
|
||||||
compMethod(0),
|
compMethod(0),
|
||||||
modTime(),
|
modTime(),
|
||||||
modDate(),
|
modDate(),
|
||||||
crc(0),
|
crc(0),
|
||||||
szComp(0),
|
szComp(0),
|
||||||
szUncomp(0),
|
szUncomp(0),
|
||||||
absolutePath(),
|
absolutePath(),
|
||||||
fileSize(0),
|
fileSize(0),
|
||||||
lhEntryChecked(false)
|
lhEntryChecked(false)
|
||||||
{
|
{
|
||||||
gpFlag[0] = gpFlag[1] = 0;
|
gpFlag[0] = gpFlag[1] = 0;
|
||||||
modTime[0] = modTime[1] = 0;
|
modTime[0] = modTime[1] = 0;
|
||||||
modDate[0] = modDate[1] = 0;
|
modDate[0] = modDate[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32 lhOffset; // Offset of the local header record for this entry
|
quint32 lhOffset; // Offset of the local header record for this entry
|
||||||
mutable quint32 dataOffset; // Offset of the file data for this entry
|
mutable quint32 dataOffset; // Offset of the file data for this entry
|
||||||
unsigned char gpFlag[2]; // General purpose flag
|
unsigned char gpFlag[2]; // General purpose flag
|
||||||
quint16 compMethod; // Compression method
|
quint16 compMethod; // Compression method
|
||||||
unsigned char modTime[2]; // Last modified time
|
unsigned char modTime[2]; // Last modified time
|
||||||
unsigned char modDate[2]; // Last modified date
|
unsigned char modDate[2]; // Last modified date
|
||||||
quint32 crc; // CRC32
|
quint32 crc; // CRC32
|
||||||
quint32 szComp; // Compressed file size
|
quint32 szComp; // Compressed file size
|
||||||
quint32 szUncomp; // Uncompressed file size
|
quint32 szUncomp; // Uncompressed file size
|
||||||
QString comment; // File comment
|
QString comment; // File comment
|
||||||
|
|
||||||
QString absolutePath; // Internal use
|
QString absolutePath; // Internal use
|
||||||
qint64 fileSize; // Internal use
|
qint64 fileSize; // Internal use
|
||||||
|
|
||||||
mutable bool lhEntryChecked; // Is true if the local header record for this entry has been parsed
|
mutable bool lhEntryChecked; // Is true if the local header record for this entry has been parsed
|
||||||
|
|
||||||
inline bool isEncrypted() const { return gpFlag[0] & 0x01; }
|
inline bool isEncrypted() const { return gpFlag[0] & 0x01; }
|
||||||
inline bool hasDataDescriptor() const { return gpFlag[0] & 0x08; }
|
inline bool hasDataDescriptor() const { return gpFlag[0] & 0x08; }
|
||||||
};
|
};
|
||||||
|
|
||||||
OSDAB_END_NAMESPACE
|
OSDAB_END_NAMESPACE
|
||||||
|
|
||||||
#endif // OSDAB_ZIPENTRY_P__H
|
#endif // OSDAB_ZIPENTRY_P__H
|
||||||
|
|
|
@ -1,152 +1,152 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
** Filename: zipglobal.cpp
|
** Filename: zipglobal.cpp
|
||||||
** Last updated [dd/mm/yyyy]: 06/02/2011
|
** Last updated [dd/mm/yyyy]: 06/02/2011
|
||||||
**
|
**
|
||||||
** pkzip 2.0 file compression.
|
** pkzip 2.0 file compression.
|
||||||
**
|
**
|
||||||
** Some of the code has been inspired by other open source projects,
|
** Some of the code has been inspired by other open source projects,
|
||||||
** (mainly Info-Zip and Gilles Vollant's minizip).
|
** (mainly Info-Zip and Gilles Vollant's minizip).
|
||||||
** Compression and decompression actually uses the zlib library.
|
** Compression and decompression actually uses the zlib library.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
||||||
**
|
**
|
||||||
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
||||||
**
|
**
|
||||||
** This file may be distributed and/or modified under the terms of the
|
** This file may be distributed and/or modified under the terms of the
|
||||||
** GNU General Public License version 2 as published by the Free Software
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
** packaging of this file.
|
** packaging of this file.
|
||||||
**
|
**
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
**
|
**
|
||||||
** See the file LICENSE.GPL that came with this software distribution or
|
** See the file LICENSE.GPL that came with this software distribution or
|
||||||
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
||||||
**
|
**
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
#include "zipglobal.h"
|
#include "zipglobal.h"
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) || defined(Q_OS_WINCE) || defined(Q_OS_LINUX) || defined (Q_OS_MACX)
|
#if defined(Q_OS_WIN) || defined(Q_OS_WINCE) || defined(Q_OS_LINUX) || defined (Q_OS_MACX)
|
||||||
#define OSDAB_ZIP_HAS_UTC
|
#define OSDAB_ZIP_HAS_UTC
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#else
|
#else
|
||||||
#undef OSDAB_ZIP_HAS_UTC
|
#undef OSDAB_ZIP_HAS_UTC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
#include <QtCore/qt_windows.h>
|
#include <QtCore/qt_windows.h>
|
||||||
#elif defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
#elif defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OSDAB_BEGIN_NAMESPACE(Zip)
|
OSDAB_BEGIN_NAMESPACE(Zip)
|
||||||
|
|
||||||
/*! Returns the current UTC offset in seconds unless OSDAB_ZIP_NO_UTC is defined
|
/*! Returns the current UTC offset in seconds unless OSDAB_ZIP_NO_UTC is defined
|
||||||
and method is implemented for the current platform and 0 otherwise.
|
and method is implemented for the current platform and 0 otherwise.
|
||||||
*/
|
*/
|
||||||
int OSDAB_ZIP_MANGLE(currentUtcOffset)()
|
int OSDAB_ZIP_MANGLE(currentUtcOffset)()
|
||||||
{
|
{
|
||||||
#if !(!defined OSDAB_ZIP_NO_UTC && defined OSDAB_ZIP_HAS_UTC)
|
#if !(!defined OSDAB_ZIP_NO_UTC && defined OSDAB_ZIP_HAS_UTC)
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
time_t curr_time_t;
|
time_t curr_time_t;
|
||||||
time(&curr_time_t);
|
time(&curr_time_t);
|
||||||
|
|
||||||
#if defined Q_OS_WIN
|
#if defined Q_OS_WIN
|
||||||
struct tm _tm_struct;
|
struct tm _tm_struct;
|
||||||
struct tm* tm_struct = &_tm_struct;
|
struct tm* tm_struct = &_tm_struct;
|
||||||
#else
|
#else
|
||||||
struct tm* tm_struct = 0;
|
struct tm* tm_struct = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
|
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
|
||||||
// use the reentrant version of localtime() where available
|
// use the reentrant version of localtime() where available
|
||||||
tzset();
|
tzset();
|
||||||
tm res;
|
tm res;
|
||||||
tm_struct = gmtime_r(&curr_time_t, &res);
|
tm_struct = gmtime_r(&curr_time_t, &res);
|
||||||
#elif defined Q_OS_WIN && !defined Q_CC_MINGW
|
#elif defined Q_OS_WIN && !defined Q_CC_MINGW
|
||||||
if (gmtime_s(tm_struct, &curr_time_t))
|
if (gmtime_s(tm_struct, &curr_time_t))
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
tm_struct = gmtime(&curr_time_t);
|
tm_struct = gmtime(&curr_time_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!tm_struct)
|
if (!tm_struct)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const time_t global_time_t = mktime(tm_struct);
|
const time_t global_time_t = mktime(tm_struct);
|
||||||
|
|
||||||
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
|
#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
|
||||||
// use the reentrant version of localtime() where available
|
// use the reentrant version of localtime() where available
|
||||||
tm_struct = localtime_r(&curr_time_t, &res);
|
tm_struct = localtime_r(&curr_time_t, &res);
|
||||||
#elif defined Q_OS_WIN && !defined Q_CC_MINGW
|
#elif defined Q_OS_WIN && !defined Q_CC_MINGW
|
||||||
if (localtime_s(tm_struct, &curr_time_t))
|
if (localtime_s(tm_struct, &curr_time_t))
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
tm_struct = localtime(&curr_time_t);
|
tm_struct = localtime(&curr_time_t);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!tm_struct)
|
if (!tm_struct)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const time_t local_time_t = mktime(tm_struct);
|
const time_t local_time_t = mktime(tm_struct);
|
||||||
|
|
||||||
const int utcOffset = - qRound(difftime(global_time_t, local_time_t));
|
const int utcOffset = - qRound(difftime(global_time_t, local_time_t));
|
||||||
return tm_struct->tm_isdst > 0 ? utcOffset + 3600 : utcOffset;
|
return tm_struct->tm_isdst > 0 ? utcOffset + 3600 : utcOffset;
|
||||||
#endif // No UTC
|
#endif // No UTC
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime OSDAB_ZIP_MANGLE(fromFileTimestamp)(const QDateTime& dateTime)
|
QDateTime OSDAB_ZIP_MANGLE(fromFileTimestamp)(const QDateTime& dateTime)
|
||||||
{
|
{
|
||||||
#if !defined OSDAB_ZIP_NO_UTC && defined OSDAB_ZIP_HAS_UTC
|
#if !defined OSDAB_ZIP_NO_UTC && defined OSDAB_ZIP_HAS_UTC
|
||||||
const int utc = OSDAB_ZIP_MANGLE(currentUtcOffset)();
|
const int utc = OSDAB_ZIP_MANGLE(currentUtcOffset)();
|
||||||
return dateTime.toUTC().addSecs(utc);
|
return dateTime.toUTC().addSecs(utc);
|
||||||
#else
|
#else
|
||||||
return dateTime;
|
return dateTime;
|
||||||
#endif // OSDAB_ZIP_NO_UTC
|
#endif // OSDAB_ZIP_NO_UTC
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OSDAB_ZIP_MANGLE(setFileTimestamp)(const QString& fileName, const QDateTime& dateTime)
|
bool OSDAB_ZIP_MANGLE(setFileTimestamp)(const QString& fileName, const QDateTime& dateTime)
|
||||||
{
|
{
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
HANDLE hFile = CreateFileW(fileName.toStdWString().c_str(),
|
HANDLE hFile = CreateFileW(fileName.toStdWString().c_str(),
|
||||||
GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
GENERIC_WRITE, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
|
||||||
if (hFile == INVALID_HANDLE_VALUE) {
|
if (hFile == INVALID_HANDLE_VALUE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
FILETIME ft, ftLastMod;
|
FILETIME ft, ftLastMod;
|
||||||
const QDate date = dateTime.date();
|
const QDate date = dateTime.date();
|
||||||
const QTime time = dateTime.time();
|
const QTime time = dateTime.time();
|
||||||
st.wYear = date.year();
|
st.wYear = date.year();
|
||||||
st.wMonth = date.month();
|
st.wMonth = date.month();
|
||||||
st.wDay = date.day();
|
st.wDay = date.day();
|
||||||
st.wHour = time.hour();
|
st.wHour = time.hour();
|
||||||
st.wMinute = time.minute();
|
st.wMinute = time.minute();
|
||||||
st.wSecond = time.second();
|
st.wSecond = time.second();
|
||||||
st.wMilliseconds = time.msec();
|
st.wMilliseconds = time.msec();
|
||||||
|
|
||||||
SystemTimeToFileTime(&st, &ft);
|
SystemTimeToFileTime(&st, &ft);
|
||||||
LocalFileTimeToFileTime(&ft, &ftLastMod);
|
LocalFileTimeToFileTime(&ft, &ftLastMod);
|
||||||
|
|
||||||
const bool success = SetFileTime(hFile, NULL, NULL, &ftLastMod);
|
const bool success = SetFileTime(hFile, NULL, NULL, &ftLastMod);
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
return success;
|
return success;
|
||||||
|
|
||||||
#elif defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
#elif defined(Q_OS_LINUX) || defined(Q_OS_MACX)
|
||||||
|
|
||||||
struct utimbuf t_buffer;
|
struct utimbuf t_buffer;
|
||||||
t_buffer.actime = t_buffer.modtime = dateTime.toTime_t();
|
t_buffer.actime = t_buffer.modtime = dateTime.toTime_t();
|
||||||
return utime(fileName.toLocal8Bit().constData(), &t_buffer) == 0;
|
return utime(fileName.toLocal8Bit().constData(), &t_buffer) == 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
OSDAB_END_NAMESPACE
|
OSDAB_END_NAMESPACE
|
||||||
|
|
|
@ -1,77 +1,77 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
** Filename: zipglobal.h
|
** Filename: zipglobal.h
|
||||||
** Last updated [dd/mm/yyyy]: 27/03/2011
|
** Last updated [dd/mm/yyyy]: 27/03/2011
|
||||||
**
|
**
|
||||||
** pkzip 2.0 file compression.
|
** pkzip 2.0 file compression.
|
||||||
**
|
**
|
||||||
** Some of the code has been inspired by other open source projects,
|
** Some of the code has been inspired by other open source projects,
|
||||||
** (mainly Info-Zip and Gilles Vollant's minizip).
|
** (mainly Info-Zip and Gilles Vollant's minizip).
|
||||||
** Compression and decompression actually uses the zlib library.
|
** Compression and decompression actually uses the zlib library.
|
||||||
**
|
**
|
||||||
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
** Copyright (C) 2007-2012 Angius Fabrizio. All rights reserved.
|
||||||
**
|
**
|
||||||
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
** This file is part of the OSDaB project (http://osdab.42cows.org/).
|
||||||
**
|
**
|
||||||
** This file may be distributed and/or modified under the terms of the
|
** This file may be distributed and/or modified under the terms of the
|
||||||
** GNU General Public License version 2 as published by the Free Software
|
** GNU General Public License version 2 as published by the Free Software
|
||||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||||
** packaging of this file.
|
** packaging of this file.
|
||||||
**
|
**
|
||||||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
**
|
**
|
||||||
** See the file LICENSE.GPL that came with this software distribution or
|
** See the file LICENSE.GPL that came with this software distribution or
|
||||||
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
** visit http://www.gnu.org/copyleft/gpl.html for GPL licensing information.
|
||||||
**
|
**
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
#ifndef OSDAB_ZIPGLOBAL__H
|
#ifndef OSDAB_ZIPGLOBAL__H
|
||||||
#define OSDAB_ZIPGLOBAL__H
|
#define OSDAB_ZIPGLOBAL__H
|
||||||
|
|
||||||
#include <QtCore/QDateTime>
|
#include <QtCore/QDateTime>
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
/* If you want to build the OSDaB Zip code as
|
/* If you want to build the OSDaB Zip code as
|
||||||
a library, define OSDAB_ZIP_LIB in the library's .pro file and
|
a library, define OSDAB_ZIP_LIB in the library's .pro file and
|
||||||
in the libraries using it OR remove the #ifndef OSDAB_ZIP_LIB
|
in the libraries using it OR remove the #ifndef OSDAB_ZIP_LIB
|
||||||
define below and leave the #else body. Also remember to define
|
define below and leave the #else body. Also remember to define
|
||||||
OSDAB_ZIP_BUILD_LIB in the library's project).
|
OSDAB_ZIP_BUILD_LIB in the library's project).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OSDAB_ZIP_LIB
|
#ifndef OSDAB_ZIP_LIB
|
||||||
# define OSDAB_ZIP_EXPORT
|
# define OSDAB_ZIP_EXPORT
|
||||||
#else
|
#else
|
||||||
# if defined(OSDAB_ZIP_BUILD_LIB)
|
# if defined(OSDAB_ZIP_BUILD_LIB)
|
||||||
# define OSDAB_ZIP_EXPORT Q_DECL_EXPORT
|
# define OSDAB_ZIP_EXPORT Q_DECL_EXPORT
|
||||||
# else
|
# else
|
||||||
# define OSDAB_ZIP_EXPORT Q_DECL_IMPORT
|
# define OSDAB_ZIP_EXPORT Q_DECL_IMPORT
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OSDAB_NAMESPACE
|
#ifdef OSDAB_NAMESPACE
|
||||||
#define OSDAB_BEGIN_NAMESPACE(ModuleName) namespace Osdab { namespace ModuleName {
|
#define OSDAB_BEGIN_NAMESPACE(ModuleName) namespace Osdab { namespace ModuleName {
|
||||||
#else
|
#else
|
||||||
#define OSDAB_BEGIN_NAMESPACE(ModuleName)
|
#define OSDAB_BEGIN_NAMESPACE(ModuleName)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OSDAB_NAMESPACE
|
#ifdef OSDAB_NAMESPACE
|
||||||
#define OSDAB_END_NAMESPACE } }
|
#define OSDAB_END_NAMESPACE } }
|
||||||
#else
|
#else
|
||||||
#define OSDAB_END_NAMESPACE
|
#define OSDAB_END_NAMESPACE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef OSDAB_NAMESPACE
|
#ifndef OSDAB_NAMESPACE
|
||||||
#define OSDAB_ZIP_MANGLE(x) zip_##x
|
#define OSDAB_ZIP_MANGLE(x) zip_##x
|
||||||
#else
|
#else
|
||||||
#define OSDAB_ZIP_MANGLE(x) x
|
#define OSDAB_ZIP_MANGLE(x) x
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OSDAB_BEGIN_NAMESPACE(Zip)
|
OSDAB_BEGIN_NAMESPACE(Zip)
|
||||||
|
|
||||||
OSDAB_ZIP_EXPORT int OSDAB_ZIP_MANGLE(currentUtcOffset)();
|
OSDAB_ZIP_EXPORT int OSDAB_ZIP_MANGLE(currentUtcOffset)();
|
||||||
OSDAB_ZIP_EXPORT QDateTime OSDAB_ZIP_MANGLE(fromFileTimestamp)(const QDateTime& dateTime);
|
OSDAB_ZIP_EXPORT QDateTime OSDAB_ZIP_MANGLE(fromFileTimestamp)(const QDateTime& dateTime);
|
||||||
OSDAB_ZIP_EXPORT bool OSDAB_ZIP_MANGLE(setFileTimestamp)(const QString& fileName, const QDateTime& dateTime);
|
OSDAB_ZIP_EXPORT bool OSDAB_ZIP_MANGLE(setFileTimestamp)(const QString& fileName, const QDateTime& dateTime);
|
||||||
|
|
||||||
OSDAB_END_NAMESPACE
|
OSDAB_END_NAMESPACE
|
||||||
|
|
||||||
#endif // OSDAB_ZIPGLOBAL__H
|
#endif // OSDAB_ZIPGLOBAL__H
|
||||||
|
|
Loading…
Reference in a new issue