|
libcommonc++
0.7
|
A depth- or breadth-first file traverser. More...
#include <FileTraverser.h++>

Public Member Functions | |
| FileTraverser (const String &basePath, bool depthFirst=true) | |
| Construct a new FileTraverser rooted at the given base path. More... | |
| virtual | ~FileTraverser () |
| Destructor. More... | |
| void | setPrunePattern (const RegExp &pattern) |
| Set a prune pattern for the traverser. More... | |
| bool | traverse () |
| Traverse the file tree. More... | |
Protected Member Functions | |
| virtual bool | processFile (const FileName &name, bool isDir, uint_t depth)=0 |
| Process the next file or directory encountered. More... | |
| virtual bool | handleError (const FileName &name, const IOException &ex) |
| Handle an exception during traversal. More... | |
A depth- or breadth-first file traverser.
This is an abstract class; subclasses must implement the processFile() function to process each file and directory encountered during the traversal.
| FileTraverser | ( | const String & | basePath, |
| bool | depthFirst = true |
||
| ) |
Construct a new FileTraverser rooted at the given base path.
| basePath | The base path at which traversal will begin. |
| depthFirst | If true, traversal will be depth-first; otherwise it will be breadth-first. |
|
virtual |
Destructor.
|
protectedvirtual |
Handle an exception during traversal.
The method should return true if traversal should continue, false otherwise. The default implementation is a no-op that simply returns false.
| name | The filename for which the error occurred. |
| ex | The exception indicating the error. |
Process the next file or directory encountered.
| name | The filename. |
| isDir | A flag indicating whether the file is a directory. |
| depth | The current traversal depth. |
|
inline |
Set a prune pattern for the traverser.
Any file or directory whose name matches the given pattern will be skipped during traversal. Setting a null pattern disables pruning.
| pattern | The prune pattern. |
| bool traverse | ( | ) |
Traverse the file tree.