libzypp 8.13.6
|
#include <Pathname.h>
Public Member Functions | |
Pathname () | |
Default ctor: an empty path. | |
Pathname (const std::string &name_tv) | |
Ctor from string. | |
Pathname (const char *name_tv) | |
Ctor from char*. | |
Pathname & | operator= (const Pathname &path_tv) |
Assign. | |
Pathname & | operator/= (const Pathname &path_tv) |
Concatenate and assing. | |
Pathname & | operator+= (const Pathname &path_tv) |
Concatenate and assing. | |
const std::string & | asString () const |
String representation. | |
Url | asUrl () const |
Url representation using dir schema. | |
const char * | c_str () const |
String representation. | |
bool | empty () const |
Test for an empty path. | |
bool | absolute () const |
Test for an absolute path. | |
bool | relative () const |
Test for a relative path. | |
Pathname | dirname () const |
Return all but the last component od this path. | |
std::string | basename () const |
Return the last component of this path. | |
std::string | extension () const |
Return all of the characters in name after and including the last dot in the last element of name. | |
Pathname | absolutename () const |
Return this path, adding a leading '/' if relative. | |
Pathname | relativename () const |
Return this path, removing a leading '/' if absolute. | |
Pathname | cat (const Pathname &r) const |
Concatenation of pathnames. | |
Pathname | extend (const std::string &r) const |
Append string r to the last component of the path. | |
Static Public Member Functions | |
static std::string | showRoot (const Pathname &root_r, const Pathname &path_r) |
String representation as "(root)/path". | |
static std::string | showRootIf (const Pathname &root_r, const Pathname &path_r) |
String representation as "(root)/path", unless root is "/" or empty. | |
static Pathname | dirname (const Pathname &name_tv) |
static std::string | basename (const Pathname &name_tv) |
static std::string | extension (const Pathname &name_tv) |
static Pathname | absolutename (const Pathname &name_tv) |
static Pathname | relativename (const Pathname &name_tv) |
static Pathname | assertprefix (const Pathname &root_r, const Pathname &path_r) |
Return path_r prefixed with root_r , unless it is already prefixed. | |
static Pathname | cat (const Pathname &l, const Pathname &r) |
static Pathname | extend (const Pathname &l, const std::string &r) |
Private Member Functions | |
void | _assign (const std::string &name_tv) |
Private Attributes | |
std::string::size_type | prfx_i |
std::string | name_t |
Related Functions | |
(Note that these are not member functions.) | |
bool | operator== (const Pathname &l, const Pathname &r) |
bool | operator!= (const Pathname &l, const Pathname &r) |
Pathname | operator/ (const Pathname &l, const Pathname &r) |
Pathname | operator+ (const Pathname &l, const Pathname &r) |
bool | operator< (const Pathname &l, const Pathname &r) |
std::ostream & | operator<< (std::ostream &str, const Pathname &obj) |
Always stores normalized paths (no inner '.' or '..' components and no consecutive '/'es). Concatenation automatically adds the path separator '/'.
Add support for handling extensions incl. stripping extensions from basename (basename("/path/foo.baa", ".baa") ==> "foo")
Review. Maybe use COW pimpl, check storage.
EXPLICIT ctors.
Definition at line 45 of file Pathname.h.
zypp::filesystem::Pathname::Pathname | ( | ) | [inline] |
Default ctor: an empty path.
Definition at line 49 of file Pathname.h.
zypp::filesystem::Pathname::Pathname | ( | const std::string & | name_tv | ) | [inline] |
zypp::filesystem::Pathname::Pathname | ( | const char * | name_tv | ) | [inline] |
Concatenate and assing.
Definition at line 76 of file Pathname.h.
References cat().
const std::string& zypp::filesystem::Pathname::asString | ( | ) | const [inline] |
String representation.
Definition at line 80 of file Pathname.h.
References name_t.
Referenced by zypp::filesystem::assert_dir(), assertprefix(), zypp::filesystem::PathInfo::asString(), asUrl(), basename(), zypp::filesystem::PathInfo::c_str(), cat(), zypp::filesystem::checksum(), zypp::filesystem::chmod(), zypp::filesystem::copy(), zypp::filesystem::copy_dir(), zypp::filesystem::copy_dir_content(), zypp::filesystem::copy_file2dir(), zypp::filesystem::hardlink(), zypp::filesystem::hardlinkCopy(), zypp::filesystem::is_empty_dir(), zypp::filesystem::md5sum(), zypp::filesystem::mkdir(), operator!=(), zypp::filesystem::PathInfo::operator()(), operator<(), operator<<(), operator==(), zypp::filesystem::rename(), showRootIf(), zypp::filesystem::symlink(), zypp::filesystem::TmpDir::TmpDir(), zypp::filesystem::TmpFile::TmpFile(), and zypp::filesystem::zipType().
std::string zypp::filesystem::Pathname::showRoot | ( | const Pathname & | root_r, |
const Pathname & | path_r | ||
) | [static] |
String representation as "(root)/path".
Definition at line 243 of file Pathname.cc.
Referenced by showRootIf().
std::string zypp::filesystem::Pathname::showRootIf | ( | const Pathname & | root_r, |
const Pathname & | path_r | ||
) | [static] |
String representation as "(root)/path", unless root is "/"
or empty.
Definition at line 248 of file Pathname.cc.
References asString(), empty(), and showRoot().
Url zypp::filesystem::Pathname::asUrl | ( | ) | const |
Url representation using dir
schema.
Definition at line 236 of file Pathname.cc.
References asString(), and zypp::Url::setPathName().
const char* zypp::filesystem::Pathname::c_str | ( | ) | const [inline] |
String representation.
Definition at line 93 of file Pathname.h.
References name_t.
Referenced by zypp::filesystem::Glob::add(), zypp::filesystem::Glob::collect(), zypp::filesystem::df(), zypp::filesystem::exchange(), zypp::filesystem::readlink(), zypp::readPoolQueriesFromFile(), zypp::filesystem::recursive_rmdir_1(), and zypp::writePoolQueriesToFile().
bool zypp::filesystem::Pathname::empty | ( | ) | const [inline] |
Test for an empty path.
Definition at line 97 of file Pathname.h.
References name_t.
Referenced by absolute(), zypp::filesystem::assert_dir(), assertprefix(), basename(), cat(), dirname(), zypp::filesystem::exchange(), extension(), zypp::filesystem::PathInfo::operator()(), relative(), and showRootIf().
bool zypp::filesystem::Pathname::absolute | ( | ) | const [inline] |
Test for an absolute path.
Definition at line 99 of file Pathname.h.
References empty(), name_t, and prfx_i.
Referenced by relativename().
bool zypp::filesystem::Pathname::relative | ( | ) | const [inline] |
Test for a relative path.
Definition at line 101 of file Pathname.h.
References empty(), name_t, and prfx_i.
Referenced by absolutename(), and zypp::filesystem::assert_dir().
Pathname zypp::filesystem::Pathname::dirname | ( | ) | const [inline] |
Return all but the last component od this path.
Definition at line 104 of file Pathname.h.
References dirname().
Referenced by zypp::filesystem::assert_file(), dirname(), zypp::filesystem::exchange(), zypp::filesystem::expandlink(), zypp::filesystem::TmpDir::makeSibling(), and zypp::filesystem::TmpFile::makeSibling().
Definition at line 190 of file Pathname.cc.
std::string zypp::filesystem::Pathname::basename | ( | ) | const [inline] |
Return the last component of this path.
Definition at line 108 of file Pathname.h.
References basename().
Referenced by basename(), zypp::filesystem::copy_dir(), extension(), zypp::filesystem::TmpDir::makeSibling(), and zypp::filesystem::TmpFile::makeSibling().
string zypp::filesystem::Pathname::basename | ( | const Pathname & | name_tv | ) | [static] |
Definition at line 216 of file Pathname.cc.
References asString(), empty(), and prfx_i.
std::string zypp::filesystem::Pathname::extension | ( | ) | const [inline] |
Return all of the characters in name after and including the last dot in the last element of name.
If there is no dot in the last element of name then returns the empty string.
Definition at line 115 of file Pathname.h.
References extension().
Referenced by extension().
string zypp::filesystem::Pathname::extension | ( | const Pathname & | name_tv | ) | [static] |
Definition at line 260 of file Pathname.cc.
References basename(), and empty().
Pathname zypp::filesystem::Pathname::absolutename | ( | ) | const [inline] |
Return this path, adding a leading '/' if relative.
Definition at line 119 of file Pathname.h.
References absolutename().
Referenced by absolutename().
static Pathname zypp::filesystem::Pathname::absolutename | ( | const Pathname & | name_tv | ) | [inline, static] |
Definition at line 120 of file Pathname.h.
References cat(), and relative().
Pathname zypp::filesystem::Pathname::relativename | ( | ) | const [inline] |
Return this path, removing a leading '/' if absolute.
Definition at line 124 of file Pathname.h.
References relativename().
Referenced by relativename().
static Pathname zypp::filesystem::Pathname::relativename | ( | const Pathname & | name_tv | ) | [inline, static] |
Definition at line 125 of file Pathname.h.
References absolute(), and cat().
Pathname zypp::filesystem::Pathname::assertprefix | ( | const Pathname & | root_r, |
const Pathname & | path_r | ||
) | [static] |
Return path_r
prefixed with root_r
, unless it is already prefixed.
Definition at line 277 of file Pathname.cc.
References asString(), empty(), and zypp::str::hasPrefix().
Concatenation of pathnames.
"foo" / "baa" ==> "foo/baa" "foo/" / "baa" ==> "foo/baa" "foo" / "/baa" ==> "foo/baa" "foo/" / "/baa" ==> "foo/baa"
Definition at line 139 of file Pathname.h.
References cat().
Referenced by absolutename(), cat(), operator+(), operator+=(), operator/(), operator/=(), and relativename().
Definition at line 291 of file Pathname.cc.
References asString(), empty(), and prfx_i.
Pathname zypp::filesystem::Pathname::extend | ( | const std::string & | r | ) | const [inline] |
Append string r to the last component of the path.
"foo/baa".extend( ".h" ) ==> "foo/baa.h"
Definition at line 147 of file Pathname.h.
References extend().
Referenced by extend().
static Pathname zypp::filesystem::Pathname::extend | ( | const Pathname & | l, |
const std::string & | r | ||
) | [static] |
void zypp::filesystem::Pathname::_assign | ( | const std::string & | name_tv | ) | [private] |
Definition at line 131 of file Pathname.cc.
References name_t, and prfx_i.
Referenced by Pathname().
Definition at line 159 of file Pathname.h.
References asString().
Definition at line 163 of file Pathname.h.
References asString().
Concatenate two Pathname.
Definition at line 173 of file Pathname.h.
References cat().
Definition at line 177 of file Pathname.h.
References asString().
std::ostream & operator<< | ( | std::ostream & | str, |
const Pathname & | obj | ||
) | [related] |
std::string::size_type zypp::filesystem::Pathname::prfx_i [private] |
Definition at line 151 of file Pathname.h.
Referenced by _assign(), absolute(), basename(), cat(), dirname(), operator=(), and relative().
std::string zypp::filesystem::Pathname::name_t [private] |
Definition at line 152 of file Pathname.h.
Referenced by _assign(), absolute(), asString(), c_str(), dirname(), empty(), operator=(), and relative().