ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
QuaZipDir Class Reference

Provides ZIP archive navigation. More...

#include <quazipdir.h>

Public Member Functions

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

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.

Definition at line 55 of file quazipdir.h.

Constructor & Destructor Documentation

◆ QuaZipDir() [1/2]

QuaZipDir::QuaZipDir ( const QuaZipDir that)

The copy constructor.

Definition at line 61 of file quazipdir.cpp.

Referenced by exists().

◆ QuaZipDir() [2/2]

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 "/".

Definition at line 63 of file quazipdir.cpp.

◆ ~QuaZipDir()

QuaZipDir::~QuaZipDir ( )

Destructor.

Definition at line 68 of file quazipdir.cpp.

Member Function Documentation

◆ caseSensitivity()

QuaZip::CaseSensitivity QuaZipDir::caseSensitivity ( ) const

Returns the current case sensitivity mode.

Definition at line 81 of file quazipdir.cpp.

Referenced by setCaseSensitivity().

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

Definition at line 85 of file quazipdir.cpp.

References cd(), dirName(), exists(), isRoot(), path(), and QtCompat::SkipEmptyParts.

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

◆ cdUp()

bool QuaZipDir::cdUp ( )

Goes up.

Definition at line 142 of file quazipdir.cpp.

References cd().

◆ count()

uint QuaZipDir::count ( ) const

Returns the number of entries in the directory.

Definition at line 144 of file quazipdir.cpp.

References entryList().

◆ dirName()

QString QuaZipDir::dirName ( ) const

Returns the current directory name.

The name doesn't include the path.

Definition at line 146 of file quazipdir.cpp.

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.

Definition at line 366 of file quazipdir.cpp.

References nameFilters(), and result.

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

Definition at line 376 of file quazipdir.cpp.

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.

Definition at line 381 of file quazipdir.cpp.

References nameFilters(), and result.

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

Definition at line 392 of file quazipdir.cpp.

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.

Definition at line 397 of file quazipdir.cpp.

References nameFilters(), and result.

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

Definition at line 407 of file quazipdir.cpp.

References entryList().

◆ exists() [1/2]

bool QuaZipDir::exists ( ) const

Return true if the directory pointed by this QuaZipDir exists.

Definition at line 455 of file quazipdir.cpp.

References QuaZipDir().

Referenced by cd().

◆ exists() [2/2]

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.

Definition at line 412 of file quazipdir.cpp.

References cd(), QuaZip::convertCaseSensitivity(), entryList(), exists(), filePath(), and isRoot().

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.

Definition at line 457 of file quazipdir.cpp.

Referenced by exists().

◆ filter()

QDir::Filters QuaZipDir::filter ( )

Returns the default filter.

Definition at line 461 of file quazipdir.cpp.

◆ 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 '/'.

Definition at line 463 of file quazipdir.cpp.

Referenced by cd(), and exists().

◆ nameFilters()

QStringList QuaZipDir::nameFilters ( ) const

Return the default name filter.

Definition at line 465 of file quazipdir.cpp.

Referenced by entryInfoList(), entryInfoList64(), entryList(), and setNameFilters().

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

Definition at line 77 of file quazipdir.h.

References cloudViewer::utility::operator==().

◆ operator=()

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

operator==

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

Definition at line 74 of file quazipdir.cpp.

◆ operator==()

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

The assignment operator.

Definition at line 70 of file quazipdir.cpp.

◆ operator[]()

QString QuaZipDir::operator[] ( int  pos) const

Returns the name of the entry at the specified position.

Definition at line 79 of file quazipdir.cpp.

References entryList().

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

Definition at line 467 of file quazipdir.cpp.

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.

Definition at line 469 of file quazipdir.cpp.

◆ setCaseSensitivity()

void QuaZipDir::setCaseSensitivity ( QuaZip::CaseSensitivity  caseSensitivity)

Sets the default case sensitivity mode.

Definition at line 473 of file quazipdir.cpp.

References caseSensitivity().

◆ setFilter()

void QuaZipDir::setFilter ( QDir::Filters  filters)

Sets the default filter.

Definition at line 477 of file quazipdir.cpp.

◆ setNameFilters()

void QuaZipDir::setNameFilters ( const QStringList &  nameFilters)

Sets the default name filter.

Definition at line 479 of file quazipdir.cpp.

References nameFilters().

◆ 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).

Definition at line 483 of file quazipdir.cpp.

References path().

◆ setSorting()

void QuaZipDir::setSorting ( QDir::SortFlags  sort)

Sets the default sorting mode.

Definition at line 494 of file quazipdir.cpp.

◆ sorting()

QDir::SortFlags QuaZipDir::sorting ( ) const

Returns the default sorting mode.

Definition at line 496 of file quazipdir.cpp.


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