tue_filesystem
Public Member Functions | Private Attributes | Friends | List of all members
tue::filesystem::Path Class Reference

#include <path.h>

Public Member Functions

bool exists () const
 
std::string extension () const
 
std::string filename () const
 
bool isDirectory () const
 
bool isRegularFile () const
 
Path join (const Path &path) const
 
std::time_t lastWriteTime () const
 
Path parentPath () const
 
 Path ()
 
 Path (const char *path)
 
 Path (const std::string &path)
 
PathremoveExtension ()
 
const std::stringstring () const
 
Path withoutExtension () const
 
virtual ~Path ()
 

Private Attributes

std::string path_
 Text of the file system path. More...
 

Friends

std::ostreamoperator<< (std::ostream &out, const Path &p)
 

Detailed Description

Path class for a file system path, providing several useful functions for querying and manipulating a path.

Definition at line 18 of file path.h.

Constructor & Destructor Documentation

◆ Path() [1/3]

tue::filesystem::Path::Path ( )

Definition at line 11 of file path.cpp.

◆ Path() [2/3]

tue::filesystem::Path::Path ( const std::string path)

Definition at line 15 of file path.cpp.

◆ Path() [3/3]

tue::filesystem::Path::Path ( const char *  path)
inline

Overloaded constructor for char* paths.

Parameters
pathPath to set in the object.

Definition at line 34 of file path.h.

◆ ~Path()

tue::filesystem::Path::~Path ( )
virtual

Destructor

Definition at line 19 of file path.cpp.

Member Function Documentation

◆ exists()

bool tue::filesystem::Path::exists ( ) const

Verify whether the path actually exists at the file system.

Returns
Whether the path represents an existing path at the file system at the time of the call.

Definition at line 42 of file path.cpp.

◆ extension()

std::string tue::filesystem::Path::extension ( ) const

Get the last extension of the path if available.

Returns
The last extension of the path including the leading dot, or the empty string.

Definition at line 23 of file path.cpp.

◆ filename()

std::string tue::filesystem::Path::filename ( ) const

Return the part of the path after the last directory separator.

Returns
The name part after the last directory separator, if it exists. If the path represents the file system root ("/"), the path itself is returned, else "." is returned.

Definition at line 28 of file path.cpp.

◆ isDirectory()

bool tue::filesystem::Path::isDirectory ( ) const

Test whether the path is a directory.

Returns
Whether the path is a directory.
Note
Getting false does not imply the path is a regular file.

Definition at line 52 of file path.cpp.

◆ isRegularFile()

bool tue::filesystem::Path::isRegularFile ( ) const

Test whether the path is a regular file.

Returns
Whether the path is a regular file.
Note
Getting false does not imply the path is a directory.

Definition at line 47 of file path.cpp.

◆ join()

Path tue::filesystem::Path::join ( const Path path) const

Construct a new path by appending the given sub_path to this path.

Parameters
pathPath to append to this path.
Returns
New path consisting of this path, appended with sub_path.

Definition at line 85 of file path.cpp.

◆ lastWriteTime()

std::time_t tue::filesystem::Path::lastWriteTime ( ) const

Get the last modification time of the path at the file system as reported by the OS. For directories, this may not include last modification time of its content.

Returns
Last modification time of the path.

Definition at line 57 of file path.cpp.

◆ parentPath()

Path tue::filesystem::Path::parentPath ( ) const

Get the parent directory of the path.

Returns
The empty string is the path is the file system root ("/"), else the path without the filename() part and last directory separator.

Definition at line 33 of file path.cpp.

◆ removeExtension()

Path & tue::filesystem::Path::removeExtension ( )

Remove the extension from the path.

Returns
The object after removal of the last extension.

Definition at line 62 of file path.cpp.

◆ string()

const std::string& tue::filesystem::Path::string ( ) const
inline

Get the complete path.

Returns
The entire path, as stored in in the object.

Definition at line 45 of file path.h.

◆ withoutExtension()

Path tue::filesystem::Path::withoutExtension ( ) const

Construct a new path from this path while removing the extension from it.

Returns
Same path as the object, but without last extension.

Definition at line 72 of file path.cpp.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream out,
const Path p 
)
friend

Definition at line 117 of file path.h.

Member Data Documentation

◆ path_

std::string tue::filesystem::Path::path_
private

Text of the file system path.

Definition at line 124 of file path.h.


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