29 #ifndef __AGG_UTIL__DIRECTORY_UTIL_H__
30 #define __AGG_UTIL__DIRECTORY_UTIL_H__
54 const std::string&
path()
const;
79 std::string _basename;
80 mutable std::string _fullPath;
103 void setRootDir(
const std::string& rootDir,
bool allowRelativePaths=
false,
bool allowSymLinks=
false);
156 std::vector<FileInfo>* pRegularFiles,
157 std::vector<FileInfo>* pDirectories);
169 std::vector<FileInfo>* pRegularFiles,
170 std::vector<FileInfo>* pDirectories);
178 std::vector<FileInfo>& rRegularFiles);
190 static void printFileInfoList(std::ostream& os,
const std::vector<FileInfo>& listing);
205 static bool matchesSuffix(
const std::string& filename,
const std::string& suffix);
212 void throwErrorForOpendirFail(
const std::string& fullPath);
220 bool matchesAllFilters(
const std::string& path, time_t modTime)
const;
226 std::string _rootDir;
233 libdap::Regex* _pRegExp;
236 bool _filteringModTimes;
240 time_t _newestModTime;
243 static const std::string _sDebugChannel;
Class to hold info on files as we get them.
FileInfo(const std::string &path, const std::string &basename, bool isDir, time_t modTime)
strips any trailing "/" on path.
void getListingOfRegularFilesRecursive(const std::string &path, std::vector< FileInfo > &rRegularFiles)
Get recursive listing of all regular files in the directory subtree.
const std::string & basename() const
const std::string & getFullPath() const
Get the path and basename as path + "/" + basename We cache this after first call to allow for a cons...
void setFilterRegExp(const std::string ®exp)
Set a (GNU style) regular expression to be used to match against the full filename (relative path und...
const std::string & path() const
does not include trailing "/"
void getListingForPath(const std::string &path, std::vector< FileInfo > *pRegularFiles, std::vector< FileInfo > *pDirectories)
Get a listing of all the regular files and directories in the given path, which is assumed relative t...
Helper class for temporarily hijacking an existing dhi to load a DDX response for one particular file...
bool operator<(const FileInfo &rhs) const
Comparator using string::operator< on the getFullPath() result.
static bool matchesSuffix(const std::string &filename, const std::string &suffix)
std::string toString() const
std::string getModTimeAsString() const
Get a human readable string for the modTime()
static class NCMLUtil overview
Helper classes for using dirent.h, dir.h, stat.h, etc.
void setFilterSuffix(const std::string &suffix)
Set the filter to be used for the nexy getListingForPath() call.
static std::string getBESRootDir()
Gets the BES root directory by checking the bes.conf settings for BES.
static void removeTrailingSlashes(std::string &path)
mutate to remove all trailing "/"
void setFilterModTimeOlderThan(time_t newestModTime)
Set a filter on the modification time of the files to be returned in a listing.
void clearRegExp()
Remove any filter using a regular expression.
const std::string & getRootDir() const
get the current root dir
void setRootDir(const std::string &rootDir, bool allowRelativePaths=false, bool allowSymLinks=false)
Makes sure the directory exists and is readable or throws an exception exception. ...
static void removePrecedingSlashes(std::string &path)
mutate to remove and preceding (in the front) "/"
void getListingForPathRecursive(const std::string &path, std::vector< FileInfo > *pRegularFiles, std::vector< FileInfo > *pDirectories)
Get the listing for the path recursing into every directory found until it bottoms out...
static void printFileInfoList(std::ostream &os, const std::vector< FileInfo > &listing)
Print the list of files to the stream.
static bool hasRelativePath(const std::string &path)
Is there a "../" in path?