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

Provides ZIP archive navigation. More...

#include <quazipdir.h>

Public Member Functions

 QuaZipDir (const QuaZipDir &that)
 The copy constructor.
 
 QuaZipDir (QuaZip *zip, const QString &dir=QString())
 Constructs a QuaZipDir instance pointing to the specified directory.
 
 ~QuaZipDir ()
 Destructor.
 
bool operator== (const QuaZipDir &that)
 The assignment operator.
 
bool operator!= (const QuaZipDir &that)
 operator!=
 
QuaZipDiroperator= (const QuaZipDir &that)
 operator==
 
QString operator[] (int pos) const
 Returns the name of the entry at the specified position.
 
QuaZip::CaseSensitivity caseSensitivity () const
 Returns the current case sensitivity mode.
 
bool cd (const QString &dirName)
 Changes the 'current' directory.
 
bool cdUp ()
 Goes up.
 
uint count () const
 Returns the number of entries in the directory.
 
QString dirName () const
 Returns the current directory name.
 
QList< QuaZipFileInfoentryInfoList (const QStringList &nameFilters, QDir::Filters filters=QDir::NoFilter, QDir::SortFlags sort=QDir::NoSort) const
 Returns the list of the entries in the directory.
 
QList< QuaZipFileInfoentryInfoList (QDir::Filters filters=QDir::NoFilter, QDir::SortFlags sort=QDir::NoSort) const
 Returns the list of the entries in the directory.
 
QList< QuaZipFileInfo64entryInfoList64 (const QStringList &nameFilters, QDir::Filters filters=QDir::NoFilter, QDir::SortFlags sort=QDir::NoSort) const
 Returns the list of the entries in the directory with zip64 support.
 
QList< QuaZipFileInfo64entryInfoList64 (QDir::Filters filters=QDir::NoFilter, QDir::SortFlags sort=QDir::NoSort) const
 Returns the list of the entries in the directory with zip64 support.
 
QStringList entryList (const QStringList &nameFilters, QDir::Filters filters=QDir::NoFilter, QDir::SortFlags sort=QDir::NoSort) const
 Returns the list of the entry names in the directory.
 
QStringList entryList (QDir::Filters filters=QDir::NoFilter, QDir::SortFlags sort=QDir::NoSort) const
 Returns the list of the entry names in the directory.
 
bool exists (const QString &fileName) const
 Returns true if the entry with the specified name exists.
 
bool exists () const
 Return true if the directory pointed by this QuaZipDir exists.
 
QString filePath (const QString &fileName) const
 Returns the full path to the specified file.
 
QDir::Filters filter ()
 Returns the default filter.
 
bool isRoot () const
 Returns if the QuaZipDir points to the root of the archive.
 
QStringList nameFilters () const
 Return the default name filter.
 
QString path () const
 Returns the path to the current dir.
 
QString relativeFilePath (const QString &fileName) const
 Returns the path to the specified file relative to the current dir.
 
void setCaseSensitivity (QuaZip::CaseSensitivity caseSensitivity)
 Sets the default case sensitivity mode.
 
void setFilter (QDir::Filters filters)
 Sets the default filter.
 
void setNameFilters (const QStringList &nameFilters)
 Sets the default name filter.
 
void setPath (const QString &path)
 Goes to the specified path.
 
void setSorting (QDir::SortFlags sort)
 Sets the default sorting mode.
 
QDir::SortFlags sorting () const
 Returns the default sorting mode.
 

Detailed Description

Provides ZIP archive navigation.

This class is modelled after QDir, and is designed to provide similar features for ZIP archives.

The only significant difference from QDir is that the root path is not '/', but an empty string since that's how the file paths are stored in the archive. However, QuaZipDir understands the paths starting with '/'. It is important in a few places:

Note that since ZIP uses '/' on all platforms, the '\' separator is not supported.

Constructor & Destructor Documentation

◆ QuaZipDir()

QuaZipDir::QuaZipDir ( QuaZip zip,
const QString dir = QString() 
)

Constructs a QuaZipDir instance pointing to the specified directory.

If dir is not specified, points to the root of the archive. The same happens if the dir is "/".

Member Function Documentation

◆ operator!=()

bool QuaZipDir::operator!= ( const QuaZipDir that)
inline

operator!=

Returns
true if either this and that use different QuaZip instances or if they point to different directories.

◆ operator=()

QuaZipDir & QuaZipDir::operator= ( const QuaZipDir that)
default

operator==

Returns
true if both this and that use the same QuaZip instance and point to the same directory.

◆ cd()

bool QuaZipDir::cd ( const QString dirName)

Changes the 'current' directory.

If the path starts with '/', it is interpreted as an absolute path from the root of the archive. Otherwise, it is interpreted as a path relative to the current directory as was set by the previous cd() or the constructor.

Note that the subsequent path() call will not return a path starting with '/' in all cases.

References cd(), QString::chop(), QByteArray::constData(), QString::contains(), dirName(), QString::endsWith(), exists(), isRoot(), path(), QString::split(), QString::startsWith(), and QString::toUtf8().

Referenced by cd(), cdUp(), and exists().

◆ dirName()

QString QuaZipDir::dirName ( ) const

Returns the current directory name.

The name doesn't include the path.

References QDir::dirName().

Referenced by cd().

◆ entryInfoList() [1/2]

QList< QuaZipFileInfo > QuaZipDir::entryInfoList ( const QStringList nameFilters,
QDir::Filters  filters = QDir::NoFilter,
QDir::SortFlags  sort = QDir::NoSort 
) const

Returns the list of the entries in the directory.

Parameters
nameFiltersThe list of file patterns to list, uses the same syntax as QDir.
filtersThe entry type filters, only Files and Dirs are accepted.
sortSorting mode.

References nameFilters().

Referenced by entryInfoList().

◆ entryInfoList() [2/2]

QList< QuaZipFileInfo > QuaZipDir::entryInfoList ( QDir::Filters  filters = QDir::NoFilter,
QDir::SortFlags  sort = QDir::NoSort 
) const

Returns the list of the entries in the directory.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

The same as entryInfoList(QStringList(), filters, sort).

References entryInfoList().

◆ entryInfoList64() [1/2]

QList< QuaZipFileInfo64 > QuaZipDir::entryInfoList64 ( const QStringList nameFilters,
QDir::Filters  filters = QDir::NoFilter,
QDir::SortFlags  sort = QDir::NoSort 
) const

Returns the list of the entries in the directory with zip64 support.

Parameters
nameFiltersThe list of file patterns to list, uses the same syntax as QDir.
filtersThe entry type filters, only Files and Dirs are accepted.
sortSorting mode.

References nameFilters().

Referenced by entryInfoList64().

◆ entryInfoList64() [2/2]

QList< QuaZipFileInfo64 > QuaZipDir::entryInfoList64 ( QDir::Filters  filters = QDir::NoFilter,
QDir::SortFlags  sort = QDir::NoSort 
) const

Returns the list of the entries in the directory with zip64 support.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

The same as entryInfoList64(QStringList(), filters, sort).

References entryInfoList64().

◆ entryList() [1/2]

QStringList QuaZipDir::entryList ( const QStringList nameFilters,
QDir::Filters  filters = QDir::NoFilter,
QDir::SortFlags  sort = QDir::NoSort 
) const

Returns the list of the entry names in the directory.

The same as entryInfoList(nameFilters, filters, sort), but only returns entry names.

References nameFilters().

Referenced by count(), entryList(), exists(), and operator[]().

◆ entryList() [2/2]

QStringList QuaZipDir::entryList ( QDir::Filters  filters = QDir::NoFilter,
QDir::SortFlags  sort = QDir::NoSort 
) const

Returns the list of the entry names in the directory.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

The same as entryList(QStringList(), filters, sort).

References entryList().

◆ exists()

bool QuaZipDir::exists ( const QString fileName) const

Returns true if the entry with the specified name exists.

The ".." is considered to exist if the current directory is not root. The "." and "/" are considered to always exist. Paths starting with "/" are relative to the archive root, other paths are relative to the current dir.

References cd(), QString::chop(), QByteArray::constData(), QStringList::contains(), QString::contains(), QuaZip::convertCaseSensitivity(), QString::endsWith(), entryList(), exists(), QFileInfo::fileName(), filePath(), QString::isEmpty(), isRoot(), QFileInfo::path(), and QString::toUtf8().

Referenced by exists().

◆ filePath()

QString QuaZipDir::filePath ( const QString fileName) const

Returns the full path to the specified file.

Doesn't check if the file actually exists.

References QDir::filePath().

Referenced by exists().

◆ isRoot()

bool QuaZipDir::isRoot ( ) const

Returns if the QuaZipDir points to the root of the archive.

Not that the root path is the empty string, not '/'.

Referenced by cd(), and exists().

◆ path()

QString QuaZipDir::path ( ) const

Returns the path to the current dir.

The path never starts with '/', and the root path is an empty string.

Referenced by cd(), and setPath().

◆ relativeFilePath()

QString QuaZipDir::relativeFilePath ( const QString fileName) const

Returns the path to the specified file relative to the current dir.

This function is mostly useless, provided only for the sake of completeness.

Parameters
fileNameThe path to the file, should start with "/" if relative to the archive root.
Returns
Path relative to the current dir.

References QDir::relativeFilePath().

◆ setPath()

void QuaZipDir::setPath ( const QString path)

Goes to the specified path.

The difference from cd() is that this function never checks if the path actually exists and doesn't use relative paths, so it's possible to go to the root directory with setPath("").

Note that this function still chops the trailing and/or leading '/' and treats a single '/' as the root path (path() will still return an empty string).

References QString::chop(), QString::endsWith(), QString::mid(), path(), and QString::startsWith().


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