29#include <initializer_list>
79 Path(
const std::string & path ) ;
85 Path(
const char * path ) ;
88 Path(
const Path & path ,
const std::string & tail ) ;
91 Path(
const Path & path ,
const std::string & tail_1 ,
const std::string & tail_2 ) ;
94 Path(
const Path & path ,
const std::string & tail_1 ,
const std::string & tail_2 ,
const std::string & tail_3 ) ;
97 Path( std::initializer_list<std::string> ) ;
102 std::size_t
size() const noexcept ;
105 bool empty() const noexcept ;
111 const
char *
cstr() const noexcept ;
184 void swap(
Path & other ) noexcept ;
187 bool operator==( const
Path & path ) const ;
190 bool operator!=( const
Path & path ) const ;
207 friend class
G::PathFriend ;
214 return m_str.empty() ;
220 return m_str.size() ;
232 return m_str.c_str() ;
238 std::ostream & operator<<( std::ostream & stream ,
const Path & path )
240 return stream << path.
str() ;
244 Path & operator+=(
Path & p ,
const std::string &
str )
251 Path operator+(
const Path & p ,
const std::string &
str )
A Path object represents a file system path.
bool isAbsolute() const noexcept
Returns !isRelative().
Path withoutRoot() const
Returns a path without the root part.
void swap(Path &other) noexcept
Swaps this with other.
static bool less(const Path &a, const Path &b)
Compares two paths, with simple eight-bit lexicographical comparisons of each path component.
static Path join(const StringArray &parts)
Builds a path from a set of parts.
const char * cstr() const noexcept
Returns the path string.
std::string basename() const
Returns the rightmost part of the path, ignoring "." parts.
Path withoutExtension() const
Returns a path without the basename extension, if any.
Path dirname() const
Returns the path without the rightmost part, ignoring "." parts.
std::string extension() const
Returns the path's basename extension, ie.
bool simple() const
Returns true if the path has a single component (ignoring "." parts), ie.
Path & pathAppend(const std::string &tail)
Appends a filename or a relative path to this path.
static Path nullDevice()
Returns the path of the "/dev/null" special file, or equivalent.
Path withExtension(const std::string &ext) const
Returns the path with the new basename extension.
Path collapsed() const
Returns the path with "foo/.." and "." parts removed, so far as is possible without changing the mean...
bool isRelative() const noexcept
Returns true if the path is a relative path or empty().
static void setPosixStyle()
Sets posix mode for testing purposes.
std::size_t size() const noexcept
Returns the length of the path string.
std::string str() const
Returns the path string.
static void setWindowsStyle()
Sets windows mode for testing purposes.
StringArray split() const
Spits the path into a list of component parts (ignoring "." parts unless the whole path is "....
bool empty() const noexcept
Returns true if size() is zero.
Path()
Default constructor for a zero-length path.
static Path difference(const Path &p1, const Path &p2)
Returns the relative path from p1 to p2.
A class like c++17's std::string_view.
std::vector< std::string > StringArray
A std::vector of std::strings.