Thea
|
Filesystem operations. More...
#include <FileSystem.hpp>
Classes | |
struct | Flags |
Miscellaneous flags (enum class). More... | |
struct | ObjectType |
Types of objects in the filesystem (enum class). More... | |
Static Public Member Functions | |
static bool | copyFile (std::string const &from, std::string const &to) |
Make a copy of a file. More... | |
static bool | createDirectory (std::string const &path) |
Create a directory, including all necessary parents (equivalent to "mkdir -p"). More... | |
static bool | directoryExists (std::string const &path) |
Check if a directory exists, and is indeed a directory (and not for instance a file). More... | |
static bool | exists (std::string const &path) |
Check if a file or directory exists. More... | |
static bool | fileExists (std::string const &path) |
Check if a file exists, and is indeed a regular file (and not for instance a directory). More... | |
static int64 | fileSize (std::string const &path) |
Get the length of a file in bytes. More... | |
static intx | getDirectoryContents (std::string const &dir, Array< std::string > &objects, int types=-1, std::string const &patterns="", int flags=0) |
Get the objects (files, subdirectories etc) in a directory, optionally filtering objects by type and name. More... | |
static std::string | readWholeFile (std::string const &path) |
Get the entire contents of a file as a string. More... | |
static bool | readWholeFile (std::string const &path, std::string &ret) |
Get the entire contents of a file as a string. More... | |
static bool | remove (std::string const &path, bool recursive=false) |
Remove a file, a symbolic link, or a directory. More... | |
static std::string | resolve (std::string const &path) |
Resolve a relative path. More... | |
Filesystem operations.
Unlike FilePath, these functions do actually access the filesystem.
Definition at line 27 of file FileSystem.hpp.
|
static |
Make a copy of a file.
Fails, returning false, if the destination already exists.
from | The source path. |
to | The destination path. |
Definition at line 230 of file FileSystem.cpp.
|
static |
Create a directory, including all necessary parents (equivalent to "mkdir -p").
Definition at line 60 of file FileSystem.cpp.
|
static |
Check if a directory exists, and is indeed a directory (and not for instance a file).
Definition at line 38 of file FileSystem.cpp.
|
static |
Check if a file or directory exists.
Definition at line 26 of file FileSystem.cpp.
|
static |
Check if a file exists, and is indeed a regular file (and not for instance a directory).
Definition at line 32 of file FileSystem.cpp.
|
static |
Get the length of a file in bytes.
Returns a negative number on failure.
Definition at line 44 of file FileSystem.cpp.
|
static |
Get the objects (files, subdirectories etc) in a directory, optionally filtering objects by type and name.
Symbolic links are returned as symbolic links and are not dereferenced to the files or directories they point to.
dir | The path to the directory. |
objects | Used to return the full paths of all retrieved objects in the directory. Prior contents are discarded. |
types | A bitwise-OR of ObjectType flags (pass zero, negative or ObjectType::ALL to allow all types of objects). |
patterns | If this string is non-empty, it is split into fields separated by spaces and each field interpreted as a shell wildcard pattern specified in the format of patternMatch(). The function will return only objects whose names (without path) match at least one of the patterns. E.g. patterns = "*.txt *.png" will return only files with names ending in .txt or .png. |
flags | A bitwise OR of Flags values specifying additional options, e.g. recursive subdirectory traversal, case-insensitive pattern matching, or sorted output. |
Definition at line 166 of file FileSystem.cpp.
|
static |
Get the entire contents of a file as a string.
Definition at line 84 of file FileSystem.hpp.
|
static |
Get the entire contents of a file as a string.
Definition at line 69 of file FileSystem.cpp.
|
static |
Remove a file, a symbolic link, or a directory.
If the path is a directory, the operation succeeds only if the directory is empty or if recursive is true.
path | The path to remove. |
recursive | If true, and if the path points to a directory, contents of the directory are recursively removed before the directory itself. |
Definition at line 212 of file FileSystem.cpp.
|
static |
Resolve a relative path.
Definition at line 54 of file FileSystem.cpp.