|
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 override |
| Public Member Functions inherited from cmnGenericObject | |
| 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 CISST_THROW(std |
| 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) |
| static bool | DeleteFile (const std::string &fullPath) |
| static bool | RenameFile (const std::string &fullPathOld, const std::string &fullPathNew) |
| static std::string | SharedLibrary (const std::string &name) |
| static std::string | Executable (const std::string &name) |
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 |
Delete file. This function doesn't use any search path.
|
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.
|
inlinestatic |
Construct the executable name based on OS suffix. For example, the return value for "MyProgram" would be "MyProgram" on most Unix systems and "MyProgram.exe" on Windows. Suffix is based on CMake and saved in cisstConfig.h.
|
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.
|
static |
Rename file. This function doesn't use any search path.
| void cmnPath::Set | ( | const std::string & | path | ) |
Set the path from a string.
|
inlinestatic |
Construct the shared library name based on OS prefix and suffix. For example, the return value for "MyLib" would be "libMyLib.so" on most Unix systems and "MyLib.dll" on Windows. Prefix and suffix are based on CMake and saved in cisstConfig.h.
|
overridevirtual |
Write the path to a stream.
Reimplemented from cmnGenericObject.