![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/Filesystem/TemporaryDirectory.h>
Temporary directory which deletes itself upon going out of scope. More...
Temporary directory which deletes itself upon going out of scope.
Public Types | |
enum class | Policy { Create , CreateRecursive , DoNotCreate } |
TemporaryDirectory Construction Policy. | |
![]() | |
enum class | SortOption { Unsorted = 0x0 , Name = 0x1 , Extension = 0x2 , Size = 0x4 , Time = 0x8 , IgnoreCase = 0x10 , DirsFirst = 0x20 , DirsLast = 0x40 , Reversed = 0x80 } |
Sorting options for paths inside a directory One of the first 5 options (Unsorted, Name, Extension, Size, Time) might be or-combined with one or multiple of the following options. More... | |
using | SortOptions = Flags<SortOption> |
Public Member Functions | |
TemporaryDirectory (const Path &path={}, Policy policy=Policy::CreateRecursive) | |
Constructs a TemporaryDirectory with a given path and policy. | |
![]() | |
Directory (const Path &path) | |
Create a new Directory instance for the given path. | |
Directory (const std::string &path) | |
Create a new Directory instance for the given path. | |
Directory (const char *path) | |
Create a new Directory instance for the given path. | |
operator Path () const | |
Allow for implicit conversion to a Path. | |
Path | path () const |
Gets the path of the directory. | |
std::string | string () const |
Gets the path of the directory as string. | |
Directory | parentDirectory () const |
Returns the absolute path to the parent directory, convenience function for Directory(path().parentPath()) . | |
Path | parentPath () const |
Returns the absolute path to the parent directory, convenience function for path().parentPath() . | |
std::string | name () const |
Gets the name of the directory, convenience function for path().fileName() . | |
bool | exists () const |
Check if the directory exists and is actually a directory. | |
bool | isEmpty () const |
Check if the directory is empty. | |
bool | isWritable () const |
Checks if the directory exists and is writable, in other words if a file can be created in it. | |
bool | contains (const std::string &filename) const |
Check if the directory contains a file or subdirectory named filename. | |
std::vector< Path > | scan (const std::function< bool(const Path &)> &filter=nullptr, SortOptions options=SortOption::Name) const |
Scans the directory and collects the paths inside that pass the (optional) lambda filter. | |
std::vector< Path > | scanRecursive (const std::function< bool(const Path &)> &filter=nullptr) const |
Recursively scans the directory and collects the paths inside that pass the (optional) lambda filter. | |
bool | copyTo (const Path &destination, Flags< CopyOptions > copyOptions=CopyOptions::None, std::function< bool(const Path &sourcePath)> filter=nullptr) const |
Copies this directory and its contents to destination based on the provided options and optional filter. | |
bool | rename (const Path &newName) |
Renames the directory. | |
bool | remove () const |
Delete the directory if it's empty. | |
bool | removeRecursive () const |
Delete the directory and all of its contents. | |
bool | removeContents () const |
Delete all the contents of the directory without deleting the directory itself. | |
bool | create () const |
Creates the directory on the filesystem (the parent directory must already exist). | |
bool | createRecursive () const |
Recursively create the directory (including parent directories if needed). | |
Additional Inherited Members | |
![]() | |
NotCopyable (NotCopyable &&) noexcept=default | |
NotCopyable & | operator= (NotCopyable &&) noexcept=default |
NotCopyable (const NotCopyable &)=delete | |
NotCopyable & | operator= (const NotCopyable &)=delete |
|
explicit |
Constructs a TemporaryDirectory with a given path and policy.
path | The path where the temporary directory will be created. Relative paths are considered relative to the current working directory.
|
policy | The policy of how the temporary directory should be created.
|