TGUI  1.0.0
Loading...
Searching...
No Matches
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.
 
TGUI_NODISCARD bool isEmpty () const
 Check if this object is empty.
 
TGUI_NODISCARD bool isAbsolute () const
 Checks whether the path is absolute.
 
TGUI_NODISCARD bool isRelative () const
 Checks whether the path is relative.
 
TGUI_NODISCARD String asString () const
 Returns the path as a string.
 
TGUI_NODISCARD Path getParentPath () const
 Returns to path to the parent directory.
 
TGUI_NODISCARD String getFilename () const
 Returns to filename component of the path (where the path consists of getParentPath() / getFilename())
 
TGUI_NODISCARD Path getNormalForm () const
 Returns the lexically normal form of the path (path with '.' and '..' resolved)
 
TGUI_NODISCARD std::string asNativeString () const
 Returns the path as a string, but with a string type and contents that depends on the OS.
 
TGUI_NODISCARD Path operator/ (const Path &path) const
 Returns a new path that consists of this object joined with another path.
 
TGUI_NODISCARD Path operator/ (const String &path) const
 Returns a new path that consists of this object joined with another path.
 
Pathoperator/= (const Path &path)
 Joins this object with another path.
 
Pathoperator/= (const String &path)
 Joins this object with another path.
 
TGUI_NODISCARD bool operator== (const Path &other) const
 Checks whether the paths are equal.
 
TGUI_NODISCARD bool operator!= (const Path &other) const
 Checks whether the paths are not equal.
 

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()

TGUI_NODISCARD 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()

TGUI_NODISCARD 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()

TGUI_NODISCARD 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()

TGUI_NODISCARD 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()

TGUI_NODISCARD 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()

TGUI_NODISCARD 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()

TGUI_NODISCARD 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()

TGUI_NODISCARD 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!=()

TGUI_NODISCARD 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]

TGUI_NODISCARD 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]

TGUI_NODISCARD 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==()

TGUI_NODISCARD 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: