QuaCompress.h
#ifndef QUACOMPRESS_H
#define QUACOMPRESS_H
/*
Copyright (C) 2025 cen1
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.
*/
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QDir>
#include <QtCore/QDateTime>
#include "quazip_global.h"
#include "JlCompress.h"
class QUAZIP_EXPORT QuaCompress {
public:
typedef JlCompress::Options::CompressionStrategy CompressionStrategy;
// Convenience constants for compression strategies
static constexpr CompressionStrategy Storage = JlCompress::Options::Storage;
static constexpr CompressionStrategy Fastest = JlCompress::Options::Fastest;
static constexpr CompressionStrategy Faster = JlCompress::Options::Faster;
static constexpr CompressionStrategy Standard = JlCompress::Options::Standard;
static constexpr CompressionStrategy Better = JlCompress::Options::Better;
static constexpr CompressionStrategy Best = JlCompress::Options::Best;
static constexpr CompressionStrategy Default = JlCompress::Options::Default;
QuaCompress();
QuaCompress& withUtf8Enabled(bool enabled = true);
QuaCompress& withStrategy(CompressionStrategy strategy);
QuaCompress& withDateTime(const QDateTime& dateTime);
QuaCompress& withPassword(const QByteArray& password);
// ==================== Compression Methods ====================
bool compressFile(const QString& newArchive, const QString& file) const;
bool compressFiles(const QString& newArchive, const QStringList& files) const;
bool compressDir(const QString& newArchive, const QString& dir = QString(),
bool recursive = true,
QDir::Filters filters = QDir::AllEntries | QDir::NoDotAndDotDot) const;
// ==================== Add to Existing Archive ====================
bool addFile(const QString& existingArchive, const QString& file) const;
bool addFiles(const QString& existingArchive, const QStringList& files) const;
bool addDir(const QString& existingArchive, const QString& dir = QString(),
bool recursive = true,
QDir::Filters filters = QDir::AllEntries | QDir::NoDotAndDotDot) const;
private:
JlCompress::Options m_options {JlCompress::Options::Default};
};
#endif // QUACOMPRESS_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
QuaCompress::addFiles
bool addFiles(const QString &existingArchive, const QStringList &files) const
Add multiple files to an existing archive.
Definition QuaCompress.cpp:82
QuaCompress::QuaCompress
QuaCompress()
Construct a QuaCompress instance.
Definition QuaCompress.cpp:34
QuaCompress::compressFile
bool compressFile(const QString &newArchive, const QString &file) const
Compress a single file.
Definition QuaCompress.cpp:62
QuaCompress::compressFiles
bool compressFiles(const QString &newArchive, const QStringList &files) const
Compress multiple files.
Definition QuaCompress.cpp:67
QuaCompress::withUtf8Enabled
QuaCompress & withUtf8Enabled(bool enabled=true)
Enable or disable UTF-8 encoding for file names and comments.
Definition QuaCompress.cpp:38
QuaCompress::withPassword
QuaCompress & withPassword(const QByteArray &password)
Set the password for encryption.
Definition QuaCompress.cpp:56
QuaCompress::withStrategy
QuaCompress & withStrategy(CompressionStrategy strategy)
Set the compression strategy/level.
Definition QuaCompress.cpp:44
QuaCompress::CompressionStrategy
JlCompress::Options::CompressionStrategy CompressionStrategy
Compression strategy - shared with JlCompress::Options::CompressionStrategy.
Definition QuaCompress.h:47
QuaCompress::addFile
bool addFile(const QString &existingArchive, const QString &file) const
Add a single file to an existing archive.
Definition QuaCompress.cpp:77
QuaCompress::withDateTime
QuaCompress & withDateTime(const QDateTime &dateTime)
Set the date/time to use for compressed files.
Definition QuaCompress.cpp:50
QuaCompress::compressDir
bool compressDir(const QString &newArchive, const QString &dir=QString(), bool recursive=true, QDir::Filters filters=QDir::AllEntries|QDir::NoDotAndDotDot) const
Compress a directory.
Definition QuaCompress.cpp:72
QuaCompress::addDir
bool addDir(const QString &existingArchive, const QString &dir=QString(), bool recursive=true, QDir::Filters filters=QDir::AllEntries|QDir::NoDotAndDotDot) const
Add a directory to an existing archive.
Definition QuaCompress.cpp:87