Portable directory walker that invokes a callback function for every file in a directory, optionally doing depth-first recursion of nested directories. More...
#include <xmltooling/util/DirectoryWalker.h>
Public Types | |
typedef void(* | DirectoryWalkerCallback )(const char *pathname, struct stat &stat_buf, void *data) |
Callback function, passed the file pathname, stat buffer, and optional callback data. | |
Public Member Functions | |
DirectoryWalker (logging::Category &log, const char *path, bool recurse=false) | |
Constructor. | |
void | walk (const DirectoryWalkerCallback &callback_fn, void *callback_data=0, const char *startsWith=0, const char *endsWith=0) const |
Perform a depth-first traversal of the directory. |
Portable directory walker that invokes a callback function for every file in a directory, optionally doing depth-first recursion of nested directories.
typedef void(* xmltooling::DirectoryWalker::DirectoryWalkerCallback)(const char *pathname, struct stat &stat_buf, void *data) |
Callback function, passed the file pathname, stat buffer, and optional callback data.
xmltooling::DirectoryWalker::DirectoryWalker | ( | logging::Category & | log, | |
const char * | path, | |||
bool | recurse = false | |||
) |
Constructor.
log | log category | |
path | directory path to walk | |
recurse | true iff nested directories should be processed |
void xmltooling::DirectoryWalker::walk | ( | const DirectoryWalkerCallback & | callback_fn, | |
void * | callback_data = 0 , |
|||
const char * | startsWith = 0 , |
|||
const char * | endsWith = 0 | |||
) | const [inline] |
Perform a depth-first traversal of the directory.
callback_fn | callback function to invoke for each match | |
callback_data | optional pointer to pass to callback | |
startsWith | optional prefix matching, skipping non-matching entries | |
endsWith | optional suffix matching, skipping non-matching entries |