Public Types | |
| enum | Style { Local, Unix, Windows } |
Public Member Functions | |
| FilePath (const char *fullinp=0) | |
| FilePath (const FilePath &) | |
| FilePath & | operator= (const FilePath &) |
| FilePath & | operator= (const char *fullinp) |
| bool | operator== (const FilePath &) const |
| bool | operator== (const char *fnm) const |
| bool | operator!= (const FilePath &) const |
| bool | operator!= (const char *fnm) const |
| FilePath & | set (const char *fullinp) |
| FilePath & | add (const char *) |
| at end | |
| FilePath & | insert (const char *) |
| after prefix at begin | |
| void | setFileName (const char *) |
| pass null to remove level | |
| void | setPath (const char *) |
| including prefix | |
| void | setExtension (const char *, bool replace=true) |
| !replace => add | |
| bool | isAbsolute () const |
| bool | isSubDirOf (const FilePath &, FilePath *reldir=0) const |
| bool | makeCanonical () |
| bool | makeRelativeTo (const FilePath &) |
| BufferString | fullPath (Style s=Local, bool cleanup=true) const |
| const char * | prefix () const |
| int | nrLevels () const |
| const char * | extension () const |
| may return null | |
| const BufferString & | fileName () const |
| BufferString | pathOnly () const |
| const BufferString & | dir (int nr=-1) const |
| nr < 0 returns last dir name | |
| BufferString | dirUpTo (int) const |
| nr < 0 returns last dir, including prefix | |
Static Public Member Functions | |
| static BufferString | getTempDir () |
| static BufferString | getTempName (const char *ext=0) |
| static BufferString | mkCleanPath (const char *path, Style fmt) |
| static const char * | dirSep (Style) |
Static Public Attributes | |
| static const char * | sPrefSep |
Protected Member Functions | |
| void | addPart (const char *) |
| void | compress (int sl=0) |
| void | trueDirIfLink () |
Protected Attributes | |
| bool | isabs_ |
| BufferString | prefix_ |
| BufferStringSet | lvls_ |
File pathname tools.
This class splits a full filename (with path) into the separate parts: directories and possibly a filename (the last part does not have to be a file name). That makes it easy to change the file name, or the path only, or the extension, add directories, etc.
To get the result after manipulation, use the fullPath().
fileName() returns the last part, pathOnly() returns all but the last part. setFileName() replaces the last part, setPath() replaces all but the last part.
| enum FilePath::Style |
| FilePath::FilePath | ( | const char * | fullinp = 0 |
) |
| FilePath::FilePath | ( | const FilePath & | ) |
| FilePath& FilePath::add | ( | const char * | ) |
at end
| void FilePath::addPart | ( | const char * | ) | [protected] |
| void FilePath::compress | ( | int | sl = 0 |
) | [protected] |
| const BufferString& FilePath::dir | ( | int | nr = -1 |
) | const |
nr < 0 returns last dir name
| static const char* FilePath::dirSep | ( | Style | ) | [static] |
| BufferString FilePath::dirUpTo | ( | int | ) | const |
nr < 0 returns last dir, including prefix
| const char* FilePath::extension | ( | ) | const |
may return null
| const BufferString& FilePath::fileName | ( | ) | const |
| BufferString FilePath::fullPath | ( | Style | s = Local, |
|
| bool | cleanup = true | |||
| ) | const |
| static BufferString FilePath::getTempDir | ( | ) | [static] |
| static BufferString FilePath::getTempName | ( | const char * | ext = 0 |
) | [static] |
| FilePath& FilePath::insert | ( | const char * | ) |
after prefix at begin
| bool FilePath::isAbsolute | ( | ) | const |
If reldir is set, it will be filled with the relative.
| bool FilePath::makeCanonical | ( | ) |
| bool FilePath::makeRelativeTo | ( | const FilePath & | ) |
| static BufferString FilePath::mkCleanPath | ( | const char * | path, | |
| Style | fmt | |||
| ) | [static] |
| int FilePath::nrLevels | ( | ) | const |
| bool FilePath::operator!= | ( | const FilePath & | ) | const |
| bool FilePath::operator!= | ( | const char * | fnm | ) | const |
| FilePath& FilePath::operator= | ( | const char * | fullinp | ) |
| bool FilePath::operator== | ( | const char * | fnm | ) | const |
| bool FilePath::operator== | ( | const FilePath & | ) | const |
| BufferString FilePath::pathOnly | ( | ) | const |
| const char* FilePath::prefix | ( | ) | const |
| FilePath& FilePath::set | ( | const char * | fullinp | ) |
| void FilePath::setExtension | ( | const char * | , | |
| bool | replace = true | |||
| ) |
!replace => add
| void FilePath::setFileName | ( | const char * | ) |
pass null to remove level
| void FilePath::setPath | ( | const char * | ) |
including prefix
| void FilePath::trueDirIfLink | ( | ) | [protected] |
bool FilePath::isabs_ [protected] |
BufferStringSet FilePath::lvls_ [protected] |
BufferString FilePath::prefix_ [protected] |
const char* FilePath::sPrefSep [static] |
1.7.1