DUNE: Uniform Navigational Environment  2019.02.0
DUNE::FileSystem::Path Class Reference

Public Types

enum  Type {
  PT_DIRECTORY, PT_FILE, PT_DEVICE, PT_LINK,
  PT_INVALID
}
 
enum  Mode { MODE_NORMAL, MODE_RECURSIVE }
 

Public Member Functions

 Path (void)
 
 Path (const char *path)
 
 Path (const std::string &path)
 
Type type (void) const
 
bool exists (void) const
 
bool isFile (void) const
 
bool isDirectory (void) const
 
bool isLink (void) const
 
bool isDevice (void) const
 
bool isAbsolute (void) const
 
int64_t size (void) const
 
time_t getLastModifiedTime (void) const
 
void remove (Mode mode=MODE_NORMAL) const
 
void create (Mode mode=MODE_RECURSIVE) const
 
void copy (const Path &destination) const
 
Path absolute (void) const
 
Path root (void) const
 
Path basename (void) const
 
Path dirname (bool include_last_sep=true) const
 
std::string extension (void) const
 
std::string suffix (const Path &path, bool keep_first_sep=false) const
 
void normalize (void)
 
void contents (std::vector< Path > &dirs) const
 
void contents (std::vector< Path > &dirs, int min_depth, int max_depth, int depth=0) const
 
void clear (void)
 
bool empty (void) const
 
const std::string & str (void) const
 
const char * c_str (void) const
 

Static Public Member Functions

static const char * separator (void)
 
static unsigned int separatorLength (void)
 
static uint64_t storageCapacity (const Path &path)
 
static uint64_t storageAvailable (const Path &path)
 
static Path current (void)
 
static Path applicationFile (void)
 

Member Enumeration Documentation

Enumerator
MODE_NORMAL 

Operation will be performed with no recursion.

MODE_RECURSIVE 

Operation will be performed recursively.

Enumerator
PT_DIRECTORY 

Path is a directory.

PT_FILE 

Path is a regular file.

PT_DEVICE 

Path is a device file.

PT_LINK 

Path is a symbolic link.

PT_INVALID 

Path is invalid or non-existent.

Constructor & Destructor Documentation

DUNE::FileSystem::Path::Path ( void  )
inline

Referenced by create(), remove(), and root().

DUNE::FileSystem::Path::Path ( const char *  path)
inline

References normalize().

DUNE::FileSystem::Path::Path ( const std::string &  path)
inline

References normalize().

Member Function Documentation

Path DUNE::FileSystem::Path::absolute ( void  ) const
inline

References current(), separator(), and str().

Path DUNE::FileSystem::Path::applicationFile ( void  )
static

Retrieve the full path of the application's executable.

Returns
full path of the application's executable.

References DUNE::Utils::String::format(), and size().

Referenced by DUNE::Coordinates::WMM::WMM().

Path DUNE::FileSystem::Path::basename ( void  ) const

References separator().

Referenced by storageAvailable(), and storageCapacity().

void DUNE::FileSystem::Path::clear ( void  )
void DUNE::FileSystem::Path::contents ( std::vector< Path > &  dirs) const
inline
void DUNE::FileSystem::Path::contents ( std::vector< Path > &  dirs,
int  min_depth,
int  max_depth,
int  depth = 0 
) const
void DUNE::FileSystem::Path::copy ( const Path destination) const

References c_str(), and str().

void DUNE::FileSystem::Path::create ( Mode  mode = MODE_RECURSIVE) const

Create the path in the filesystem.

Only valid for directories.

Parameters
modecreation mode.

References isAbsolute(), isDirectory(), MODE_NORMAL, MODE_RECURSIVE, Path(), root(), separator(), DUNE::Utils::String::split(), and str().

Referenced by DUNE::Daemon::Daemon().

Path DUNE::FileSystem::Path::current ( void  )
static

Retrieve the full path of the current working directory.

Returns
full path of the current working directory.

Referenced by absolute().

Path DUNE::FileSystem::Path::dirname ( bool  include_last_sep = true) const

References separator().

bool DUNE::FileSystem::Path::empty ( void  ) const
bool DUNE::FileSystem::Path::exists ( void  ) const
inline

Check if the path exists.

Returns
true if the path exists, false otherwise.

References PT_INVALID, and type().

std::string DUNE::FileSystem::Path::extension ( void  ) const
time_t DUNE::FileSystem::Path::getLastModifiedTime ( void  ) const

References c_str().

bool DUNE::FileSystem::Path::isAbsolute ( void  ) const

Check if the path is absolute.

Returns
true if the path is absolute, false otherwise.

References separator(), and separatorLength().

Referenced by create(), normalize(), and root().

bool DUNE::FileSystem::Path::isDevice ( void  ) const
inline

Check if the path is a device file.

Returns
true if the path is a device file, false otherwise.

References PT_DEVICE, and type().

Referenced by DUNE::Math::Random::KernelDevice::available().

bool DUNE::FileSystem::Path::isDirectory ( void  ) const
inline

Check if the path is a directory.

Returns
true if the path is a directory, false otherwise.

References PT_DIRECTORY, and type().

Referenced by contents(), DUNE::Tasks::Context::Context(), create(), remove(), storageAvailable(), and storageCapacity().

bool DUNE::FileSystem::Path::isFile ( void  ) const
inline

Check if the path is a regular file.

Returns
true if the path is a regular file, false otherwise.

References PT_FILE, and type().

bool DUNE::FileSystem::Path::isLink ( void  ) const
inline

Check if the path is a symbolic link.

Returns
true if the path is a symbolic link, false otherwise.

References PT_LINK, and type().

void DUNE::FileSystem::Path::normalize ( void  )
void DUNE::FileSystem::Path::remove ( Mode  mode = MODE_NORMAL) const

Remove the path from the filesystem.

Parameters
moderemoval mode.

References isDirectory(), MODE_RECURSIVE, Path(), and DUNE::FileSystem::Directory::RD_FULL_NAME.

Path DUNE::FileSystem::Path::root ( void  ) const

References isAbsolute(), Path(), separator(), and separatorLength().

Referenced by create().

const char * DUNE::FileSystem::Path::separator ( void  )
static

Retrieve the string/character used as directory separator.

Returns
directory separator string.

Referenced by absolute(), basename(), create(), dirname(), isAbsolute(), normalize(), DUNE::FileSystem::operator/(), root(), and suffix().

unsigned int DUNE::FileSystem::Path::separatorLength ( void  )
static

Retrieve the length of the directory separator string.

Returns
length of the directory separator string.

Referenced by isAbsolute(), root(), and suffix().

int64_t DUNE::FileSystem::Path::size ( void  ) const

References c_str().

Referenced by applicationFile().

uint64_t DUNE::FileSystem::Path::storageAvailable ( const Path path)
static

Retrieve the amount of available storage of the device in which a path resides.

Parameters
pathpath.
Returns
available storage of the device in bytes.

References basename(), c_str(), isDirectory(), and str().

uint64_t DUNE::FileSystem::Path::storageCapacity ( const Path path)
static

Retrieve the capacity of the device in which a path resides.

Parameters
pathpath.
Returns
capacity of the device in bytes.

References basename(), c_str(), isDirectory(), and str().

Referenced by DUNE::Daemon::Daemon().

std::string DUNE::FileSystem::Path::suffix ( const Path path,
bool  keep_first_sep = false 
) const

References separator(), and separatorLength().

Path::Type DUNE::FileSystem::Path::type ( void  ) const

Retrieve the path type.

Returns
path type.

References PT_DEVICE, PT_DIRECTORY, PT_FILE, PT_INVALID, and PT_LINK.

Referenced by exists(), isDevice(), isDirectory(), isFile(), and isLink().

Collaboration diagram for DUNE::FileSystem::Path:
Collaboration graph