33 #include <sys/types.h>
58 : _dirName(copyFrom._dirName),
59 _fileExpr(copyFrom._fileExpr),
69 if (_dirLoaded ==
false) {
73 return _dirList.begin() ;
79 if (_dirLoaded ==
false) {
83 return _dirList.end() ;
89 if (_dirLoaded ==
false) {
93 return _fileList.begin() ;
99 if (_dirLoaded ==
false) {
103 return _fileList.end() ;
114 if( ( dip = opendir( _dirName.c_str() ) ) == NULL )
116 string err_str =
"ERROR: failed to open directory '" + _dirName +
"'" ;
123 while ((dit = readdir(dip)) != NULL)
126 string dirEntry = dit->d_name ;
127 if (dirEntry !=
"." && dirEntry !=
"..") {
128 string fullPath = _dirName +
"/" + dirEntry ;
129 stat(fullPath.c_str(), &buf) ;
133 if (S_ISDIR(buf.st_mode)) {
134 _dirList.push_back(
BESFSDir(fullPath)) ;
137 if (_fileExpr !=
"") {
138 BESRegex reg_expr(_fileExpr.c_str()) ;
139 int match_ret = reg_expr.
match( dirEntry.c_str(),
140 dirEntry.length() ) ;
141 if( match_ret == static_cast<int>(dirEntry.length()) )
143 _fileList.push_back(
BESFSFile(_dirName, dirEntry));
148 _fileList.push_back(
BESFSFile(_dirName, dirEntry)) ;
exception thrown if inernal error encountered
int match(const char *s, int len, int pos=0)
Does the pattern match.
a C++ interface to POSIX regular expression functions.
virtual BESFSDir::dirIterator endOfDirList()
list< BESFSDir >::iterator dirIterator
BESFSDir(const string &dirName)
list< BESFSFile >::iterator fileIterator
virtual BESFSDir::fileIterator endOfFileList()
virtual BESFSDir::dirIterator beginOfDirList()
virtual BESFSDir::fileIterator beginOfFileList()