Skip Navigation Links
Skip Navigation LinksHome > ZipArchive > How to Use > API Documentation

#include <FileFilter.h>

Inheritance diagram for ZipArchiveLib::CFileFilter:
Inheritance graph

Public Member Functions

 CFileFilter (bool bInverted=false)
 
bool Evaluate (LPCTSTR lpszParentDir, LPCTSTR lpszName, const CFileInfo &info)
 
virtual bool HandlesFile (const CFileInfo &info)
 
bool IsInverted () const
 
void SetInverted (bool bInverted=true)
 

Protected Member Functions

virtual bool Accept (LPCTSTR lpszParentDir, LPCTSTR lpszName, const CFileInfo &info)
 
virtual bool HandlesInversion () const
 

Protected Attributes

bool m_bInverted
 

Detailed Description

A base class for filters used in the directory enumeration process.

See Also
Compressing Data
CDirEnumerator::Start

Constructor & Destructor Documentation

ZipArchiveLib::CFileFilter::CFileFilter ( bool  bInverted = false)
inline

Initializes a new instance of the CFileFilter class.

Parameters
bInvertedSet to true to invert the behavior of the filter or to false for the normal behavior.
See Also
SetInverted

Member Function Documentation

virtual bool ZipArchiveLib::CFileFilter::Accept ( LPCTSTR  lpszParentDir,
LPCTSTR  lpszName,
const CFileInfo info 
)
inlineprotectedvirtual

This method is directly called by the Evaluate method during an enumeration process.

If this method returns true, the file will later be processed by the CDirEnumerator::Process method. If this method returns false for a directory, the directory is not enumerated at all.

The meaning of the return value can be reversed by the SetInverted method. If this filter handles the inversion internally, the return value from this method is not reversed by the Evaluate method.

Parameters
lpszParentDirThe parent directory containing the file to accept.
lpszNameThe name of the file to accept (without a path).
infoThe structure containing the information about the current file.
Returns
true, if the file is accepted; false otherwise.
See Also
Evaluate
HandlesInversion
CDirEnumerator::Start
CDirEnumerator::Process

Reimplemented in ZipArchiveLib::CGroupFileFilter, and ZipArchiveLib::CNameFileFilter.

bool ZipArchiveLib::CFileFilter::Evaluate ( LPCTSTR  lpszParentDir,
LPCTSTR  lpszName,
const CFileInfo info 
)
inline

This method is directly called by the CDirEnumerator::Start for each file or directory that was previously accepted with the HandlesFile method.

It internally calls the Accept method and inverts its result, if the filter is in the inverted mode and does not handle the inversion internally.

  • If this method returns true for a file, then the file is processed (the CDirEnumerator::Process method is called for the file). Otherwise the file is not processed.
  • If this method returns true for a directory, then the directory can be traversed for files and subfolders (depending on the CDirEnumerator::IsRecursive() method). Otherwise the directory is not traversed.
Parameters
lpszParentDirThe parent directory containing the file to accept.
lpszNameThe name of the file to accept (without a path).
infoThe structure containing the information about the current file.
Returns
true, if the file is accepted (taking inversion into account); false otherwise.
See Also
Accept
HandlesFile
HandlesInversion
SetInverted
IsInverted
CDirEnumerator::Start
CDirEnumerator::Process
virtual bool ZipArchiveLib::CFileFilter::HandlesFile ( const CFileInfo info)
inlinevirtual

Returns the value indicating whether the filter can decide about processing of the info file. If it can, then the Evaluate method will be called for the info file. By default this method returns true for files and false for directories. Override this method to change its behavior.

  • If info is a file and this method returns false, then the file is not processed.
  • If info is a directory and this method returns false, then the directory can still be traversed for files and subfolders (depending on the CDirEnumerator::IsRecursive() method).

The Evaluate method is not called in both cases.

Parameters
infoThe structure containing the information about the file.
Returns
true, if the info file should be evaluated by the Evaluate method; false otherwise.
Note
This method is particularly useful when the filter operates in the inverted mode (see SetInverted). For example, if a filter should accept directories in both inverted and non-inverted mode, it would need to specially handle inversion for directories without this method. With this method it can just not accept directories for evaluation and they still will be traversed.

Reimplemented in ZipArchiveLib::CGroupFileFilter, and ZipArchiveLib::CNameFileFilter.

virtual bool ZipArchiveLib::CFileFilter::HandlesInversion ( ) const
inlineprotectedvirtual

Returns the value indicating whether the current filter handles the inversion mode internally or not.

  • If the filter is in the inverted mode and it handles the inversion, then the return value true from the Accept method means that the file should be processed.
  • If the filter is in the inverted mode and it does not handle the inversion, then the return value true from the Accept method means that the file should not be processed.

It may be more efficient to handle the inversion internally in some cases.

Returns
true, if the filter handles the inversion internally; false otherwise.
Note
This method returns false by default. Override this method to change this behavior.
See Also
SetInverted
IsInverted

Reimplemented in ZipArchiveLib::CGroupFileFilter.

bool ZipArchiveLib::CFileFilter::IsInverted ( ) const
inline

Returns the value indicating whether the filter operates in an inverted mode or in a normal mode.

Returns
true, if the filter operates in an inverted mode; false otherwise.
See Also
SetInverted
HandlesInversion
void ZipArchiveLib::CFileFilter::SetInverted ( bool  bInverted = true)
inline

Sets the filter to operate in the inverted or in the normal mode. If the filter operates in an inverted mode, the file that this filer accepts is not processed and vice versa. Normal mode means that a file is processed (the CDirEnumerator::Process method is called for that file), if the filter accepts the file.

Parameters
bInvertedtrue to make the filter operate in an inverted mode or false to make the filter operate in a normal mode.
See Also
HandlesInversion
IsInverted

The documentation for this class was generated from the following file:
Back To Top Up