TGUI  0.10-beta
tgui::Filesystem::Path Class Reference

Object to represent paths on a filesystem. More...

#include <TGUI/Filesystem.hpp>

Public Member Functions

 Path ()=default
 Default constructor that creates an empty path object.
 
 Path (const String &path)
 Constructor that creates a Path object from the given path string. More...
 
bool isEmpty () const
 Check if this object is empty. More...
 
bool isAbsolute () const
 Checks whether the path is absolute. More...
 
bool isRelative () const
 Checks whether the path is relative. More...
 
String asString () const
 Returns the path as a string. More...
 
Path getParentPath () const
 Returns to path to the parent directory. More...
 
String getFilename () const
 Returns to filename component of the path (where the path consists of getParentPath() / getFilename()) More...
 
Path getNormalForm () const
 Returns the lexically normal form of the path (path with '.' and '..' resolved) More...
 
std::string asNativeString () const
 Returns the path as a string, but with a string type and contents that depends on the OS. More...
 
Path operator/ (const Path &path) const
 Returns a new path that consists of this object joined with another path. More...
 
Path operator/ (const String &path) const
 Returns a new path that consists of this object joined with another path. More...
 
Pathoperator/= (const Path &path)
 Joins this object with another path. More...
 
Pathoperator/= (const String &path)
 Joins this object with another path. More...
 
bool operator== (const Path &other) const
 Checks whether the paths are equal. More...
 
bool operator!= (const Path &other) const
 Checks whether the paths are not equal. More...
 

Detailed Description

Object to represent paths on a filesystem.

Constructor & Destructor Documentation

◆ Path()

tgui::Filesystem::Path::Path ( const String path)
explicit

Constructor that creates a Path object from the given path string.

Parameters
pathThe path to be parsed and stored in this object

Member Function Documentation

◆ asNativeString()

std::string tgui::Filesystem::Path::asNativeString ( ) const

Returns the path as a string, but with a string type and contents that depends on the OS.

Returns
The path stored in this object

An std::wstring is returned on Windows with backslashes as separator. On other platforms, a UTF-8 encoded std::string is returned with slashes as separator.

◆ asString()

String tgui::Filesystem::Path::asString ( ) const

Returns the path as a string.

Returns
The path stored in this object

Slashes are always used as separator on any OS so that relative paths are portable.

◆ getFilename()

String tgui::Filesystem::Path::getFilename ( ) const

Returns to filename component of the path (where the path consists of getParentPath() / getFilename())

Returns
Filename component of the path

◆ getNormalForm()

Path tgui::Filesystem::Path::getNormalForm ( ) const

Returns the lexically normal form of the path (path with '.' and '..' resolved)

Returns
Normal form of the path, based on the text representation (no filesystem access is done)

◆ getParentPath()

Path tgui::Filesystem::Path::getParentPath ( ) const

Returns to path to the parent directory.

Returns
Parent directory

If the path has a filename then the parent directory is the directory containing that file.

◆ isAbsolute()

bool tgui::Filesystem::Path::isAbsolute ( ) const

Checks whether the path is absolute.

An absolute path is a path that unambiguously identifies the location of a file without reference to an additional starting location.

Returns
True for absolute paths, false for relative paths

◆ isEmpty()

bool tgui::Filesystem::Path::isEmpty ( ) const

Check if this object is empty.

Returns
True when default-constructed or when set to an empty string, false otherwise

◆ isRelative()

bool tgui::Filesystem::Path::isRelative ( ) const

Checks whether the path is relative.

An absolute path is a path that unambiguously identifies the location of a file without reference to an additional starting location. A path is relative when it isn't an absolute path.

Returns
True for relative paths, false for absolute paths

◆ operator!=()

bool tgui::Filesystem::Path::operator!= ( const Path other) const

Checks whether the paths are not equal.

Parameters
otherThe path to compare with

This function only checks whether the path strings are identical or not.

◆ operator/() [1/2]

Path tgui::Filesystem::Path::operator/ ( const Path path) const

Returns a new path that consists of this object joined with another path.

Parameters
pathThe path to join to this one
Returns
The joined paths

◆ operator/() [2/2]

Path tgui::Filesystem::Path::operator/ ( const String path) const
inline

Returns a new path that consists of this object joined with another path.

Parameters
pathThe path to join to this one
Returns
The joined paths

◆ operator/=() [1/2]

Path & tgui::Filesystem::Path::operator/= ( const Path path)

Joins this object with another path.

Parameters
pathThe path to join to this one
Returns
Reference to this object

◆ operator/=() [2/2]

Path & tgui::Filesystem::Path::operator/= ( const String path)
inline

Joins this object with another path.

Parameters
pathThe path to join to this one
Returns
Reference to this object

◆ operator==()

bool tgui::Filesystem::Path::operator== ( const Path other) const

Checks whether the paths are equal.

Parameters
otherThe path to compare with

This function only checks whether the path strings are identical or not.


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