28#include <initializer_list>
78 Path(
const std::string & path ) ;
81 Path(
const char * path ) ;
84 Path(
const Path & path ,
const std::string & tail ) ;
87 Path(
const Path & path ,
const std::string & tail_1 ,
const std::string & tail_2 ) ;
90 Path(
const Path & path ,
const std::string & tail_1 ,
const std::string & tail_2 ,
const std::string & tail_3 ) ;
93 Path( std::initializer_list<std::string> ) ;
98 std::size_t
size() const noexcept ;
101 bool empty() const noexcept ;
104 std::
string str() const ;
107 const
char *
cstr() const noexcept ;
175 void swap(
Path & other ) noexcept ;
178 bool operator==( const
Path & path ) const ;
181 bool operator!=( const
Path & path ) const ;
205 return m_str.empty() ;
211 return m_str.size() ;
223 return m_str.c_str() ;
229 std::ostream & operator<<( std::ostream & stream ,
const Path & path )
231 return stream << path.
str() ;
235 Path & operator+=(
Path & p ,
const std::string &
str )
242 Path operator+(
const Path & p ,
const std::string &
str )
A private implementation class used by G::Path providing a set of static methods.
A Path object represents a file system path.
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.
bool isRelative() const
Returns true if the path is a relative path or empty().
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.
bool isAbsolute() const
Returns !isRelative().
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.
static Path nullDevice()
Returns the path of the "/dev/null" special file, or equivalent.
void pathAppend(const std::string &tail)
Appends a filename or a relative path to this path.
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...
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.
std::vector< std::string > StringArray
A std::vector of std::strings.