QuaZip quazip-1-6
Public Types | Public Member Functions | Static Public Attributes | List of all members
QuaCompress Class Reference

#include <QuaCompress.h>

Public Types

typedef JlCompress::Options::CompressionStrategy CompressionStrategy
 Compression strategy - shared with JlCompress::Options::CompressionStrategy.
 

Public Member Functions

 QuaCompress ()
 Construct a QuaCompress instance.
 
QuaCompresswithUtf8Enabled (bool enabled=true)
 Enable or disable UTF-8 encoding for file names and comments.
 
QuaCompresswithStrategy (CompressionStrategy strategy)
 Set the compression strategy/level.
 
QuaCompresswithDateTime (const QDateTime &dateTime)
 Set the date/time to use for compressed files.
 
QuaCompresswithPassword (const QByteArray &password)
 Set the password for encryption.
 
bool compressFile (const QString &newArchive, const QString &file) const
 Compress a single file.
 
bool compressFiles (const QString &newArchive, const QStringList &files) const
 Compress multiple files.
 
bool compressDir (const QString &newArchive, const QString &dir=QString(), bool recursive=true, QDir::Filters filters=QDir::AllEntries|QDir::NoDotAndDotDot) const
 Compress a directory.
 
bool addFile (const QString &existingArchive, const QString &file) const
 Add a single file to an existing archive.
 
bool addFiles (const QString &existingArchive, const QStringList &files) const
 Add multiple files to an existing archive.
 
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.
 

Static Public Attributes

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
 

Detailed Description

QuaCompress provides a fluent API for ZIP compression operations.

Example usage:

.withUtf8Enabled()
.withCompression(QuaCompress::Best)
.compressDir("archive.zip", "mydir/");
QuaCompress()
Construct a QuaCompress instance.
Definition QuaCompress.cpp:34

Member Function Documentation

◆ withUtf8Enabled()

QuaCompress & QuaCompress::withUtf8Enabled ( bool  enabled = true)

Enable or disable UTF-8 encoding for file names and comments.

Parameters
enabledIf true, use UTF-8 encoding. If false, use the configured codec (or system default).
Returns
Reference to this instance for method chaining.

◆ withStrategy()

QuaCompress & QuaCompress::withStrategy ( CompressionStrategy  strategy)

Set the compression strategy/level.

Parameters
strategyThe compression level to use.
Returns
Reference to this instance for method chaining.

◆ withDateTime()

QuaCompress & QuaCompress::withDateTime ( const QDateTime &  dateTime)

Set the date/time to use for compressed files.

Parameters
dateTimeThe date/time to set. Default is to use current time.
Returns
Reference to this instance for method chaining.

◆ withPassword()

QuaCompress & QuaCompress::withPassword ( const QByteArray &  password)

Set the password for encryption.

Parameters
passwordThe password to use for encrypting files during compression.
Returns
Reference to this instance for method chaining.

◆ compressFile()

bool QuaCompress::compressFile ( const QString &  newArchive,
const QString &  file 
) const

Compress a single file.

Parameters
newArchiveThe name of the archive to create.
fileThe file to compress.
Returns
true if successful, false otherwise.

References JlCompress::compressFile().

◆ compressFiles()

bool QuaCompress::compressFiles ( const QString &  newArchive,
const QStringList &  files 
) const

Compress multiple files.

Parameters
newArchiveThe name of the archive to create.
filesList of files to compress.
Returns
true if successful, false otherwise.

References JlCompress::compressFiles().

◆ compressDir()

bool QuaCompress::compressDir ( const QString &  newArchive,
const QString &  dir = QString(),
bool  recursive = true,
QDir::Filters  filters = QDir::AllEntries | QDir::NoDotAndDotDot 
) const

Compress a directory.

Parameters
newArchiveThe name of the archive to create.
dirThe directory to compress. If empty, uses current directory.
recursiveIf true, include subdirectories recursively.
filtersQDir filters to apply when selecting files.
Returns
true if successful, false otherwise.

References JlCompress::compressDir().

◆ addFile()

bool QuaCompress::addFile ( const QString &  existingArchive,
const QString &  file 
) const

Add a single file to an existing archive.

Parameters
existingArchiveThe existing archive to add to.
fileThe file to add.
Returns
true if successful, false otherwise.

References JlCompress::addFile().

◆ addFiles()

bool QuaCompress::addFiles ( const QString &  existingArchive,
const QStringList &  files 
) const

Add multiple files to an existing archive.

Parameters
existingArchiveThe existing archive to add to.
filesList of files to add.
Returns
true if successful, false otherwise.
Warning
The UTF-8 setting must match the existing archive's encoding.

References JlCompress::addFiles().

◆ addDir()

bool QuaCompress::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.

Parameters
existingArchiveThe existing archive to add to.
dirThe directory to add. If empty, uses current directory.
recursiveIf true, include subdirectories recursively.
filtersQDir filters to apply when selecting files.
Returns
true if successful, false otherwise.

References JlCompress::addDir().


The documentation for this class was generated from the following files: