TGUI  0.8.9
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)
 Default constructor that creates an empty path object. More...
 
bool isEmpty () const
 Check if this object is empty. More...
 
String asString () const
 Returns the path as a string. More...
 
Path getParentPath () const
 Returns to path to the parent directory. 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...
 

Detailed Description

Object to represent paths on a filesystem.

Constructor & Destructor Documentation

◆ Path()

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

Default constructor that creates an empty path object.

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.

◆ 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.

◆ 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

◆ 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

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