cisst-saw
|
Search path to find a file. This class contains a list of directories used to locate a file. More...
#include <cmnPath.h>
Public Types | |
enum | { HEAD = true, TAIL = false } |
enum | { EXIST = 00, WRITE = 02, READ = 04, EXECUTE = 04 } |
typedef std::list< std::string > | ContainerType |
typedef ContainerType::iterator | iterator |
typedef ContainerType::const_iterator | const_iterator |
Public Member Functions | |
cmnPath (void) | |
cmnPath (const std::string &path) | |
virtual | ~cmnPath (void) |
void | Set (const std::string &path) |
void | Add (const std::string &path, bool head=HEAD) |
bool | AddFromEnvironment (const std::string &variableName, bool head=HEAD) |
bool | AddRelativeToCisstRoot (const std::string &relativePath, bool head=HEAD) |
bool | AddRelativeToCisstShare (const std::string &relativePath, bool head=HEAD) |
std::string | Find (const std::string &filename, short mode=READ) const |
std::string | FindWithSubdirectory (const std::string &filename, const std::string &subdirectory, short mode=READ) const |
bool | Remove (const std::string &directory) |
bool | Has (const std::string &directory) const |
void | ToStream (std::ostream &outputStream) const |
![]() | |
virtual | ~cmnGenericObject (void) |
virtual const cmnClassServicesBase * | Services (void) const =0 |
bool | ReconstructFrom (const cmnGenericObject &other) |
std::string | ToString (void) const |
virtual void | ToStreamRaw (std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const |
virtual bool | FromStreamRaw (std::istream &inputStream, const char delimiter= ' ') |
virtual void | SerializeRaw (std::ostream &outputStream) const |
virtual void | DeSerializeRaw (std::istream &inputStream) |
virtual cmnLogger::StreamBufType * | GetLogMultiplexer (void) const |
virtual size_t | ScalarNumber (void) const |
virtual bool | ScalarNumberIsFixed (void) const |
virtual double | Scalar (const size_t CMN_UNUSED(index)) const throw (std::out_of_range) |
virtual std::string | ScalarDescription (const size_t CMN_UNUSED(index), const std::string &CMN_UNUSED(userDescription)) const |
Static Public Member Functions | |
static const std::string & | DirectorySeparator (void) |
static std::string | GetWorkingDirectory (void) |
static bool | GetCisstRoot (std::string &result) |
static bool | GetCisstShare (std::string &result) |
static bool | Exists (const std::string &fullPath, short more=READ) |
Search path to find a file. This class contains a list of directories used to locate a file.
The directories can be added either at the head or the tail of the list. This class doesn't check weither the directories in the path actually exist, mostly to allow a portable program (e.g. one program can add both "/usr/local/bin" and "C:\Program Files").
As a convention, the separator between subdirectories should be a "/" (slash) and the separation between two directories in the path is ";" (semi-colon). For example, "/bin;/usr/bin" will add both "/bin" and "/usr/bin".
typedef ContainerType::const_iterator cmnPath::const_iterator |
typedef std::list<std::string> cmnPath::ContainerType |
Container used to store the directories.
typedef ContainerType::iterator cmnPath::iterator |
STL like iterators.
cmnPath::cmnPath | ( | void | ) |
cmnPath::cmnPath | ( | const std::string & | path | ) |
Create a search path from a string.
|
inlinevirtual |
Destructor
void cmnPath::Add | ( | const std::string & | path, |
bool | head = HEAD |
||
) |
Add one or more directories to the path.
bool cmnPath::AddFromEnvironment | ( | const std::string & | variableName, |
bool | head = HEAD |
||
) |
Add one or more directories to the path using an environment variable.
bool cmnPath::AddRelativeToCisstRoot | ( | const std::string & | relativePath, |
bool | head = HEAD |
||
) |
Add path relative to the CISST_ROOT environment variable. This can be useful to find shared libraries. To find data files, use AddRelativeToCisstShare.
bool cmnPath::AddRelativeToCisstShare | ( | const std::string & | relativePath, |
bool | head = HEAD |
||
) |
Add path relative to the shared cisst directory, i.e. CISST_ROOT/share/cisst-<version>.
|
static |
A platform-independent string for separating subdirectory or file name from the parent directory name. It's equal to "/" on Linux, "\\" on Windows, etc.
|
static |
Check if a file exists assuming the path provided is either relative or absolute, this function doesn't use any search path.
std::string cmnPath::Find | ( | const std::string & | filename, |
short | mode = READ |
||
) | const |
Find the full name for a given file.
std::string cmnPath::FindWithSubdirectory | ( | const std::string & | filename, |
const std::string & | subdirectory, | ||
short | mode = READ |
||
) | const |
Find the full name for a given file using all directories in path as well as given "sub directory" in each directory. E.g if the path contains /bin and /usr/bin and the sub-directory provided is "Release", the full search path if /bin/Release, /bin, /usr/bin/Release, /usr/bin. One can also #include <cisstBuildType.h> which defines the string CISST_BUILD_SUFFIX.
|
static |
Get CISST_ROOT from the environment variable
|
static |
Get cisst shared directory based on CISST_ROOT from the environment variable
|
static |
Get working directory
bool cmnPath::Has | ( | const std::string & | directory | ) | const |
Indicates if a given directory is in the search list.
bool cmnPath::Remove | ( | const std::string & | directory | ) |
Remove the first occurence of a directory from the search list.
void cmnPath::Set | ( | const std::string & | path | ) |
Set the path from a string.
|
virtual |
Write the path to a stream.
Reimplemented from cmnGenericObject.