JlCompress.h
#ifndef JLCOMPRESSFOLDER_H_
#define JLCOMPRESSFOLDER_H_
/*
Copyright (C) 2010 Roberto Pompermaier
Copyright (C) 2005-2016 Sergey A. Tachenov
This file is part of QuaZip.
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,
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/>.
See COPYING file for the full LGPL text.
Original ZIP package is copyrighted by Gilles Vollant and contributors,
see quazip/(un)zip.h files for details. Basically it's the zlib license.
*/
#include "quazip.h"
#include "quazipfile.h"
#include "quazipfileinfo.h"
#include "quazip_qt_compat.h"
#include <QtCore/QString>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>
#include <QtCore/QFile>
#include <QtCore/QSharedDataPointer>
class QUAZIP_EXPORT JlCompress {
public:
class QUAZIP_EXPORT Options {
public:
enum CompressionStrategy
{
Storage = 0x00, // Z_NO_COMPRESSION 0
Fastest = 0x81, // Z_BEST_SPEED 1
Faster = 0x83,
Standard = 0x86,
Better = 0x87,
Best = 0x89, // Z_BEST_COMPRESSION 9
Default = 0xff
};
public:
explicit Options(const CompressionStrategy& strategy);
explicit Options(const QDateTime& dateTime = QDateTime(),
const CompressionStrategy& strategy = Default,
bool utf8Enabled = false,
const QByteArray& password = QByteArray());
Options(const Options& other) noexcept;
Options& operator=(const Options& other) noexcept;
~Options();
QDateTime getDateTime() const;
void setDateTime(const QDateTime &dateTime);
CompressionStrategy getCompressionStrategy() const;
int getCompressionMethod() const;
int getCompressionLevel() const;
void setCompressionStrategy(const CompressionStrategy &strategy);
bool getUtf8Enabled() const;
void setUtf8Enabled(bool utf8Enabled);
QByteArray getPassword() const;
void setPassword(const QByteArray& password);
private:
struct JlOptions;
QSharedDataPointer<JlOptions> d;
};
static bool copyData(QIODevice &inFile, QIODevice &outFile);
static QStringList extractDir(QuaZip &zip, const QString &dir);
static QStringList getFileList(QuaZip *zip);
static QString extractFile(QuaZip &zip, QString fileName, QString fileDest);
static QStringList extractFiles(QuaZip &zip, const QStringList &files, const QString &dir);
static bool extractFile(QuaZip* zip, QString fileName, QString fileDest);
static bool compressFile(QuaZip* zip, QString fileName, QString fileDest);
static bool compressFile(QuaZip* zip, QString fileName, QString fileDest, const Options& options);
static bool compressSubDir(QuaZip* parentZip, QString dir, QString parentDir, bool recursive,
QDir::Filters filters);
static bool compressSubDir(QuaZip* parentZip, QString dir, QString parentDir, bool recursive,
QDir::Filters filters, const Options& options);
static bool removeFile(QStringList listFile);
static bool compressFile(QString fileCompressed, QString file);
static bool compressFile(QString fileCompressed, QString file, const Options& options);
static bool compressFiles(QString fileCompressed, QStringList files);
static bool compressFiles(QString fileCompressed, QStringList files, const Options& options);
static bool addFile(QString fileCompressed, QString file);
static bool addFile(QString fileCompressed, QString file, const Options& options);
static bool addFiles(QString fileCompressed, QStringList files);
static bool addFiles(QString fileCompressed, QStringList files, const Options& options);
static bool addDir(QString fileCompressed, QString dir = QString(), bool recursive = true);
static bool addDir(QString fileCompressed, QString dir,
bool recursive, QDir::Filters filters);
static bool addDir(QString fileCompressed, QString dir,
bool recursive, QDir::Filters filters, const Options& options);
static bool compressDir(QString fileCompressed, QString dir = QString(), bool recursive = true);
static bool compressDir(QString fileCompressed, QString dir,
bool recursive, QDir::Filters filters);
static bool compressDir(QString fileCompressed, QString dir,
bool recursive, QDir::Filters filters, const Options& options);
static QString extractFile(QString fileCompressed, QString fileName, QString fileDest = QString());
static QStringList extractFiles(QString fileCompressed, QStringList files, QString dir = QString());
static QStringList extractDir(QString fileCompressed, QString dir = QString());
static QStringList extractDir(QString fileCompressed, QuazipTextCodec* fileNameCodec, QString dir = QString());
static QString extractFile(QString fileCompressed, QString fileName, QString fileDest, const QByteArray& password);
static QStringList extractFiles(QString fileCompressed, QStringList files, QString dir, const QByteArray& password);
static QStringList extractDir(QString fileCompressed, QString dir, const QByteArray& password);
static QStringList getFileList(QString fileCompressed);
static QString extractFile(QIODevice *ioDevice, QString fileName, QString fileDest = QString());
static QStringList extractFiles(QIODevice *ioDevice, QStringList files, QString dir = QString());
static QStringList extractDir(QIODevice *ioDevice, QString dir = QString());
static QStringList extractDir(QIODevice* ioDevice, QuazipTextCodec* fileNameCodec, QString dir = QString());
static QStringList getFileList(QIODevice *ioDevice);
};
#endif /* JLCOMPRESSFOLDER_H_ */
JlCompress::Options
Definition JlCompress.h:46
JlCompress::Options::CompressionStrategy
CompressionStrategy
Definition JlCompress.h:62
JlCompress::Options::Default
@ Default
Definition JlCompress.h:77
JlCompress::Options::Storage
@ Storage
Storage without compression.
Definition JlCompress.h:64
JlCompress::Options::Standard
@ Standard
Standard compression speed and ratio.
Definition JlCompress.h:70
JlCompress::Options::Faster
@ Faster
Relatively fast compression speed.
Definition JlCompress.h:68
JlCompress::Options::Fastest
@ Fastest
The fastest compression speed.
Definition JlCompress.h:66
JlCompress::Options::Better
@ Better
Better compression ratio.
Definition JlCompress.h:72
JlCompress::Options::Best
@ Best
The best compression ratio.
Definition JlCompress.h:74
JlCompress
Utility class for typical operations.
Definition JlCompress.h:44
QuaZip
ZIP archive.
Definition quazip.h:84
QuazipTextCodec
Definition quazip_textcodec.h:40