QuaZip quazip-1-4
Static Public Member Functions | List of all members
JlCompress Class Reference

Utility class for typical operations. More...

#include <JlCompress.h>

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 compressFile (QuaZip *zip, QString fileName, QString fileDest)
 Compress a single file.
 
static bool compressSubDir (QuaZip *parentZip, QString dir, QString parentDir, bool recursive, QDir::Filters filters)
 Compress a subdirectory.
 
static bool extractFile (QuaZip *zip, QString fileName, QString fileDest)
 Extract a single file.
 
static bool removeFile (QStringList listFile)
 Remove some files.
 
static bool compressFile (QString fileCompressed, QString file)
 Compress a single file.
 
static bool compressFiles (QString fileCompressed, QStringList files)
 Compress a list of files.
 
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 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, QTextCodec *fileNameCodec, QString dir=QString())
 Extract a whole archive.
 
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, QTextCodec *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

◆ compressFile() [1/2]

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

Compress a single file.

Parameters
zipOpened zip to compress the file to.
fileNameThe full path to the source file.
fileDestThe full name of the file inside the archive.
Returns
true if success, false otherwise.

References QFileDevice::close(), QuaZipFile::close(), QFileInfo::dir(), QFile::encodeName(), QuaZip::getMode(), QuaZipFile::getZipError(), QuaZip::mdAdd, QuaZip::mdAppend, QuaZip::mdCreate, QuaZipFile::open(), QFile::open(), QDir::relativeFilePath(), QFile::setFileName(), and QIODevice::write().

Referenced by compressFile(), compressFiles(), and compressSubDir().

◆ compressSubDir()

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

Compress a subdirectory.

Parameters
parentZipOpened zip containing the parent directory.
dirThe full path to the directory to pack.
parentDirThe full path to the directory corresponding to the root of the ZIP.
recursiveWhether to pack sub-directories as well or only files.
Returns
true if success, false otherwise.

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

Referenced by compressDir(), and compressSubDir().

◆ extractFile() [1/3]

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

◆ removeFile()

bool JlCompress::removeFile ( QStringList  listFile)
static

Remove some files.

Parameters
listFileThe list of files to remove.
Returns
true if success, false otherwise.

References QList::at(), QList::count(), and QFile::remove().

Referenced by extractFile().

◆ compressFile() [2/2]

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

Compress a single file.

Parameters
fileCompressedThe name of the archive.
fileThe file to compress.
Returns
true if success, false otherwise.

References QuaZip::close(), compressFile(), QuaZip::getZipError(), QuaZip::mdCreate, QDir::mkpath(), QuaZip::open(), and QFile::remove().

◆ compressFiles()

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

Compress a list of files.

Parameters
fileCompressedThe name of the archive.
filesThe file list to compress.
Returns
true if success, false otherwise.

References QList::at(), QuaZip::close(), compressFile(), QFileInfo::exists(), QFileInfo::fileName(), QuaZip::getZipError(), QuaZip::mdCreate, QDir::mkpath(), QuaZip::open(), QFile::remove(), QFileInfo::setFile(), and QList::size().

◆ compressDir() [1/2]

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
fileCompressedThe name of the archive.
dirThe directory to compress.
recursiveWhether to pack the subdirectories as well, or just regular files.
Returns
true if success, false otherwise.

References compressDir(), and QDir::Filters.

Referenced by compressDir().

◆ compressDir() [2/2]

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
fileCompressedpath to the resulting archive
dirpath to the directory being compressed
recursiveif true, then the subdirectories are packed as well
filterswhat 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 QuaZip::close(), compressSubDir(), QuaZip::getZipError(), QuaZip::mdCreate, QDir::mkpath(), QuaZip::open(), and QFile::remove().

◆ extractFile() [2/3]

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

Extract a single file.

Parameters
fileCompressedThe name of the archive.
fileNameThe file to extract.
fileDestThe 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/2]

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

Extract a list of files.

Parameters
fileCompressedThe name of the archive.
filesThe file list to extract.
dirThe 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/4]

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

Extract a whole archive.

Parameters
fileCompressedThe name of the archive.
dirThe 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/4]

QStringList JlCompress::extractDir ( QString  fileCompressed,
QTextCodec fileNameCodec,
QString  dir = QString() 
)
static

Extract a whole archive.

Parameters
fileCompressedThe name of the archive.
fileNameCodecThe codec to use for file names.
dirThe 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() [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() [3/3]

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

Extract a single file.

Parameters
ioDevicepointer to device with compressed data.
fileNameThe file to extract.
fileDestThe 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() [2/2]

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

Extract a list of files.

Parameters
ioDevicepointer to device with compressed data.
filesThe file list to extract.
dirThe 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() [3/4]

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

Extract a whole archive.

Parameters
ioDevicepointer to device with compressed data.
dirThe 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() [4/4]

QStringList JlCompress::extractDir ( QIODevice ioDevice,
QTextCodec fileNameCodec,
QString  dir = QString() 
)
static

Extract a whole archive.

Parameters
ioDevicepointer to device with compressed data.
fileNameCodecThe codec to use for file names.
dirThe 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: