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!=
QuaZipDir & | operator= (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< QuaZipFileInfo > | entryInfoList (const QStringList &nameFilters, QDir::Filters filters=QDir::NoFilter, QDir::SortFlags sort=QDir::NoSort) const
| Returns the list of the entries in the directory.
QList< QuaZipFileInfo > | entryInfoList (QDir::Filters filters=QDir::NoFilter, QDir::SortFlags sort=QDir::NoSort) const
| Returns the list of the entries in the directory.
QList< QuaZipFileInfo64 > | 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.
QList< QuaZipFileInfo64 > | entryInfoList64 (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:

- In the cd() function.
- In the constructor.
- In the exists() function.
- In the relativePath() function.

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.

References operator==(), and QuaZipDir().

## 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.

References caseSensitivity(), cd(), cdUp(), count(), dirName(), entryInfoList(), entryInfoList64(), entryList(), exists(), filePath(), filter(), isRoot(), nameFilters(), operator[](), path(), QuaZipDir(), relativeFilePath(), setCaseSensitivity(), setFilter(), setNameFilters(), setPath(), setSorting(), and sorting().

## 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(), dirName(), exists(), isRoot(), path(), and QuaZipDir().

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

## dirName()

QString QuaZipDir::dirName | ( |  | ) | const

Returns the current directory name.

The name doesn't include the path.

Referenced by cd(), and operator=().

## 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

  nameFilters | The list of file patterns to list, uses the same syntax as QDir.
  filters | The entry type filters, only Files and Dirs are accepted.
  sort | Sorting mode.

References nameFilters().

Referenced by entryInfoList(), and operator=().

## 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

  nameFilters | The list of file patterns to list, uses the same syntax as QDir.
  filters | The entry type filters, only Files and Dirs are accepted.
  sort | Sorting mode.

References nameFilters().

Referenced by entryInfoList64(), and operator=().

## 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(), operator=(), 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(), QuaZip::convertCaseSensitivity(), entryList(), exists(), filePath(), isRoot(), and QuaZipDir().

Referenced by exists(), and operator=().

## filePath()

QString QuaZipDir::filePath | ( | const QString & | fileName | ) | const

Returns the full path to the specified file.

Doesn't check if the file actually exists.

Referenced by exists(), and operator=().

## 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(), exists(), and operator=().

## 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(), operator=(), 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

  fileName | The path to the file, should start with "/" if relative to the archive root.

Returns
  Path relative to the current dir.

Referenced by operator=().

## 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 path().

Referenced by operator=().

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

- quazip/quazipdir.h
- quazip/quazipdir.cpp