|
std::string | abspath (const std::string &path) |
| Make path absolute. More...
|
|
std::string | basename (const std::string &path) |
| Get file name. More...
|
|
std::string | dirname (const std::string &path) |
| Get file directory. More...
|
|
bool | exists (const std::string path) |
| Test the existance of a file or directory. More...
|
|
bool | hasext (const std::string &path, const std::set< std::string > *exts=NULL) |
| Test whether a given path has an extension. More...
|
|
bool | isabs (const std::string &path) |
| Test whether a given path is absolute. More...
|
|
bool | isdir (const std::string path) |
| Test whether a given path is the path of an existent directory. More...
|
|
bool | isfile (const std::string path) |
| Test whether a given path is the path of an existent file. More...
|
|
bool | islink (const std::string &path) |
| Whether a given path is a symbolic link. More...
|
|
bool | issep (char c) |
| Determine if a given character is a path separator. More...
|
|
std::string | join (const std::string &base, const std::string &path) |
| Join two paths, e.g., base path and relative path. More...
|
|
std::string | normpath (const std::string &path) |
| Normalize path, i.e., remove occurences of "./", duplicate slashes,... More...
|
|
std::string | ntpath (const std::string &path) |
| Convert path to Windows representation. More...
|
|
std::string | posixpath (const std::string &path) |
| Convert path to Posix (e.g., Unix, Mac OS) representation. More...
|
|
std::string | realpath (const std::string &path) |
| Get canonical file path. More...
|
|
std::string | relpath (const std::string &path, const std::string &base=std::string()) |
| Make path relative. More...
|
|
void | split (const std::string &path, std::string &head, std::string &tail) |
| Split path into two parts. More...
|
|
std::vector< std::string > | split (const std::string &path) |
| Split path into two parts. More...
|
|
void | splitdrive (const std::string &path, std::string &drive, std::string &tail) |
| Get drive specification of Windows path. More...
|
|
std::vector< std::string > | splitdrive (const std::string &path) |
| Get drive specification of Windows path. More...
|
|
void | splitext (const std::string &path, std::string &head, std::string &ext, const std::set< std::string > *exts=NULL, bool icase=false) |
| Get file name extension. More...
|
|
std::vector< std::string > | splitext (const std::string &path, const std::set< std::string > *exts=NULL) |
| Get file name extension. More...
|
|
string basis::os::path::join |
( |
const std::string & |
base, |
|
|
const std::string & |
path |
|
) |
| |
Join two paths, e.g., base path and relative path.
This function joins two paths. If the second path is an absolute path, this normalized absolute path is returned. Otherwise, the base path is prepended to the relative path and the resulting relative or absolute path returned after normalizing it.
- Parameters
-
[in] | base | Base path. |
[in] | path | Relative or absolute path. |
- Returns
- Joined path.
Definition at line 432 of file path.cxx.
string basis::os::path::normpath |
( |
const std::string & |
path | ) |
|
Normalize path, i.e., remove occurences of "./", duplicate slashes,...
This function removes single periods enclosed by slashes (or backslashes), duplicate slashes (or backslashes), and further tries to reduce the number of parent directory references. Moreover, on Windows, it replaces slashes with backslashes.
For example, on Windows, "../bla//.//.\bla\\\\\bla/../.." is convert to "..\bla". On Unix, it is converted to "..". Note that on Unix, ".\bla\\\\\bla" is a directory name.
- Parameters
-
- Returns
- Normalized path.
Definition at line 81 of file path.cxx.
void basis::os::path::split |
( |
const std::string & |
path, |
|
|
std::string & |
head, |
|
|
std::string & |
tail |
|
) |
| |
Split path into two parts.
This function splits a path into its head and tail. Trailing slashes are stripped from head unless it is the root. See the following table for an illustration:
path | head | tail
-------------------------+-------+---------------+-------------
"/" | "/" | ""
"/usr/bin" | "/usr" | "bin"
"/home/user/info.txt" | "/home/user" | "info.txt"
"word.doc" | "" | "word.doc"
"../word.doc" | ".." | "word.doc"
"C:/" | "C:/" | ""
"C:" | "C:" | ""
"C:/WINDOWS/regedit.exe" | "C:/WINDOWS" | "regedit.exe"
"d:\data" | "d:/" | "data"
"/usr/local/" | "/usr/local" | ""
In all cases, join(head, tail) returns a path to the same location as path (but the strings may differ).
- Parameters
-
[in] | path | Path. |
[out] | head | Head part of path. |
[out] | tail | Tail part of path. |
- See also
- splitdrive()
-
splitext()
-
dirname()
-
basename()
Definition at line 164 of file path.cxx.