wex v24.10.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/core/path.h>

Inheritance diagram for wex::path:
Inheritance graph
[legend]

Public Types

enum  { LOG_MOD = 0 , LOG_SYNC = 1 , LOG_PATH = 2 }
 Flags for path logging. More...
 
typedef std::bitset< 3 > log_t
 A typedef containing log flags.
 

Public Member Functions

 path (const std::filesystem::path &p=std::filesystem::path(), log_t t=0)
 Default constructor taking a std::filesystem::path.
 
 path (const std::string &path, log_t t=0)
 Constructor using string path.
 
 path (const char *path, log_t t=0)
 Constructor using a char array.
 
 path (const std::vector< std::string > &v, log_t t=0)
 Constructor from a vector of paths.
 
 path (const path &p, const std::string &name, log_t=0)
 Constructor using a path and a name.
 
 path (const path &r)
 Copy constructor.
 
 ~path ()
 Destructor.
 
auto operator<=> (const path &r) const
 Spaceship 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.
 
bool exists () const
 Returns true if path corresponds to an existing file or directory.
 
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 filename () const
 Returns path filename (including extension) component.
 
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.
 
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.
 
const auto & original ()
 Returns original path.
 
const std::string parent_path () const
 Returns path path component.
 
const std::vector< pathpaths () const
 Returns path components.
 
pathreplace_filename (const std::string &filename)
 Replaces filename.
 
void set_log (const log_t &t)
 Sets new log type.
 
const auto & stat () const
 Returns the stat.
 
const auto string () const
 Returns the path as a string.
 

Static Public Member Functions

static wex::path current ()
 Returns current path.
 
static void current (const wex::path &p)
 Sets current path.
 

Detailed Description

Offers functionality to handle paths.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Flags for path logging.

Default only logs the filename (all flags are off).

Enumerator
LOG_MOD 

adds 'modified'

LOG_SYNC 

adds 'synchronized'

LOG_PATH 

uses 'path' instead of 'filename'

Constructor & Destructor Documentation

◆ path()

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

Default constructor taking a std::filesystem::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

◆ open_mime()

bool wex::path::open_mime ( ) const

Opens this path using registered mime type.

Returns false if no mime type is found.