Hermes
hermes::Path Class Reference

Representation of a directory/file in the filesystem. More...

Public Member Functions

 Path ()=default
 Default constructor.
 
 Path (const Str &path)
 Constructor from hermes::Str More...
 
 Path (const char *const &&path)
 Constructor from c string. More...
 
 Path (std::string path)
 Constructor from std::string More...
 
 Path (const Path &other)
 Copy constructor. More...
 
 Path (Path &&other) noexcept
 Move constructor.
 
 operator std::string () const
 Casts to std::string More...
 
Pathoperator= (const Path &path)
 Copy assignment. More...
 
bool operator== (const Path &b) const
 Full comparison. More...
 
Path operator+ (const Str &b) const
 Generates copy concatenated with separator. More...
 
Path operator/ (const Path &other) const
 Generates copy concatenated with separator. More...
 
Pathoperator/= (const Path &other)
 Joins with separator. More...
 
Pathoperator+= (const std::string &other)
 Joins with separator. More...
 
Pathoperator+= (const Path &other)
 Joins with separator. More...
 
Pathjoin (const Path &path)
 Joins with separator. More...
 
Pathcd (const std::string &path)
 Jump to path. More...
 
bool exists () const
 Check if this path exists in filesystem. More...
 
bool isDirectory () const
 Check if this path exists and represents a folder. More...
 
bool isFile () const
 Check if this path exists and represents a file. More...
 
bool hasExtension () const
 
std::vector< std::string > parts () const
 Splits this path into a list. More...
 
std::string name () const
 Gets last folder/file name. More...
 
const std::string & fullName () const
 Gets this full path string. More...
 
std::string extension () const
 Gets file extension. More...
 
bool match_r (const std::string &regular_expression) const
 Checks if this path matches pattern. More...
 
Path cwd () const
 Gets this path's folder location. More...
 
bool mkdir () const
 Creates folder from this path. More...
 
bool touch () const
 Creates empty file from this path. More...
 
u64 writeTo (const std::string &content) const
 Writes content into this file. More...
 
u64 appendTo (const std::string &content) const
 Appends to this file. More...
 
std::string read () const
 Reads ascii content from this file. More...
 

Public Attributes

std::string separator {"/"}
 OS path separator.
 

Detailed Description

Representation of a directory/file in the filesystem.

Constructor & Destructor Documentation

◆ Path() [1/4]

hermes::Path::Path ( const Str path)

Constructor from hermes::Str

Parameters
path

◆ Path() [2/4]

hermes::Path::Path ( const char *const &&  path)

Constructor from c string.

Parameters
path

◆ Path() [3/4]

hermes::Path::Path ( std::string  path)

Constructor from std::string

Parameters
path

◆ Path() [4/4]

hermes::Path::Path ( const Path other)

Copy constructor.

Parameters
other

Member Function Documentation

◆ appendTo()

u64 hermes::Path::appendTo ( const std::string &  content) const

Appends to this file.

Parameters
content
Returns

◆ cd()

Path & hermes::Path::cd ( const std::string &  path)

Jump to path.

Parameters
path

◆ cwd()

Path hermes::Path::cwd ( ) const

Gets this path's folder location.

Returns

◆ exists()

bool hermes::Path::exists ( ) const

Check if this path exists in filesystem.

Returns

◆ extension()

std::string hermes::Path::extension ( ) const

Gets file extension.

Returns

◆ fullName()

const std::string & hermes::Path::fullName ( ) const

Gets this full path string.

Returns

◆ hasExtension()

bool hermes::Path::hasExtension ( ) const
Returns

◆ isDirectory()

bool hermes::Path::isDirectory ( ) const

Check if this path exists and represents a folder.

Returns

◆ isFile()

bool hermes::Path::isFile ( ) const

Check if this path exists and represents a file.

Returns

◆ join()

Path & hermes::Path::join ( const Path path)

Joins with separator.

Parameters
path
Returns

◆ match_r()

bool hermes::Path::match_r ( const std::string &  regular_expression) const

Checks if this path matches pattern.

Parameters
regular_expression
Returns

◆ mkdir()

bool hermes::Path::mkdir ( ) const

Creates folder from this path.

Returns

◆ name()

std::string hermes::Path::name ( ) const

Gets last folder/file name.

Returns

◆ operator std::string()

hermes::Path::operator std::string ( ) const
inlineexplicit

Casts to std::string

Returns

◆ operator+()

Path hermes::Path::operator+ ( const Str b) const

Generates copy concatenated with separator.

Parameters
b
Returns

◆ operator+=() [1/2]

Path & hermes::Path::operator+= ( const Path other)

Joins with separator.

Parameters
other
Returns

◆ operator+=() [2/2]

Path & hermes::Path::operator+= ( const std::string &  other)

Joins with separator.

Parameters
other
Returns

◆ operator/()

Path hermes::Path::operator/ ( const Path other) const

Generates copy concatenated with separator.

Parameters
other
Returns

◆ operator/=()

Path & hermes::Path::operator/= ( const Path other)

Joins with separator.

Parameters
other
Returns

◆ operator=()

Path & hermes::Path::operator= ( const Path path)

Copy assignment.

Parameters
path
Returns

◆ operator==()

bool hermes::Path::operator== ( const Path b) const

Full comparison.

Parameters
b
Returns

◆ parts()

std::vector< std::string > hermes::Path::parts ( ) const

Splits this path into a list.

Returns

◆ read()

std::string hermes::Path::read ( ) const

Reads ascii content from this file.

Returns

◆ touch()

bool hermes::Path::touch ( ) const

Creates empty file from this path.

Returns

◆ writeTo()

u64 hermes::Path::writeTo ( const std::string &  content) const

Writes content into this file.

Parameters
content
Returns

The documentation for this class was generated from the following files: