13#ifndef ZYPP_PATHNAME_H
14#define ZYPP_PATHNAME_H
52 Pathname(
const std::string & name_r )
57 {
_assign( name_r ? name_r :
"" ); }
68 swap( lhs._name, rhs._name );
78 {
swap( *
this, rhs );
return *
this; }
82 {
return( *
this =
cat( *
this, path_tv ) ); }
88 {
return( *
this =
cat( *
this, path_tv ) ); }
101 Url asUrl(
const std::string & scheme_r )
const;
110 const char *
c_str()
const
111 {
return _name.c_str(); }
141 {
return name_r.
relative() ?
cat(
"/", name_r ) : name_r; }
146 {
return name_r.
absolute() ?
cat(
".", name_r ) : name_r; }
175 void _assign(
const std::string & name_r );
180 inline bool operator==(
const Pathname & l,
const Pathname & r )
181 {
return l.asString() == r.asString(); }
184 inline bool operator!=(
const Pathname & l,
const Pathname & r )
185 {
return l.asString() != r.asString(); }
188 inline Pathname operator/(
const Pathname & l,
const Pathname & r )
194 inline Pathname operator+(
const Pathname & l,
const Pathname & r )
198 inline bool operator<(
const Pathname & l,
const Pathname & r )
199 {
return l.asString() < r.asString(); }
204 inline std::ostream &
operator<<( std::ostream &
str,
const Pathname & obj )
205 {
return str << obj.asString(); }
212 using filesystem::Pathname;
Pathname relativename() const
Return this path, removing a leading '/' if absolute.
static std::string showRoot(const Pathname &root_r, const Pathname &path_r)
String representation as "(root)/path".
Pathname extend(const std::string &r) const
Append string r to the last component of the path.
Pathname & operator/=(const Pathname &path_tv)
Concatenate and assign.
friend void swap(Pathname &lhs, Pathname &rhs)
Swap.
static Pathname stripprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r with any root_r dir prefix striped.
Pathname & operator+=(const Pathname &path_tv)
Concatenate and assign.
Pathname dirname() const
Return all but the last component od this path.
bool emptyOrRoot() const
Test for "" or "/".
bool absolute() const
Test for an absolute path.
Pathname cat(const Pathname &r) const
Concatenation of pathnames.
Pathname()
Default ctor: an empty path.
const char * c_str() const
String representation.
const std::string & asString() const
String representation.
std::string basename() const
Return the last component of this path.
bool empty() const
Test for an empty path.
static Pathname assertprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r prefixed with root_r, unless it is already prefixed.
void _assign(const std::string &name_r)
Pathname & operator=(Pathname rhs)
Assign.
Pathname absolutename() const
Return this path, adding a leading '/' if relative.
static std::string showRootIf(const Pathname &root_r, const Pathname &path_r)
String representation as "(root)/path", unless root is "/" or empty.
std::string extension() const
Return all of the characters in name after and including the last dot in the last element of name.
bool relative() const
Test for a relative path.
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, FileType obj)
Easy-to use interface to the ZYPP dependency resolver.
bool operator==(const Url &lhs, const Url &rhs)
needed for find
bool operator<(const Url &lhs, const Url &rhs)
needed for std::set
bool operator!=(const Url &lhs, const Url &rhs)