bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
|
#include <DirectoryUtil.h>
Public Member Functions | |
void | clearRegExp () |
void | getListingForPath (const std::string &path, std::vector< FileInfo > *pRegularFiles, std::vector< FileInfo > *pDirectories) |
void | getListingForPathRecursive (const std::string &path, std::vector< FileInfo > *pRegularFiles, std::vector< FileInfo > *pDirectories) |
void | getListingOfRegularFilesRecursive (const std::string &path, std::vector< FileInfo > &rRegularFiles) |
const std::string & | getRootDir () const |
void | setFilterModTimeOlderThan (time_t newestModTime) |
void | setFilterRegExp (const std::string ®exp) |
void | setFilterSuffix (const std::string &suffix) |
void | setRootDir (const std::string &rootDir, bool allowRelativePaths=false, bool allowSymLinks=false) |
Static Public Member Functions | |
static std::string | getBESRootDir () |
static bool | hasRelativePath (const std::string &path) |
static bool | matchesSuffix (const std::string &filename, const std::string &suffix) |
static void | printFileInfoList (const std::vector< FileInfo > &listing) |
static void | printFileInfoList (std::ostream &os, const std::vector< FileInfo > &listing) |
static void | removePrecedingSlashes (std::string &path) |
static void | removeTrailingSlashes (std::string &path) |
Helper classes for using dirent.h, dir.h, stat.h, etc. to make directory listings.
Definition at line 83 of file DirectoryUtil.h.
agg_util::DirectoryUtil::DirectoryUtil | ( | ) |
Definition at line 158 of file DirectoryUtil.cc.
agg_util::DirectoryUtil::~DirectoryUtil | ( | ) |
Definition at line 166 of file DirectoryUtil.cc.
void agg_util::DirectoryUtil::clearRegExp | ( | ) |
Remove any filter using a regular expression.
Definition at line 218 of file DirectoryUtil.cc.
|
static |
Gets the BES root directory by checking the bes.conf settings for BES. Returns: value for key == "BES.Catalog.catalog.RootDirectory" if it exists, else the value for "BES.Data.RootDirectory" if that doesn't exist either, simply returns the filesystem root "/".
Definition at line 423 of file DirectoryUtil.cc.
void agg_util::DirectoryUtil::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 to getRootDir().
Entries are placed into one of two vectors if not null. This allows just regular files to be gotten, or just subdirectories, or both.
path | the directory to list, non-recursive. |
pRegularFiles | vector to add the regular (not directory) files to if not null. |
pDirectories | vector to add the directories found in path if not null. |
Definition at line 230 of file DirectoryUtil.cc.
void agg_util::DirectoryUtil::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. NOTE: a symlink loop will cause an exception.
path | top directory to begin recursive search |
pRegularFiles | if not null, filled with all regular files in filesystem subtree. |
pDirectories | if not null, filled in with all directories in filesystem subtree. |
Definition at line 279 of file DirectoryUtil.cc.
void agg_util::DirectoryUtil::getListingOfRegularFilesRecursive | ( | const std::string & | path, |
std::vector< FileInfo > & | rRegularFiles ) |
Get recursive listing of all regular files in the directory subtree.
path | top directory to search |
rRegularFiles | where to place all the files. |
Definition at line 312 of file DirectoryUtil.cc.
const std::string & agg_util::DirectoryUtil::getRootDir | ( | ) | const |
get the current root dir
Definition at line 173 of file DirectoryUtil.cc.
|
static |
Is there a "../" in path?
Definition at line 386 of file DirectoryUtil.cc.
|
static |
Definition at line 437 of file DirectoryUtil.cc.
|
static |
Just dump to the BESDebug channel _sDebugChannel for debugging
Definition at line 409 of file DirectoryUtil.cc.
|
static |
Print the list of files to the stream.
Definition at line 416 of file DirectoryUtil.cc.
|
static |
mutate to remove and preceding (in the front) "/"
Definition at line 401 of file DirectoryUtil.cc.
|
static |
mutate to remove all trailing "/"
Definition at line 391 of file DirectoryUtil.cc.
void agg_util::DirectoryUtil::setFilterModTimeOlderThan | ( | time_t | newestModTime | ) |
Set a filter on the modification time of the files to be returned in a listing. Any returned file will have a modification date older than newestModTime.
newestModTime | the cutoff modification time for inclusion of files. |
Definition at line 224 of file DirectoryUtil.cc.
void agg_util::DirectoryUtil::setFilterRegExp | ( | const std::string & | regexp | ) |
Set a (GNU style) regular expression to be used to match against the full filename (relative path under root) and filter only those that match in the listings. setFilterRegExp("") is the same as clearRegExp().
regexp | the regular expression to use. |
this | will throw libdap::Error if there's a problem with compiling the regexp. |
Definition at line 210 of file DirectoryUtil.cc.
void agg_util::DirectoryUtil::setFilterSuffix | ( | const std::string & | suffix | ) |
Set the filter to be used for the nexy getListingForPath() call. Only files that end in suffix will be returned.
suffix | suffix string to filter returned files against |
Definition at line 205 of file DirectoryUtil.cc.
void agg_util::DirectoryUtil::setRootDir | ( | const std::string & | origRootDir, |
bool | allowRelativePaths = false, | ||
bool | allowSymLinks = false ) |
Makes sure the directory exists and is readable or throws an exception exception. Removes any trailing slashes unless the root is "/" (default). If !allowRelativePaths, then: Throws a BESForbiddenError if there is a "../" in the path somewhere. If !allowSymLinks and one is encountered, Throws a BESNotForbiddenError exception. If the root path cannot be found, throws BESNotFoundError.
Makes sure the directory exists and is readable or throws an parse exception. Removes any trailing slashes unless the root is "/" (default). If noRelativePaths, then: Throws a parse exception if there is a "../" in the path somewhere.
Definition at line 183 of file DirectoryUtil.cc.