26#ifndef TGUI_FILESYSTEM_HPP
27#define TGUI_FILESYSTEM_HPP
29#include <TGUI/String.hpp>
34#ifdef TGUI_USE_STD_FILESYSTEM
72#ifdef TGUI_USE_STD_FILESYSTEM
80 template <
typename PathType, std::enable_if_t<std::is_same_v<PathType, std::filesystem::path>,
int> = 0>
81 explicit Path(
const PathType& path) :
161#ifdef TGUI_SYSTEM_WINDOWS
162 std::wstring asNativeString()
const;
167#ifdef TGUI_USE_STD_FILESYSTEM
171 operator const std::filesystem::path&()
const
196 return *
this /
Path(path);
219 return *
this /=
Path(path);
246#ifdef TGUI_USE_STD_FILESYSTEM
247 std::filesystem::path m_path;
249 std::vector<String> m_parts;
251 bool m_absolute =
false;
263 bool directory =
false;
264 std::uintmax_t fileSize = 0;
265 std::time_t modificationTime = 0;
288 return directoryExists(
Path{path});
311 return fileExists(
Path{path});
338 return createDirectory(
Path{path});
Object to represent paths on a filesystem.
Definition Filesystem.hpp:56
bool isEmpty() const
Check if this object is empty.
std::string asNativeString() const
Returns the path as a string, but with a string type and contents that depends on the OS.
bool isRelative() const
Checks whether the path is relative.
Path()=default
Default constructor that creates an empty path object.
String asString() const
Returns the path as a string.
Path getParentPath() const
Returns to path to the parent directory.
Path operator/(const Path &path) const
Returns a new path that consists of this object joined with another path.
bool operator!=(const Path &other) const
Checks whether the paths are not equal.
Path & operator/=(const Path &path)
Joins this object with another path.
Path & operator/=(const String &path)
Joins this object with another path.
Definition Filesystem.hpp:217
Path(const String &path)
Constructor that creates a Path object from the given path string.
String getFilename() const
Returns to filename component of the path (where the path consists of getParentPath() / getFilename()...
bool isAbsolute() const
Checks whether the path is absolute.
bool operator==(const Path &other) const
Checks whether the paths are equal.
Path operator/(const String &path) const
Returns a new path that consists of this object joined with another path.
Definition Filesystem.hpp:194
Path getNormalForm() const
Returns the lexically normal form of the path (path with '.' and '..' resolved)
Helper functionality for filesystem access.
Definition Filesystem.hpp:49
static bool directoryExists(const Path &path)
Checks if a directory exists.
static Path getLocalDataDirectory()
Returns the directory to store application data.
static bool fileExists(const String &path)
Checks if a file exists.
Definition Filesystem.hpp:309
static bool directoryExists(const String &path)
Checks if a directory exists.
Definition Filesystem.hpp:286
static std::vector< FileInfo > listFilesInDirectory(const Path &path)
Returns a list of all files and folders inside a given directory.
static bool fileExists(const Path &path)
Checks if a file exists.
static Path getCurrentWorkingDirectory()
Returns the current working directory.
static bool createDirectory(const Path &path)
Create a directory.
static Path getHomeDirectory()
Returns the home directory.
static bool createDirectory(const String &path)
Create a directory.
Definition Filesystem.hpp:336
Wrapper class to store strings.
Definition String.hpp:79
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36
Information about a file or directory, used to return data from the listFilesInDirectory function.
Definition Filesystem.hpp:260