common_util
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
cutl::filepath Class Reference

The class for file path operations. More...

#include <filepath.h>

Public Member Functions

 filepath (const std::string &path)
 Construct a new filepath object.
 
 filepath (const filepath &other)
 Construct a new filepath object by copy.
 
filepathoperator= (const filepath &other)
 Assign operator, assign a new filepath object by copy.
 
 ~filepath ()=default
 Destroy the filepath object.
 
std::string str () const
 Get the string of the filepath.
 
filepath join (const std::string &filename) const
 Join the current filepath with a new filename.
 
bool exists () const
 Check if the filepath is exists.
 
bool readable () const
 Check if the filepath is readable.
 
bool writable () const
 Check if the filepath is writable.
 
bool executable () const
 Check if the filepath is executable.
 
filetype type () const
 Get the file type of the filepath.
 
bool isfile () const
 Check if the filepath is a regular file.
 
bool isdir () const
 Check if the filepath is a directory.
 
bool issymlink () const
 Check if the filepath is a symbolic link.
 
std::string dirname () const
 Get the parent directory of the filepath.
 
std::string basename () const
 Get the filename or directory name of the filepath.
 
std::string realpath () const
 Get the real path referenced by symbolic link.
 
std::string abspath () const
 Get the absolute path of the filepath.
 
std::string extension () const
 Get the extension of the filepath.
 

Static Public Member Functions

static char separator ()
 Get the path separator of the current os platform.
 

Detailed Description

The class for file path operations.

Constructor & Destructor Documentation

◆ filepath() [1/2]

cutl::filepath::filepath ( const std::string & path)

Construct a new filepath object.

Parameters
pathfile path string

◆ filepath() [2/2]

cutl::filepath::filepath ( const filepath & other)

Construct a new filepath object by copy.

Parameters
otherother filepath object

Member Function Documentation

◆ abspath()

std::string cutl::filepath::abspath ( ) const

Get the absolute path of the filepath.

Returns
std::string the absolute path of the filepath.

◆ basename()

std::string cutl::filepath::basename ( ) const

Get the filename or directory name of the filepath.

Returns
filename or directory name

◆ dirname()

std::string cutl::filepath::dirname ( ) const

Get the parent directory of the filepath.

Returns
parent directory path

◆ executable()

bool cutl::filepath::executable ( ) const

Check if the filepath is executable.

Returns
true means executable, false means not executable.

◆ exists()

bool cutl::filepath::exists ( ) const

Check if the filepath is exists.

Returns
true means the filepath is exists, otherwise not exists.

◆ extension()

std::string cutl::filepath::extension ( ) const

Get the extension of the filepath.

Returns
extension with dot

◆ isdir()

bool cutl::filepath::isdir ( ) const

Check if the filepath is a directory.

Returns
true means directory, false means not directory.

◆ isfile()

bool cutl::filepath::isfile ( ) const

Check if the filepath is a regular file.

Returns
true mena regular file, false means not regular file.

◆ issymlink()

bool cutl::filepath::issymlink ( ) const

Check if the filepath is a symbolic link.

Returns
true means symbolic link, false means not symbolic link.

◆ join()

filepath cutl::filepath::join ( const std::string & filename) const

Join the current filepath with a new filename.

Parameters
filenamethe filename to be joined
Returns
the new filepath object

◆ operator=()

filepath & cutl::filepath::operator= ( const filepath & other)

Assign operator, assign a new filepath object by copy.

Parameters
otherother filepath object
Returns
filepath& the reference of the current filepath object

◆ readable()

bool cutl::filepath::readable ( ) const

Check if the filepath is readable.

Returns
true means readable, false means not readable.

◆ realpath()

std::string cutl::filepath::realpath ( ) const

Get the real path referenced by symbolic link.

Note
This function only works on Unix-like systems, not support on Windows.
Returns
real path referenced by symbolic link or shortcuts

◆ separator()

static char cutl::filepath::separator ( )
static

Get the path separator of the current os platform.

Returns
the path separator

◆ str()

std::string cutl::filepath::str ( ) const

Get the string of the filepath.

Returns
the filepath

◆ type()

filetype cutl::filepath::type ( ) const

Get the file type of the filepath.

Returns
file type

◆ writable()

bool cutl::filepath::writable ( ) const

Check if the filepath is writable.

Returns
true menas writable, false means not writable.

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