GNU CommonC++
Public Member Functions | Protected Member Functions

ost::DirTree Class Reference

A generic class to walk a hierarchical directory structure. More...

#include <file.h>

List of all members.

Public Member Functions

 DirTree (const char *prefix, unsigned maxdepth)
 Construct a directory tree walk starting at the specified prefix.
 DirTree (unsigned maxdepth)
 Construct an un-opened directory tree of a known maximum depth.
virtual ~DirTree ()
void open (const char *prefix)
 Open a directory tree path.
void close (void)
 Close the directory path.
char * getPath (void)
 Extract the next full pathname from the directory walk.
unsigned perform (const char *prefix)
 This is used to step through the filter virtual for an entire subtree, and is used for cases where a derived DirTree class performs it's primary operations through filter rather than externally by calling getPath().

Protected Member Functions

virtual bool filter (const char *file, struct stat *ino)
 Virtual method to filter results.

Detailed Description

A generic class to walk a hierarchical directory structure.

Author:
David Sugar <dyfet@ostel.com> Directory tree walking.

Constructor & Destructor Documentation

ost::DirTree::DirTree ( const char *  prefix,
unsigned  maxdepth 
)

Construct a directory tree walk starting at the specified prefix.

A maximum subdirectory depth is also specified.

Parameters:
prefixto start walk.
maxdepthsubdirectory depth to examine.
ost::DirTree::DirTree ( unsigned  maxdepth)

Construct an un-opened directory tree of a known maximum depth.

Parameters:
maxdepthsubdirectory subdirectory depth.
virtual ost::DirTree::~DirTree ( ) [virtual]

Member Function Documentation

void ost::DirTree::close ( void  )

Close the directory path.

virtual bool ost::DirTree::filter ( const char *  file,
struct stat *  ino 
) [protected, virtual]

Virtual method to filter results.

Virtual override methods should call baseclass method to assure . and .. names are stripped out.

Returns:
true if current filename is accepted.
Parameters:
filepath to examine
inoinfo of type, date, etc.
char* ost::DirTree::getPath ( void  )

Extract the next full pathname from the directory walk.

When returning directories, a '/' is appended. The returned string is a buffer of MAX_PATH size.

Returns:
path of next subdirectory entry or NULL.
void ost::DirTree::open ( const char *  prefix)

Open a directory tree path.

Parameters:
prefixdirectory path to open.
unsigned ost::DirTree::perform ( const char *  prefix)

This is used to step through the filter virtual for an entire subtree, and is used for cases where a derived DirTree class performs it's primary operations through filter rather than externally by calling getPath().

Returns:
number of files and directories examined.
Parameters:
prefixdirectory path to examine.

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