|
CeresEngine 0.2.0
A game development framework
|
Path to file or directory. More...
#include <CeresEngine/Foundation/IO/FilePath.hpp>
Public Member Functions | |
| FilePath () | |
Creates a new empty FilePath. | |
| FilePath (StringView path) | |
Creates a new FilePath from a string view that represents a path. | |
| FilePath (String &&path) | |
Creates a new FilePath by moving the contents of a path string. | |
| FilePath (const char *path) | |
Creates a new FilePath from a const char* string. | |
| FilePath (const FilePath &)=default | |
| FilePath (FilePath &&)=default | |
| FilePath & | operator= (const FilePath &)=default |
| FilePath & | operator= (FilePath &&)=default |
| virtual | ~FilePath () |
Destroys the FilePath instance. | |
| StringView | getPath () const |
| Get path as string. | |
| String | toNative () const |
| Gets the native path as string. | |
| bool | isEmpty () const |
| Checks if path is empty. | |
| StringView | getFullPath () const |
| Gets full path. | |
| StringView | getFileName () const |
| Gets file name from the path. | |
| StringView | getBaseName () const |
| Gets the path base name. | |
| StringView | getExtension () const |
| Gets the path file extension. | |
| StringView | getParent () const |
| Gets the directory path. | |
| FilePath | getParentPath () const |
| Gets the directory path. | |
| StringView | getDriveLetter () const |
| Gets drive letter on a Windows-style path. | |
| bool | isAbsolute () const |
| Checks if path is an absolute path. | |
| bool | isRelative () const |
| Check if path is a relative. | |
| FilePath | resolve (const FilePath &path) const |
Resolves a relative path from path. | |
| FilePath | normalize () const |
| Gets the normalized path (removed '. | |
| FilePath | relativize (const FilePath &base) const |
Relativizes this path to be a relative path from base. | |
| FilePath & | makeRelative () |
| FilePath | toRelative () const & |
| FilePath && | toRelative () && |
| FilePath & | makeAbsolute () |
| FilePath | toAbsolute () const & |
| FilePath && | toAbsolute () && |
| FilePath | operator/ (const FilePath &other) const |
| FilePath & | operator/= (const FilePath &other) |
| const String & | toString () const |
| The underlying path as a string in the unified format. | |
| std::filesystem::path | toStdPath () const |
Protected Member Functions | |
| void | setPath (StringView path) |
| Sets a new path. Converts the path into the internal format. | |
| void | setPath (String &&path) |
| Sets a new path. Converts the path into the internal format. | |
Private Attributes | |
| String | mPath |
| The underlying path as a string in the unified format. | |
Path to file or directory.
This class stores a path to a file or directory and provides common operations like getting the file name or extension.
FilePath uses a unified format for storing paths that can be used consistently on every platform, using only '/' as a separator. When a FilePath is constructed from a string, the path is translated into the unified format and can then be used in a cross-platform way throughout an application. All operations on FilePath also return paths in the same unified format. To obtain a path in native platform format, use toNative().
All operations are completely string-based and don't use any system information. Therefore, paths are treated purely syntactically and do not imply that for example a file does really exist.
| CeresEngine::FilePath::FilePath | ( | ) |
Creates a new empty FilePath.
| CeresEngine::FilePath::FilePath | ( | StringView | path | ) |
Creates a new FilePath from a string view that represents a path.
| CeresEngine::FilePath::FilePath | ( | String && | path | ) |
Creates a new FilePath by moving the contents of a path string.
Creates a new FilePath from a const char* string.
|
default |
| StringView CeresEngine::FilePath::getBaseName | ( | ) | const |
Gets the path base name.
| StringView CeresEngine::FilePath::getDriveLetter | ( | ) | const |
Gets drive letter on a Windows-style path.
| StringView CeresEngine::FilePath::getExtension | ( | ) | const |
Gets the path file extension.
| StringView CeresEngine::FilePath::getFileName | ( | ) | const |
Gets file name from the path.
| StringView CeresEngine::FilePath::getFullPath | ( | ) | const |
Gets full path.
| StringView CeresEngine::FilePath::getParent | ( | ) | const |
Gets the directory path.
|
inline |
Gets the directory path.
|
inline |
Get path as string.
| bool CeresEngine::FilePath::isAbsolute | ( | ) | const |
Checks if path is an absolute path.
true if path is absolute, else false. | bool CeresEngine::FilePath::isEmpty | ( | ) | const |
Checks if path is empty.
true if path is empty, else false. | bool CeresEngine::FilePath::isRelative | ( | ) | const |
Check if path is a relative.
true if path is relative, else false. | FilePath & CeresEngine::FilePath::makeAbsolute | ( | ) |
| FilePath & CeresEngine::FilePath::makeRelative | ( | ) |
| FilePath CeresEngine::FilePath::normalize | ( | ) | const |
Gets the normalized path (removed '.
' and '..' entries if possible).
Relativizes this path to be a relative path from base.
Resolves a relative path from path.
path to the current path.| path | Th path to be resolved. |
Sets a new path. Converts the path into the internal format.
|
protected |
Sets a new path. Converts the path into the internal format.
|
inline |
|
inline |
| String CeresEngine::FilePath::toNative | ( | ) | const |
Gets the native path as string.
|
inline |
|
inline |
| std::filesystem::path CeresEngine::FilePath::toStdPath | ( | ) | const |
The underlying path as a string in the unified format.
|
private |
The underlying path as a string in the unified format.