wex  v21.04.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
wex::path Class Reference

Offers functionality to handle paths. More...

#include <wex/path.h>

Public Types

enum  { STAT_SYNC = 0 , STAT_FULLPATH = 1 }
 Flags for path logging. More...
 

Public Member Functions

 path (const std::filesystem::path &p=std::filesystem::path(), status_t t=0)
 Others. More...
 
 path (const std::string &path)
 Constructor using string path.
 
 path (const std::string &path, const std::string &name)
 Constructor using a path and a name.
 
 path (const char *path)
 Constructor using a char array.
 
 path (const std::vector< std::string > &v)
 Constructor from a vector of paths.
 
 path (const path &r, status_t t=0)
 Copy constructor.
 
pathoperator= (const path &r)
 Assignment operator.
 
 ~path ()
 Destructor.
 
bool operator== (const path &r) const
 == Operator.
 
bool operator!= (const path &r) const
 != Operator.
 
pathappend (const path &path)
 Appends path.
 
const std::filesystem::path & data () const
 Returns the internal path.
 
bool dir_exists () const
 Returns true if the directory with this name exists.
 
bool empty () const
 Returns true if path is empty.
 
const std::string extension () const
 Returns path extension component (including the .).
 
bool file_exists () const
 Returns true if the file with this name exists.
 
const std::string fullname () const
 Returns path fullname (including extension) component.
 
const std::string get_path () const
 Returns path path component (without fullname).
 
bool is_absolute () const
 Returns true if this path is absolute.
 
bool is_readonly () const
 Returns true if this path (stat) is readonly.
 
bool is_relative () const
 Returns true if this path is relative.
 
const auto & lexer () const
 Returns the lexer.
 
std::stringstream log () const
 Logs info about this class.
 
pathmake_absolute ()
 Make this path absolute.
 
const std::string name () const
 Returns path name component.
 
bool open_mime () const
 Opens this path using registered mime type. More...
 
const auto & original ()
 Returns original path.
 
const std::vector< pathpaths () const
 Returns path components.
 
pathreplace_filename (const std::string &filename)
 Replaces filename.
 
const auto & stat () const
 Returns the stat.
 
const auto string () const
 Returns the path as a string.
 

Static Public Member Functions

static std::string current ()
 Static interface. More...
 
static void current (const std::string &path)
 Sets current path.
 

Detailed Description

Offers functionality to handle paths.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Flags for path logging.

Enumerator
STAT_SYNC 

shows 'synchronized' instead of 'modified'

STAT_FULLPATH 

shows file 'fullpath' instead of 'fullname'

Constructor & Destructor Documentation

◆ path()

wex::path::path ( const std::filesystem::path &  p = std::filesystem::path(),
status_t  t = 0 
)

Others.

Default constructor taking a path. If path is empty, it saves the current path, and when destructed restores it to current.

Parameters
pthe path
tthe status, used for log

Member Function Documentation

◆ current()

static std::string wex::path::current ( )
static

Static interface.

Returns current path.

◆ open_mime()

bool wex::path::open_mime ( ) const

Opens this path using registered mime type.

Returns false if no mime type is found.