Kea 3.1.1
isc::util::file::Path Struct Reference

Paths on a filesystem. More...

#include <filesystem.h>

Public Member Functions

 Path (std::string const &path)
 Constructor.
 
std::string extension () const
 Get the extension of the file.
 
std::string filename () const
 Get the name of the file, extension included.
 
std::string parentDirectory () const
 Get the parent directory.
 
std::string parentPath () const
 Get the parent path.
 
PathreplaceExtension (std::string const &replacement=std::string())
 Identifies the extension in {replacement}, trims it, and replaces this instance's extension with it.
 
PathreplaceParentPath (std::string const &replacement=std::string())
 Trims {replacement} and replaces this instance's parent path with it.
 
std::string stem () const
 Get the base name of the file without the extension.
 
std::string str () const
 Get the path in textual format.
 

Detailed Description

Paths on a filesystem.

Definition at line 107 of file filesystem.h.

Constructor & Destructor Documentation

◆ Path()

isc::util::file::Path::Path ( std::string const & path)

Constructor.

Splits the full name into components.

Definition at line 112 of file filesystem.cc.

Member Function Documentation

◆ extension()

string isc::util::file::Path::extension ( ) const

Get the extension of the file.

Counterpart for std::filesystem::path::extension.

Returns
extension of current path.

Definition at line 174 of file filesystem.cc.

◆ filename()

string isc::util::file::Path::filename ( ) const

Get the name of the file, extension included.

Counterpart for std::filesystem::path::filename.

Returns
name + extension of current path.

Definition at line 179 of file filesystem.cc.

Referenced by isc::util::file::PathChecker::validatePath().

◆ parentDirectory()

string isc::util::file::Path::parentDirectory ( ) const

Get the parent directory.

Empty if no directory is present, the parent path follwed by a slash otherwise.

Returns
parent directory of current path.

Definition at line 164 of file filesystem.cc.

Referenced by isc::process::Daemon::checkWriteConfigFile(), and isc::util::file::PathChecker::validatePath().

◆ parentPath()

string isc::util::file::Path::parentPath ( ) const

Get the parent path.

Counterpart for std::filesystem::path::parent_path.

Returns
parent path of current path.

Definition at line 159 of file filesystem.cc.

Referenced by isc::util::file::PathChecker::validatePath().

◆ replaceExtension()

Path & isc::util::file::Path::replaceExtension ( std::string const & replacement = std::string())

Identifies the extension in {replacement}, trims it, and replaces this instance's extension with it.

Counterpart for std::filesystem::path::replace_extension.

The change is done in the members and {this} is returned to allow call chaining.

Parameters
replacementThe extension to replace with.
Returns
The current instance after the replacement was done.

Definition at line 184 of file filesystem.cc.

References isc::util::str::trim().

+ Here is the call graph for this function:

◆ replaceParentPath()

Path & isc::util::file::Path::replaceParentPath ( std::string const & replacement = std::string())

Trims {replacement} and replaces this instance's parent path with it.

The change is done in the members and {this} is returned to allow call chaining.

Parameters
replacementThe parent path to replace with.
Returns
The current instance after the replacement was done.

Definition at line 200 of file filesystem.cc.

References isc::util::str::trim().

Referenced by writeHeaderFile(), and writeProgramFile().

+ Here is the call graph for this function:

◆ stem()

string isc::util::file::Path::stem ( ) const

Get the base name of the file without the extension.

Counterpart for std::filesystem::path::stem.

Returns
the base name of current path without the extension.

Definition at line 169 of file filesystem.cc.

Referenced by isc::process::Daemon::checkWriteConfigFile().

◆ str()

string isc::util::file::Path::str ( ) const

Get the path in textual format.

Counterpart for std::filesystem::path::string.

Returns
stored filename.

Definition at line 154 of file filesystem.cc.

Referenced by isc::util::file::PathChecker::validatePath(), writeHeaderFile(), and writeProgramFile().


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