26#ifndef TGUI_FILESYSTEM_HPP
27#define TGUI_FILESYSTEM_HPP
29#include <TGUI/String.hpp>
31#if !TGUI_EXPERIMENTAL_USE_STD_MODULE
36 #ifdef TGUI_USE_STD_FILESYSTEM
43TGUI_MODULE_EXPORT
namespace tgui
75#ifdef TGUI_USE_STD_FILESYSTEM
83 template <
typename PathType, std::enable_if_t<std::is_same_v<PathType, std::filesystem::path>,
int> = 0>
84 explicit Path(
const PathType& path) :
164#ifdef TGUI_SYSTEM_WINDOWS
165 TGUI_NODISCARD std::wstring asNativeString()
const;
170#ifdef TGUI_USE_STD_FILESYSTEM
174 operator const std::filesystem::path&()
const
199 return *
this /
Path(path);
222 return *
this /=
Path(path);
249#ifdef TGUI_USE_STD_FILESYSTEM
250 std::filesystem::path m_path;
252 std::vector<String> m_parts;
254 bool m_absolute =
false;
266 bool directory =
false;
267 std::uintmax_t fileSize = 0;
268 std::time_t modificationTime = 0;
291 return directoryExists(
Path{path});
314 return fileExists(
Path{path});
341 return createDirectory(
Path{path});
Object to represent paths on a filesystem.
Definition Filesystem.hpp:59
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 bool operator!=(const Path &other) const
Checks whether the paths are not equal.
TGUI_NODISCARD bool isAbsolute() const
Checks whether the path is absolute.
Path()=default
Default constructor that creates an empty path object.
TGUI_NODISCARD bool operator==(const Path &other) const
Checks whether the paths are equal.
TGUI_NODISCARD bool isEmpty() const
Check if this object is empty.
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:220
Path(const String &path)
Constructor that creates a Path object from the given path string.
TGUI_NODISCARD Path operator/(const String &path) const
Returns a new path that consists of this object joined with another path.
Definition Filesystem.hpp:197
TGUI_NODISCARD Path getParentPath() const
Returns to path to the parent directory.
TGUI_NODISCARD String asString() const
Returns the path as a string.
TGUI_NODISCARD Path getNormalForm() const
Returns the lexically normal form of the path (path with '.' and '..' resolved)
TGUI_NODISCARD bool isRelative() const
Checks whether the path is relative.
TGUI_NODISCARD Path operator/(const Path &path) const
Returns a new path that consists of this object joined with another path.
TGUI_NODISCARD String getFilename() const
Returns to filename component of the path (where the path consists of getParentPath() / getFilename()...
Helper functionality for filesystem access.
Definition Filesystem.hpp:52
static TGUI_NODISCARD std::vector< FileInfo > listFilesInDirectory(const Path &path)
Returns a list of all files and folders inside a given directory.
static TGUI_NODISCARD Path getLocalDataDirectory()
Returns the directory to store application data.
static TGUI_NODISCARD bool fileExists(const String &path)
Checks if a file exists.
Definition Filesystem.hpp:312
static bool createDirectory(const Path &path)
Create a directory.
static TGUI_NODISCARD bool fileExists(const Path &path)
Checks if a file exists.
static TGUI_NODISCARD Path getHomeDirectory()
Returns the home directory.
static TGUI_NODISCARD bool directoryExists(const Path &path)
Checks if a directory exists.
static bool createDirectory(const String &path)
Create a directory.
Definition Filesystem.hpp:339
static TGUI_NODISCARD Path getCurrentWorkingDirectory()
Returns the current working directory.
static TGUI_NODISCARD bool directoryExists(const String &path)
Checks if a directory exists.
Definition Filesystem.hpp:289
Wrapper class to store strings.
Definition String.hpp:101
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39
Information about a file or directory, used to return data from the listFilesInDirectory function.
Definition Filesystem.hpp:263