Ark Server API (ASE) - Wiki
|
#include <Path.h>
Public Types | |
enum | Style { PATH_UNIX , PATH_URI = PATH_UNIX , PATH_WINDOWS , PATH_VMS , PATH_NATIVE , PATH_GUESS } |
typedef std::vector< std::string > | StringVec |
Public Member Functions | |
Path () | |
Path (bool absolute) | |
Creates an empty relative path. | |
Path (const char *path) | |
Creates an empty absolute or relative path. | |
Path (const char *path, Style style) | |
Creates a path from a string. | |
Path (const std::string &path) | |
Creates a path from a string. | |
Path (const std::string &path, Style style) | |
Creates a path from a string. | |
Path (const Path &path) | |
Creates a path from a string. | |
Path (Path &&path) noexcept | |
Copy constructor. | |
Path (const Path &parent, const std::string &fileName) | |
Move constructor. | |
Path (const Path &parent, const char *fileName) | |
Path (const Path &parent, const Path &relative) | |
~Path () | |
Path & | operator= (const Path &path) |
Destroys the Path. | |
Path & | operator= (Path &&path) noexcept |
Assignment operator. | |
Path & | operator= (const std::string &path) |
Move assignment. | |
Path & | operator= (const char *path) |
Assigns a string containing a path in native format. | |
void | swap (Path &path) |
Assigns a string containing a path in native format. | |
Path & | assign (const std::string &path) |
Swaps the path with another one. | |
Path & | assign (const std::string &path, Style style) |
Assigns a string containing a path in native format. | |
Path & | assign (const Path &path) |
Assigns a string containing a path. | |
Path & | assign (const char *path) |
Assigns the given path. | |
std::string | toString () const |
Assigns a string containing a path. | |
std::string | toString (Style style) const |
Returns a string containing the path in native format. | |
Path & | parse (const std::string &path) |
Returns a string containing the path in the given format. | |
Path & | parse (const std::string &path, Style style) |
Same as assign(). | |
bool | tryParse (const std::string &path) |
Assigns a string containing a path. | |
bool | tryParse (const std::string &path, Style style) |
Path & | parseDirectory (const std::string &path) |
Path & | parseDirectory (const std::string &path, Style style) |
Path & | makeDirectory () |
Path & | makeFile () |
Path & | makeParent () |
Path & | makeAbsolute () |
Makes the path refer to its parent. | |
Path & | makeAbsolute (const Path &base) |
Path & | append (const Path &path) |
Path & | resolve (const Path &path) |
Appends the given path. | |
bool | isAbsolute () const |
bool | isRelative () const |
Returns true iff the path is absolute. | |
bool | isDirectory () const |
Returns true iff the path is relative. | |
bool | isFile () const |
Path & | setNode (const std::string &node) |
const std::string & | getNode () const |
Path & | setDevice (const std::string &device) |
Returns the node name. | |
const std::string & | getDevice () const |
int | depth () const |
Returns the device name. | |
const std::string & | directory (int n) const |
Returns the number of directories in the directory list. | |
const std::string & | operator[] (int n) const |
Path & | pushDirectory (const std::string &dir) |
Path & | popDirectory () |
Adds a directory to the directory list. | |
Path & | popFrontDirectory () |
Removes the last directory from the directory list. | |
Path & | setFileName (const std::string &name) |
Removes the first directory from the directory list. | |
const std::string & | getFileName () const |
Sets the filename. | |
Path & | setBaseName (const std::string &name) |
Returns the filename. | |
std::string | getBaseName () const |
Path & | setExtension (const std::string &extension) |
std::string | getExtension () const |
Sets the filename extension. | |
const std::string & | version () const |
Returns the filename extension. | |
Path & | clear () |
Returns the file version. VMS only. | |
Path | parent () const |
Clears all components. | |
Path | absolute () const |
Path | absolute (const Path &base) const |
Static Public Member Functions | |
static Path | forDirectory (const std::string &path) |
static Path | forDirectory (const std::string &path, Style style) |
Creates a path referring to a directory. | |
static char | separator () |
Creates a path referring to a directory. | |
static char | pathSeparator () |
static std::string | current () |
static std::string | home () |
Returns the current working directory. | |
static std::string | configHome () |
Returns the user's home directory. | |
static std::string | dataHome () |
static std::string | tempHome () |
static std::string | cacheHome () |
static std::string | temp () |
static std::string | config () |
Returns the temporary directory. | |
static std::string | null () |
static std::string | expand (const std::string &path) |
Returns the name of the null device. | |
static void | listRoots (std::vector< std::string > &roots) |
static bool | find (StringVec::const_iterator it, StringVec::const_iterator end, const std::string &name, Path &path) |
static bool | find (const std::string &pathList, const std::string &name, Path &path) |
static std::string | transcode (const std::string &path) |
Protected Member Functions | |
void | parseUnix (const std::string &path) |
void | parseWindows (const std::string &path) |
void | parseVMS (const std::string &path) |
void | parseGuess (const std::string &path) |
std::string | buildUnix () const |
std::string | buildWindows () const |
std::string | buildVMS () const |
Private Attributes | |
std::string | _node |
std::string | _device |
std::string | _name |
std::string | _version |
StringVec | _dirs |
bool | _absolute |
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.
typedef std::vector<std::string> Poco::Path::StringVec |
enum Poco::Path::Style |
Poco::Path::Path | ( | ) |
Poco::Path::Path | ( | bool | absolute | ) |
Creates an empty relative path.
Poco::Path::Path | ( | const char * | path | ) |
Creates an empty absolute or relative path.
Poco::Path::Path | ( | const char * | path, |
Style | style ) |
Creates a path from a string.
Poco::Path::Path | ( | const std::string & | path | ) |
Creates a path from a string.
Poco::Path::Path | ( | const std::string & | path, |
Style | style ) |
Creates a path from a string.
Poco::Path::Path | ( | const Path & | path | ) |
Creates a path from a string.
|
noexcept |
Copy constructor.
Poco::Path::Path | ( | const Path & | parent, |
const std::string & | fileName ) |
Move constructor.
Poco::Path::Path | ( | const Path & | parent, |
const char * | fileName ) |
Creates a path from a parent path and a filename. The parent path is expected to reference a directory.
Creates a path from a parent path and a filename. The parent path is expected to reference a directory.
Poco::Path::~Path | ( | ) |
Creates a path from a parent path and a relative path. The parent path is expected to reference a directory. The relative path is appended to the parent path.
Path Poco::Path::absolute | ( | ) | const |
Returns a path referring to the path's directory.
Returns an absolute variant of the path, taking the current working directory as base.
Makes the path absolute if it is relative. The given path is taken as base.
Path & Poco::Path::assign | ( | const char * | path | ) |
Assigns the given path.
Path & Poco::Path::assign | ( | const std::string & | path | ) |
Swaps the path with another one.
Assigns a string containing a path in native format.
|
protected |
|
protected |
|
protected |
|
static |
Returns the user's temp directory.
On Unix systems, this is the '~/.local/temp/'.
Path & Poco::Path::clear | ( | ) |
Returns the file version. VMS only.
|
static |
Returns the temporary directory.
|
static |
Returns the user's home directory.
|
static |
Returns the platform's path separator, which separates single paths in a list of paths.
On Unix systems, this is the colon ':'. On Windows systems, this is the semicolon ';'. On OpenVMS systems, this is the comma ','.
|
static |
Returns the user's config directory.
On Unix systems, this is the '~/.config/'. On Windows systems, this is 'APPDATA'.
|
inline |
const std::string & Poco::Path::directory | ( | int | n | ) | const |
Returns the number of directories in the directory list.
|
static |
Returns the name of the null device.
|
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.
|
static |
Fills the vector with all filesystem roots available on the system. On Unix, there is exactly one root, "/". On Windows, the roots are the drive letters. On OpenVMS, the roots are the mounted disks.
|
inlinestatic |
std::string Poco::Path::getBaseName | ( | ) | const |
Sets the basename part of the filename and does not change the extension.
|
inline |
std::string Poco::Path::getExtension | ( | ) | const |
Sets the filename extension.
|
inline |
|
inline |
|
static |
Returns the current working directory.
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
Expands all environment variables contained in the path.
On Unix, a tilde as first character in the path is replaced with the path to user's home directory.
Path & Poco::Path::makeAbsolute | ( | ) |
Makes the path refer to its parent.
Makes the path absolute if it is relative. The current working directory is taken as base directory.
Path & Poco::Path::makeDirectory | ( | ) |
The resulting path always refers to a directory and the filename part is empty.
Path & Poco::Path::makeFile | ( | ) |
If the path contains a filename, the filename is appended to the directory list and cleared. Thus the resulting path always refers to a directory.
Path & Poco::Path::makeParent | ( | ) |
If the path contains no filename, the last directory becomes the filename.
|
static |
Returns the systemwide config directory.
On Unix systems, this is the '/etc/'.
Path & Poco::Path::operator= | ( | const char * | path | ) |
Assigns a string containing a path in native format.
Path & Poco::Path::operator= | ( | const std::string & | path | ) |
Move assignment.
const std::string & Poco::Path::operator[] | ( | int | n | ) | const |
Returns the n'th directory in the directory list. If n == depth(), returns the filename.
Path Poco::Path::parent | ( | ) | const |
Clears all components.
|
inline |
Path & Poco::Path::parseDirectory | ( | const std::string & | path | ) |
Tries to interpret the given string as a path, according to the given style. If the path is syntactically valid, assigns the path and returns true. Otherwise leaves the object unchanged and returns false.
The resulting path always refers to a directory and the filename part is empty.
|
protected |
|
protected |
On Windows, 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.
|
protected |
|
protected |
|
inlinestatic |
Path & Poco::Path::popDirectory | ( | ) |
Adds a directory to the directory list.
Path & Poco::Path::popFrontDirectory | ( | ) |
Removes the last directory from the directory list.
Path & Poco::Path::pushDirectory | ( | const std::string & | dir | ) |
Returns the n'th directory in the directory list. If n == depth(), returns the filename.
|
inlinestatic |
Path & Poco::Path::setBaseName | ( | const std::string & | name | ) |
Returns the filename.
Path & Poco::Path::setDevice | ( | const std::string & | device | ) |
Returns the node name.
Path & Poco::Path::setExtension | ( | const std::string & | extension | ) |
Returns the basename (the filename sans extension) of the path.
Path & Poco::Path::setFileName | ( | const std::string & | name | ) |
Removes the first directory from the directory list.
Path & Poco::Path::setNode | ( | const std::string & | node | ) |
Returns true iff the path references a file (the filename part is not empty).
void Poco::Path::swap | ( | Path & | path | ) |
Assigns a string containing a path in native format.
|
static |
Returns the user's cache directory.
On Unix systems, this is the '~/.cache/'. On Windows systems, this is 'APPDATA'.
|
static |
Returns the user's data directory.
On Unix systems, this is the '~/.local/share/'. On Windows systems, this is 'APPDATA'.
std::string Poco::Path::toString | ( | ) | const |
Assigns a string containing a path.
std::string Poco::Path::toString | ( | Style | style | ) | const |
Returns a string containing the path in native format.
|
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 | ) |
Assigns a string containing a path.
bool Poco::Path::tryParse | ( | const std::string & | path, |
Style | style ) |
Tries to interpret the given string as a path in native format. If the path is syntactically valid, assigns the path and returns true. Otherwise leaves the object unchanged and returns false.
|
inline |