AbZip  1.5
Public Member Functions | Friends | List of all members
ZipDirIterator Class Reference

This class provides a search or extraction directory iterator. You can use this class to navigate entries within the archive. A starting root folder and file name fitlers can be applied. More...

#include <ZipDirIterator.h>

Public Member Functions

 ZipDirIterator (const AbZip &zip, const QString &path=QString(), AbZip::ZipOptions options=AbZip::None)
 Constructs a ZipDirIterator class ready to search the archive. You can pass options to decide how the directory should be iterated. More...
 
 ZipDirIterator (const AbZip &zip, const QString &path, const QStringList &nameFilters, AbZip::ZipOptions options=AbZip::None)
 Constructs a ZipDirIterator class ready to search the archive using nameFilters. You can pass options to decide how the directory should be iterated. More...
 
virtual ~ZipDirIterator ()
 Destroys the ZipDirIterator.
 
QString next ()
 next Advances the iterator to the next matching entry, and returns the file path of this new entry. If hasNext() returns false, this function does nothing, and returns a null QString. More...
 
bool hasNext () const
 hasNext Tests if their is at least one more matching entry found. More...
 
QString fileName () const
 fileName Returns the file name for the current entry, without the path prepended. More...
 
QString filePath () const
 filePath Returns the full file and path for the current entry. More...
 
ZipFileInfo fileInfo () const
 fileInfo Get a ZipFileInfo class containing all the information about the entry in the archive. More...
 
QString path () const
 path Returns the path only of the found entry. More...
 

Friends

class AbZipPrivate
 

Detailed Description

This class provides a search or extraction directory iterator. You can use this class to navigate entries within the archive. A starting root folder and file name fitlers can be applied.

Here is an example of how to find all PDF files within the archive.

    AbZip zip("myarchive.zip");

    ZipDirIterator it( zip, "", QStringList() << "*.pdf", AbZip::Recursive );
    while (it.hasNext())
    {
        it.next();
        ZipFileInfo info  = it.fileInfo();
        qDebug() << info.filePath << info.lastModifiedDate;
    }
    zip.close();

Constructor & Destructor Documentation

ZipDirIterator::ZipDirIterator ( const AbZip zip,
const QString &  path = QString(),
AbZip::ZipOptions  options = AbZip::None 
)

Constructs a ZipDirIterator class ready to search the archive. You can pass options to decide how the directory should be iterated.

Parameters
zipThe AbZip class
pathThe root folder within the archive to start iterating from.
optionsIterator options (Recursive, CaseSensitive, IgnoreFolders, IgnoreFiles)
ZipDirIterator::ZipDirIterator ( const AbZip zip,
const QString &  path,
const QStringList &  nameFilters,
AbZip::ZipOptions  options = AbZip::None 
)

Constructs a ZipDirIterator class ready to search the archive using nameFilters. You can pass options to decide how the directory should be iterated.

Parameters
zipThe AbZip class
pathThe root folder within the archive to start iterating from.
nameFiltersSet name filters to search for (e.g. "*.pdf" or "*abc*)
optionsIterator options (Recursive, CaseSensitive, IgnoreFolders, IgnoreFiles)

Member Function Documentation

QString ZipDirIterator::next ( )

next Advances the iterator to the next matching entry, and returns the file path of this new entry. If hasNext() returns false, this function does nothing, and returns a null QString.

Returns
Returns the full path and file name to the found entry.
bool ZipDirIterator::hasNext ( ) const

hasNext Tests if their is at least one more matching entry found.

Returns
Returns true if there is at least one more entry in the archive; otherwise, false is returned.
QString ZipDirIterator::fileName ( ) const

fileName Returns the file name for the current entry, without the path prepended.

Returns
A QString containing the file name only
QString ZipDirIterator::filePath ( ) const

filePath Returns the full file and path for the current entry.

Returns
A QString containing the full path and file name.
ZipFileInfo ZipDirIterator::fileInfo ( ) const

fileInfo Get a ZipFileInfo class containing all the information about the entry in the archive.

Returns
A ZipFileInfo class containing all the information about the file. This will contain empty data if no entry was found
QString ZipDirIterator::path ( ) const

path Returns the path only of the found entry.

Returns
A QString containing the path only.

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