#include <Path.h>
Public Types | |
typedef std::vector< std::string > | StringVec |
enum | Style { PATH_UNIX, PATH_WINDOWS, PATH_VMS, PATH_NATIVE, PATH_GUESS } |
Public Member Functions | |
Path | absolute (const Path &base) const |
Path | absolute () const |
Path & | append (const Path &path) |
Path & | assign (const char *path) |
Assigns the given path. | |
Path & | assign (const Path &path) |
Assigns a string containing a path. | |
Path & | assign (const std::string &path, Style style) |
Assigns a string containing a path in native format. | |
Path & | assign (const std::string &path) |
Swaps the path with another one. | |
void | clear () |
Returns the file version. VMS only. | |
int | depth () const |
Returns the device name. | |
const std::string & | directory (int n) const |
Returns the number of directories in the directory list. | |
std::string | getBaseName () const |
const std::string & | getDevice () const |
std::string | getExtension () const |
Sets the filename extension. | |
const std::string & | getFileName () const |
Sets the filename. | |
const std::string & | getNode () const |
bool | isAbsolute () const |
bool | isDirectory () const |
Returns true iff the path is relative. | |
bool | isFile () const |
bool | isRelative () const |
Returns true iff the path is absolute. | |
Path & | makeAbsolute (const Path &base) |
Path & | makeAbsolute () |
Makes the path refer to its parent. | |
Path & | makeDirectory () |
Path & | makeFile () |
Path & | makeParent () |
Path & | operator= (const char *path) |
Assigns a string containing a path in native format. | |
Path & | operator= (const std::string &path) |
Assignment operator. | |
Path & | operator= (const Path &path) |
Destroys the Path. | |
const std::string & | operator[] (int n) const |
Path | parent () const |
Clears all components. | |
Path & | parse (const std::string &path, Style style) |
Same as assign(). | |
Path & | parse (const std::string &path) |
Returns a string containing the path in the given format. | |
Path & | parseDirectory (const std::string &path, Style style) |
Path & | parseDirectory (const std::string &path) |
Path (const Path &parent, const Path &relative) | |
Path (const Path &parent, const char *fileName) | |
Path (const Path &parent, const std::string &fileName) | |
Copy constructor. | |
Path (const Path &path) | |
Creates a path from a string. | |
Path (const std::string &path, Style style) | |
Creates a path from a string. | |
Path (const std::string &path) | |
Creates a path from a string. | |
Path (const char *path, Style style) | |
Creates a path from a string. | |
Path (const char *path) | |
Creates an empty absolute or relative path. | |
Path (bool absolute) | |
Creates an empty relative path. | |
Path () | |
void | popDirectory () |
Adds a directory to the directory list. | |
void | pushDirectory (const std::string &dir) |
Path & | resolve (const Path &path) |
Appends the given path. | |
void | setBaseName (const std::string &name) |
Returns the filename. | |
void | setDevice (const std::string &device) |
Returns the node name. | |
void | setExtension (const std::string &extension) |
void | setFileName (const std::string &name) |
Removes the last directory from the directory list. | |
void | setNode (const std::string &node) |
void | swap (Path &path) |
Assigns a string containing a path in native format. | |
std::string | toString (Style style) const |
Returns a string containing the path in native format. | |
std::string | toString () const |
Assigns a string containing a path. | |
bool | tryParse (const std::string &path, Style style) |
bool | tryParse (const std::string &path) |
Assigns a string containing a path. | |
const std::string & | version () const |
Returns the filename extension. | |
~Path () | |
Static Public Member Functions | |
static std::string | current () |
static std::string | expand (const std::string &path) |
Returns the name of the null device. | |
static bool | find (const std::string &pathList, const std::string &name, Path &path) |
static bool | find (StringVec::const_iterator it, StringVec::const_iterator end, const std::string &name, Path &path) |
static Path | forDirectory (const std::string &path, Style style) |
Creates a path referring to a directory. | |
static Path | forDirectory (const std::string &path) |
static std::string | home () |
Returns the current working directory. | |
static void | listRoots (std::vector< std::string > &roots) |
static std::string | null () |
Returns the temporary directory. | |
static char | pathSeparator () |
static char | separator () |
Creates a path referring to a directory. | |
static std::string | temp () |
Returns the user's home directory. | |
static std::string | transcode (const std::string &path) |
Protected Member Functions | |
std::string | buildUnix () const |
std::string | buildVMS () const |
std::string | buildWindows () const |
void | parseGuess (const std::string &path) |
void | parseUnix (const std::string &path) |
void | parseVMS (const std::string &path) |
void | parseWindows (const std::string &path) |
Private Attributes | |
bool | _absolute |
std::string | _device |
StringVec | _dirs |
std::string | _name |
std::string | _node |
std::string | _version |
This class represents filesystem paths in a platform-independent manner. Unix, Windows and OpenVMS all use a different syntax for filesystem paths. This class can work with all three formats. A path is made up of an optional node name (only Windows and OpenVMS), an optional device name (also only Windows and OpenVMS), a list of directory names and an optional filename.
Definition at line 50 of file Path.h.
typedef std::vector<std::string> Poco::Path::StringVec |
enum Poco::Path::Style |
Poco::Path::Path | ( | bool | absolute | ) |
Poco::Path::Path | ( | const char * | path | ) |
Poco::Path::Path | ( | const char * | path, | |
Style | style | |||
) |
Poco::Path::Path | ( | const std::string & | path | ) |
Poco::Path::Path | ( | const std::string & | path, | |
Style | style | |||
) |
Poco::Path::Path | ( | const Path & | path | ) |
Poco::Path::Path | ( | const Path & | parent, | |
const std::string & | fileName | |||
) |
Poco::Path::Path | ( | const Path & | parent, | |
const char * | fileName | |||
) |
Poco::Path::~Path | ( | ) |
Path Poco::Path::absolute | ( | ) | const |
Path & Poco::Path::assign | ( | const char * | path | ) |
Path & Poco::Path::assign | ( | const std::string & | path | ) |
void Poco::Path::clear | ( | ) |
std::string Poco::Path::current | ( | ) | [static] |
int Poco::Path::depth | ( | ) | const [inline] |
const std::string & Poco::Path::directory | ( | int | n | ) | const |
std::string Poco::Path::expand | ( | const std::string & | path | ) | [static] |
bool Poco::Path::find | ( | const std::string & | pathList, | |
const std::string & | name, | |||
Path & | path | |||
) | [static] |
Searches the file with the given name in the locations (paths) specified by it and end. A relative path may be given in name.
If the file is found in one of the locations, the complete path of the file is stored in the path given as argument and true is returned. Otherwise false is returned and the path argument remains unchanged.
bool Poco::Path::find | ( | StringVec::const_iterator | it, | |
StringVec::const_iterator | end, | |||
const std::string & | name, | |||
Path & | path | |||
) | [static] |
Path Poco::Path::forDirectory | ( | const std::string & | path | ) | [inline, static] |
std::string Poco::Path::getBaseName | ( | ) | const |
const std::string & Poco::Path::getDevice | ( | ) | const [inline] |
std::string Poco::Path::getExtension | ( | ) | const |
const std::string & Poco::Path::getFileName | ( | ) | const [inline] |
const std::string & Poco::Path::getNode | ( | ) | const [inline] |
std::string Poco::Path::home | ( | ) | [static] |
bool Poco::Path::isAbsolute | ( | ) | const [inline] |
bool Poco::Path::isDirectory | ( | ) | const [inline] |
bool Poco::Path::isFile | ( | ) | const [inline] |
bool Poco::Path::isRelative | ( | ) | const [inline] |
void Poco::Path::listRoots | ( | std::vector< std::string > & | roots | ) | [static] |
Path & Poco::Path::makeAbsolute | ( | ) |
Path & Poco::Path::makeDirectory | ( | ) |
Path & Poco::Path::makeFile | ( | ) |
Path & Poco::Path::makeParent | ( | ) |
std::string Poco::Path::null | ( | ) | [static] |
Path & Poco::Path::operator= | ( | const char * | path | ) |
Path & Poco::Path::operator= | ( | const std::string & | path | ) |
const std::string & Poco::Path::operator[] | ( | int | n | ) | const |
Path & Poco::Path::parse | ( | const std::string & | path | ) | [inline] |
Path & Poco::Path::parseDirectory | ( | const std::string & | path | ) |
void Poco::Path::parseGuess | ( | const std::string & | path | ) | [protected] |
void Poco::Path::parseUnix | ( | const std::string & | path | ) | [protected] |
On Windows, if POCO has been compiled with Windows UTF-8 support (POCO_WIN32_UTF8), this function converts a string (usually containing a path) encoded in UTF-8 into a string encoded in the current Windows code page.
This function should be used for every string passed as a file name to a string stream or fopen().
On all other platforms, or if POCO has not been compiled with Windows UTF-8 support, this function returns the string unchanged.
void Poco::Path::parseVMS | ( | const std::string & | path | ) | [protected] |
void Poco::Path::parseWindows | ( | const std::string & | path | ) | [protected] |
char Poco::Path::pathSeparator | ( | ) | [inline, static] |
void Poco::Path::popDirectory | ( | ) |
void Poco::Path::pushDirectory | ( | const std::string & | dir | ) |
char Poco::Path::separator | ( | ) | [inline, static] |
void Poco::Path::setBaseName | ( | const std::string & | name | ) |
void Poco::Path::setDevice | ( | const std::string & | device | ) |
void Poco::Path::setExtension | ( | const std::string & | extension | ) |
void Poco::Path::setFileName | ( | const std::string & | name | ) |
void Poco::Path::setNode | ( | const std::string & | node | ) |
void Poco::Path::swap | ( | Path & | path | ) |
std::string Poco::Path::temp | ( | ) | [static] |
std::string Poco::Path::toString | ( | Style | style | ) | const |
std::string Poco::Path::toString | ( | ) | const |
std::string Poco::Path::transcode | ( | const std::string & | path | ) | [static] |
Searches the file with the given name in the locations (paths) specified in pathList. The paths in pathList must be delimited by the platform's path separator (see pathSeparator()). A relative path may be given in name.
If the file is found in one of the locations, the complete path of the file is stored in the path given as argument and true is returned. Otherwise false is returned and the path argument remains unchanged.
bool Poco::Path::tryParse | ( | const std::string & | path, | |
Style | style | |||
) |
bool Poco::Path::tryParse | ( | const std::string & | path | ) |
const std::string & Poco::Path::version | ( | ) | const [inline] |
bool Poco::Path::_absolute [private] |
std::string Poco::Path::_device [private] |
StringVec Poco::Path::_dirs [private] |
std::string Poco::Path::_name [private] |
std::string Poco::Path::_node [private] |
std::string Poco::Path::_version [private] |