JlCompress Class Reference

Utility class for typical operations. More...

`#include <JlCompress.h>`

## Classes

class | Options

## Static Public Member Functions

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)
| Extract a single file.
static bool | compressFile (QuaZip *zip, QString fileName, QString fileDest)
| Compress a single file.
static bool | compressFile (QuaZip *zip, QString fileName, QString fileDest, const Options &options)
| Compress a single file.
static bool | compressSubDir (QuaZip *parentZip, QString dir, QString parentDir, bool recursive, QDir::Filters filters)
| Compress a subdirectory.
static bool | compressSubDir (QuaZip *parentZip, QString dir, QString parentDir, bool recursive, QDir::Filters filters, const Options &options)
| Compress a subdirectory.
static bool | removeFile (QStringList listFile)
| Remove some files.
static bool | compressFile (QString fileCompressed, QString file)
| Compress a single file.
static bool | compressFile (QString fileCompressed, QString file, const Options &options)
| Compress a single file with advanced options.
static bool | compressFiles (QString fileCompressed, QStringList files)
| Compress a list of files.
static bool | compressFiles (QString fileCompressed, QStringList files, const Options &options)
| Compress a list of files.
static bool | addFile (QString fileCompressed, QString file)
| Add a single file to an existing archive.
static bool | addFile (QString fileCompressed, QString file, const Options &options)
| Add a single file to an existing archive with advanced options.
static bool | addFiles (QString fileCompressed, QStringList files)
| Add a list of files to an existing archive.
static bool | addFiles (QString fileCompressed, QStringList files, const Options &options)
| Add a list of files to an existing archive.
static bool | addDir (QString fileCompressed, QString dir=QString(), bool recursive=true)
| Add a whole directory to an existing archive.
static bool | addDir (QString fileCompressed, QString dir, bool recursive, QDir::Filters filters)
| Add a whole directory to an existing archive.
static bool | addDir (QString fileCompressed, QString dir, bool recursive, QDir::Filters filters, const Options &options)
| Add a whole directory to an existing archive.
static bool | compressDir (QString fileCompressed, QString dir=QString(), bool recursive=true)
| Compress a whole directory.
static bool | compressDir (QString fileCompressed, QString dir, bool recursive, QDir::Filters filters)
| Compress a whole directory.
static bool | compressDir (QString fileCompressed, QString dir, bool recursive, QDir::Filters filters, const Options &options)
| Compress a whole directory.
static QString | extractFile (QString fileCompressed, QString fileName, QString fileDest=QString())
| Extract a single file.
static QStringList | extractFiles (QString fileCompressed, QStringList files, QString dir=QString())
| Extract a list of files.
static QStringList | extractDir (QString fileCompressed, QString dir=QString())
| Extract a whole archive.
static QStringList | extractDir (QString fileCompressed, QuazipTextCodec *fileNameCodec, QString dir=QString())
| Extract a whole archive.
static QString | extractFile (QString fileCompressed, QString fileName, QString fileDest, const QByteArray &password)
| Extract a single file with password.
static QStringList | extractFiles (QString fileCompressed, QStringList files, QString dir, const QByteArray &password)
| Extract a list of files with password.
static QStringList | extractDir (QString fileCompressed, QString dir, const QByteArray &password)
| Extract a whole archive with password.
static QStringList | getFileList (QString fileCompressed)
| Get the file list.
static QString | extractFile (QIODevice *ioDevice, QString fileName, QString fileDest=QString())
| Extract a single file.
static QStringList | extractFiles (QIODevice *ioDevice, QStringList files, QString dir=QString())
| Extract a list of files.
static QStringList | extractDir (QIODevice *ioDevice, QString dir=QString())
| Extract a whole archive.
static QStringList | extractDir (QIODevice *ioDevice, QuazipTextCodec *fileNameCodec, QString dir=QString())
| Extract a whole archive.
static QStringList | getFileList (QIODevice *ioDevice)
| Get the file list.

## Detailed Description

Utility class for typical operations.

This class contains a number of useful static functions to perform simple operations, such as mass ZIP packing or extraction.

## Member Function Documentation

## extractFile() [1/4]

bool JlCompress::extractFile | ( | QuaZip * | zip,
|  | QString | fileName,
|  | QString | fileDest )

static

Extract a single file.

Parameters

  zip | The opened zip archive to extract from.
  fileName | The full name of the file to extract.
  fileDest | The full path to the destination file.

Returns
  true if success, false otherwise.

## compressFile() [1/4]

bool JlCompress::compressFile | ( | QuaZip * | zip,
|  | QString | fileName,
|  | QString | fileDest )

static

Compress a single file.

Parameters

  zip | Opened zip to compress the file to.
  fileName | The full path to the source file.
  fileDest | The full name of the file inside the archive.

Returns
  true if success, false otherwise.

References compressFile().

Referenced by addFiles(), compressFile(), compressFile(), compressFile(), QuaCompress::compressFile(), compressFiles(), and compressSubDir().

## compressFile() [2/4]

bool JlCompress::compressFile | ( | QuaZip * | zip,
|  | QString | fileName,
|  | QString | fileDest,
|  | const Options & | options )

static

Compress a single file.

Parameters

  zip | Opened zip to compress the file to.
  fileName | The full path to the source file.
  fileDest | The full name of the file inside the archive.
  options | Options for fixed file timestamp, compression level, encryption..

Returns
  true if success, false otherwise.

References QuaZipFile::close(), QuaZip::getMode(), QuaZipFile::getZipError(), QuaZip::mdAdd, QuaZip::mdAppend, QuaZip::mdCreate, and QuaZipFile::open().

## compressSubDir() [1/2]

bool JlCompress::compressSubDir | ( | QuaZip * | parentZip,
|  | QString | dir,
|  | QString | parentDir,
|  | bool | recursive,
|  | QDir::Filters | filters )

static

Compress a subdirectory.

Parameters

  parentZip | Opened zip containing the parent directory.
  dir | The full path to the directory to pack.
  parentDir | The full path to the directory corresponding to the root of the ZIP.
  recursive | Whether to pack sub-directories as well or only files.
  filters | what to pack, filters are applied both when searching for subdirs (if packing recursively) and when looking for files to pack

Returns
  true if success, false otherwise.

References compressSubDir().

Referenced by addDir(), compressDir(), compressSubDir(), and compressSubDir().

## compressSubDir() [2/2]

bool JlCompress::compressSubDir | ( | QuaZip * | parentZip,
|  | QString | dir,
|  | QString | parentDir,
|  | bool | recursive,
|  | QDir::Filters | filters,
|  | const Options & | options )

static

Compress a subdirectory.

Parameters

  parentZip | Opened zip containing the parent directory.
  dir | The full path to the directory to pack.
  parentDir | The full path to the directory corresponding to the root of the ZIP.
  recursive | Whether to pack sub-directories as well or only
  filters | what to pack, filters are applied both when searching for subdirs (if packing recursively) and when looking for files to pack
  options | Options for fixed file timestamp, compression level, encryption.. files.

Returns
  true if success, false otherwise.

References QuaZipFile::close(), compressFile(), compressSubDir(), QuaZip::getMode(), QuaZip::getZipName(), QuaZip::mdAdd, QuaZip::mdAppend, QuaZip::mdCreate, and QuaZipFile::open().

## removeFile()

bool JlCompress::removeFile | ( | QStringList | listFile | ) |

static

Remove some files.

Parameters

  listFile | The list of files to remove.

Returns
  true if success, false otherwise.

## compressFile() [3/4]

bool JlCompress::compressFile | ( | QString | fileCompressed,
|  | QString | file )

static

Compress a single file.

Parameters

  fileCompressed | The name of the archive to create.
  file | The file to compress.

Returns
  true if success, false otherwise.

References compressFile().

## compressFile() [4/4]

bool JlCompress::compressFile | ( | QString | fileCompressed,
|  | QString | file,
|  | const Options & | options )

static

Compress a single file with advanced options.

Parameters

  fileCompressed | The name of the archive to create.
  file | The file to compress.
  options | Options for fixed file timestamp, compression level, encryption..

Returns
  true if success, false otherwise.

References QuaZip::close(), compressFile(), QuaZip::getZipError(), QuaZip::mdCreate, QuaZip::open(), and QuaZip::setUtf8Enabled().

## compressFiles() [1/2]

bool JlCompress::compressFiles | ( | QString | fileCompressed,
|  | QStringList | files )

static

Compress a list of files.

Parameters

  fileCompressed | The name of the archive to create.
  files | The file list to compress.

Returns
  true if success, false otherwise.

References compressFiles().

Referenced by compressFiles(), and QuaCompress::compressFiles().

## compressFiles() [2/2]

bool JlCompress::compressFiles | ( | QString | fileCompressed,
|  | QStringList | files,
|  | const Options & | options )

static

Compress a list of files.

Parameters

  fileCompressed | The name of the archive to create.
  files | The file list to compress.
  options | Options for fixed file timestamp, compression level, encryption..

Returns
  true if success, false otherwise.

References QuaZip::close(), compressFile(), QuaZip::getZipError(), QuaZip::mdCreate, QuaZip::open(), and QuaZip::setUtf8Enabled().

## addFile() [1/2]

bool JlCompress::addFile | ( | QString | fileCompressed,
|  | QString | file )

static

Add a single file to an existing archive.

The file is stored in the archive using only its filename, without any directory path components.

Parameters

  fileCompressed | The name of the existing archive.
  file | The file to add.

Returns
  true if success, false otherwise.

References addFiles().

Referenced by QuaCompress::addFile().

## addFile() [2/2]

bool JlCompress::addFile | ( | QString | fileCompressed,
|  | QString | file,
|  | const Options & | options )

static

Add a single file to an existing archive with advanced options.

The file is stored in the archive using only its filename, without any directory path components.

Parameters

  fileCompressed | The name of the existing archive.
  file | The file to add.
  options | Options for fixed file timestamp, compression level, encryption..

Returns
  true if success, false otherwise.

References addFiles().

## addFiles() [1/2]

bool JlCompress::addFiles | ( | QString | fileCompressed,
|  | QStringList | files )

static

Add a list of files to an existing archive.

Each file is stored in the archive using only its filename, without any directory path components.

Warning
  The archive must already exist, or the operation will fail.
  Directories will cause the operation to fail.
  Files with the same basename will create duplicate entries in the archive since only the filename is used. ZIP format permits multiple files with identical names.

Parameters

  fileCompressed | The name of the existing archive.
  files | The file list to add.

Returns
  true if success, false otherwise.

References addFiles().

Referenced by addFile(), addFile(), addFiles(), and QuaCompress::addFiles().

## addFiles() [2/2]

bool JlCompress::addFiles | ( | QString | fileCompressed,
|  | QStringList | files,
|  | const Options & | options )

static

Add a list of files to an existing archive.

Each file is stored in the archive using only its filename, without any directory path components.

Warning
  The archive must already exist, or the operation will fail.
  Directories will cause the operation to fail.
  Files with the same basename will create duplicate entries in the archive since only the filename is used. ZIP format permits multiple files with identical names.
  On failure, the archive may be left in a partially modified state with some files already added.
  The UTF-8 flag in options MUST match the existing archive's encoding. QuaZip does not auto-detect this. If the archive was created with UTF-8 enabled, you must also enable UTF-8 when adding files, otherwise the archive will have inconsistent filename encodings.

Parameters

  fileCompressed | The name of the existing archive.
  files | The file list to add.
  options | Options for fixed file timestamp, compression level, encryption..

Returns
  true if success, false otherwise.

References QuaZip::close(), compressFile(), QuaZip::getZipError(), QuaZip::mdAdd, QuaZip::open(), and QuaZip::setUtf8Enabled().

## addDir() [1/3]

bool JlCompress::addDir | ( | QString | fileCompressed,
|  | QString | dir = QString(),
|  | bool | recursive = true )

static

Add a whole directory to an existing archive.

Does not add hidden files. See addDir(QString, QString, bool, QDir::Filters).

The relative directory structure is preserved in the archive.

Parameters

  fileCompressed | The name of the existing archive.
  dir | The directory to add.
  recursive | Whether to add the subdirectories as well, or just regular files.

Returns
  true if success, false otherwise.

References addDir().

Referenced by addDir(), addDir(), and QuaCompress::addDir().

## addDir() [2/3]

bool JlCompress::addDir | ( | QString | fileCompressed,
|  | QString | dir,
|  | bool | recursive,
|  | QDir::Filters | filters )

static

Add a whole directory to an existing archive.

Unless filters are specified explicitly, adds only regular non-hidden files (and subdirs, if recursive is true). If filters are specified, they are OR-combined with QDir::AllDirs|QDir::NoDotAndDotDot when searching for dirs and with QDir::Files when searching for files.

The relative directory structure is preserved in the archive.

Parameters

  fileCompressed | The name of the existing archive.
  dir | The directory to add.
  recursive | Whether to add the subdirectories as well, or just regular files.
  filters | What to add, filters are applied both when searching for subdirs (if adding recursively) and when looking for files to add.

Returns
  true if success, false otherwise.

References addDir().

## addDir() [3/3]

bool JlCompress::addDir | ( | QString | fileCompressed,
|  | QString | dir,
|  | bool | recursive,
|  | QDir::Filters | filters,
|  | const Options & | options )

static

Add a whole directory to an existing archive.

Unless filters are specified explicitly, adds only regular non-hidden files (and subdirs, if recursive is true). If filters are specified, they are OR-combined with QDir::AllDirs|QDir::NoDotAndDotDot when searching for dirs and with QDir::Files when searching for files.

The relative directory structure is preserved in the archive.

Warning
  The archive must already exist, or the operation will fail.
  On failure, the archive may be left in a partially modified state with some files/directories already added.
  The UTF-8 flag in options MUST match the existing archive's encoding. QuaZip does not auto-detect this. If the archive was created with UTF-8 enabled, you must also enable UTF-8 when adding files, otherwise the archive will have inconsistent filename encodings.

Parameters

  fileCompressed | The name of the existing archive.
  dir | The directory to add.
  recursive | Whether to add the subdirectories as well, or just regular files.
  filters | What to add, filters are applied both when searching for subdirs (if adding recursively) and when looking for files to add.
  options | Options for fixed file timestamp, compression level, encryption..

Returns
  true if success, false otherwise.

References QuaZip::close(), compressSubDir(), QuaZip::getZipError(), QuaZip::mdAdd, QuaZip::open(), and QuaZip::setUtf8Enabled().

## compressDir() [1/3]

bool JlCompress::compressDir | ( | QString | fileCompressed,
|  | QString | dir = QString(),
|  | bool | recursive = true )

static

Compress a whole directory.

Does not compress hidden files. See compressDir(QString, QString, bool, QDir::Filters).

Parameters

  fileCompressed | The name of the archive to create.
  dir | The directory to compress.
  recursive | Whether to pack the subdirectories as well, or just regular files.

Returns
  true if success, false otherwise.

References compressDir().

Referenced by compressDir(), compressDir(), and QuaCompress::compressDir().

## compressDir() [2/3]

bool JlCompress::compressDir | ( | QString | fileCompressed,
|  | QString | dir,
|  | bool | recursive,
|  | QDir::Filters | filters )

static

Compress a whole directory.

Unless filters are specified explicitly, packs only regular non-hidden files (and subdirs, if `recursive` is true). If filters are specified, they are OR-combined with QDir::AllDirs|QDir::NoDotAndDotDot when searching for dirs and with QDir::Files when searching for files.

Parameters

  fileCompressed | path to the resulting archive
  dir | path to the directory being compressed
  recursive | if true, then the subdirectories are packed as well
  filters | what to pack, filters are applied both when searching for subdirs (if packing recursively) and when looking for files to pack

Returns
  true on success, false otherwise

References compressDir().

## compressDir() [3/3]

bool JlCompress::compressDir | ( | QString | fileCompressed,
|  | QString | dir,
|  | bool | recursive,
|  | QDir::Filters | filters,
|  | const Options & | options )

static

Compress a whole directory.

Unless filters are specified explicitly, packs only regular non-hidden files (and subdirs, if `recursive` is true). If filters are specified, they are OR-combined with QDir::AllDirs|QDir::NoDotAndDotDot when searching for dirs and with QDir::Files when searching for files.

Parameters

  fileCompressed | path to the resulting archive
  dir | path to the directory being compressed
  recursive | if true, then the subdirectories are packed as well
  filters | what to pack, filters are applied both when searching for subdirs (if packing recursively) and when looking for files to pack
  options | Options for fixed file timestamp, compression level, encryption..

Returns
  true on success, false otherwise

References QuaZip::close(), compressSubDir(), QuaZip::getZipError(), QuaZip::mdCreate, QuaZip::open(), and QuaZip::setUtf8Enabled().

## extractFile() [2/4]

QString JlCompress::extractFile | ( | QString | fileCompressed,
|  | QString | fileName,
|  | QString | fileDest = QString() )

static

Extract a single file.

Parameters

  fileCompressed | The name of the archive.
  fileName | The file to extract.
  fileDest | The destination file, assumed to be identical to file if left empty.

Returns
  The list of the full paths of the files extracted, empty on failure.

## extractFiles() [1/3]

QStringList JlCompress::extractFiles | ( | QString | fileCompressed,
|  | QStringList | files,
|  | QString | dir = QString() )

static

Extract a list of files.

Parameters

  fileCompressed | The name of the archive.
  files | The file list to extract.
  dir | The directory to put the files to, the current directory if left empty.

Returns
  The list of the full paths of the files extracted, empty on failure.

## extractDir() [1/5]

QStringList JlCompress::extractDir | ( | QString | fileCompressed,
|  | QString | dir = QString() )

static

Extract a whole archive.

Parameters

  fileCompressed | The name of the archive.
  dir | The directory to extract to, the current directory if left empty.

Returns
  The list of the full paths of the files extracted, empty on failure.

## extractDir() [2/5]

QStringList JlCompress::extractDir | ( | QString | fileCompressed,
|  | QuazipTextCodec * | fileNameCodec,
|  | QString | dir = QString() )

static

Extract a whole archive.

Parameters

  fileCompressed | The name of the archive.
  fileNameCodec | The codec to use for file names.
  dir | The directory to extract to, the current directory if left empty.

Returns
  The list of the full paths of the files extracted, empty on failure.

References QuaZip::setFileNameCodec().

## extractFile() [3/4]

QString JlCompress::extractFile | ( | QString | fileCompressed,
|  | QString | fileName,
|  | QString | fileDest,
|  | const QByteArray & | password )

static

Extract a single file with password.

Parameters

  fileCompressed | The name of the archive.
  fileName | The file to extract.
  fileDest | The destination file, assumed to be identical to fileName if left empty.
  password | Password for decryption (empty for no encryption).

Returns
  The full path of the extracted file, empty on failure.

## extractFiles() [2/3]

QStringList JlCompress::extractFiles | ( | QString | fileCompressed,
|  | QStringList | files,
|  | QString | dir,
|  | const QByteArray & | password )

static

Extract a list of files with password.

Parameters

  fileCompressed | The name of the archive.
  files | The file list to extract.
  dir | The directory to put the files to, the current directory if left empty.
  password | Password for decryption (empty for no encryption).

Returns
  The list of the full paths of the files extracted, empty on failure.

## extractDir() [3/5]

QStringList JlCompress::extractDir | ( | QString | fileCompressed,
|  | QString | dir,
|  | const QByteArray & | password )

static

Extract a whole archive with password.

Parameters

  fileCompressed | The name of the archive.
  dir | The directory to extract to, the current directory if left empty.
  password | Password for decryption (empty for no encryption).

Returns
  The list of the full paths of the files extracted, empty on failure.

## getFileList() [1/2]

QStringList JlCompress::getFileList | ( | QString | fileCompressed | ) |

static

Get the file list.

Returns
  The list of the files in the archive, or, more precisely, the list of the entries, including both files and directories if they are present separately.

## extractFile() [4/4]

QString JlCompress::extractFile | ( | QIODevice * | ioDevice,
|  | QString | fileName,
|  | QString | fileDest = QString() )

static

Extract a single file.

Parameters

  ioDevice | pointer to device with compressed data.
  fileName | The file to extract.
  fileDest | The destination file, assumed to be identical to file if left empty.

Returns
  The list of the full paths of the files extracted, empty on failure.

## extractFiles() [3/3]

QStringList JlCompress::extractFiles | ( | QIODevice * | ioDevice,
|  | QStringList | files,
|  | QString | dir = QString() )

static

Extract a list of files.

Parameters

  ioDevice | pointer to device with compressed data.
  files | The file list to extract.
  dir | The directory to put the files to, the current directory if left empty.

Returns
  The list of the full paths of the files extracted, empty on failure.

## extractDir() [4/5]

QStringList JlCompress::extractDir | ( | QIODevice * | ioDevice,
|  | QString | dir = QString() )

static

Extract a whole archive.

Parameters

  ioDevice | pointer to device with compressed data.
  dir | The directory to extract to, the current directory if left empty.

Returns
  The list of the full paths of the files extracted, empty on failure.

## extractDir() [5/5]

QStringList JlCompress::extractDir | ( | QIODevice * | ioDevice,
|  | QuazipTextCodec * | fileNameCodec,
|  | QString | dir = QString() )

static

Extract a whole archive.

Parameters

  ioDevice | pointer to device with compressed data.
  fileNameCodec | The codec to use for file names.
  dir | The directory to extract to, the current directory if left empty.

Returns
  The list of the full paths of the files extracted, empty on failure.

References QuaZip::setFileNameCodec().

## getFileList() [2/2]

QStringList JlCompress::getFileList | ( | QIODevice * | ioDevice | ) |

static

Get the file list.

Returns
  The list of the files in the archive, or, more precisely, the list of the entries, including both files and directories if they are present separately.

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

- quazip/JlCompress.h
- quazip/JlCompress.cpp