|
Ocean
|
This class holds a directory. More...
#include <Directory.h>
Public Member Functions | |
| Directory () | |
| Creates an empty directory. | |
| Directory (const std::string &path) | |
| Creates a new directory. | |
| Directory (const File &file) | |
| Creates a new directory by a given file. | |
| Directory (const Path &path) | |
| Creates a new directory by a given path. | |
| virtual bool | isValid () const |
| Returns whether the directory is valid. | |
| virtual bool | exists () const |
| Returns whether the directory exists already. | |
| bool | remove (const bool recursively=false) const |
| Removes this directory from the filesystem. | |
| bool | create () const |
| Create all necessary sub-directories for the given path, if they do not exist. | |
| std::string | base () const |
| Returns the base of this directory. | |
| std::string | name () const |
| Returns the name of a directory. | |
| Files | findFiles (const std::string &fileType=std::string("*"), const bool recursive=false) const |
| Returns all files in the directory with the given file format. | |
| Directories | findDirectories (const bool recursive=false) const |
| Returns all directories of this directory. | |
| File | operator+ (const File &file) const |
| Returns a file composed of this directory and a relative file. | |
| Directory | operator+ (const Directory &path) const |
| Returns a directory composed of this and a relative directory. | |
| Directory & | operator+= (const Directory &path) |
| Adds an relative path to this directory. | |
| Directory & | operator-- () |
| Removes the last sub-directory from this directory. | |
| Directory | operator-- (int) |
| Removes the last sub-directory from this directory. | |
Public Member Functions inherited from Ocean::IO::Path | |
| virtual | ~Path ()=default |
| Destructs a path. | |
| Type | type () const |
| Returns the type of this path. | |
| bool | isAbsolute () const |
| Returns whether this path is absolute. | |
| bool | isRelative () const |
| Returns whether this path is relative. | |
| bool | isNull () const |
| Returns whether this path holds no valid. | |
| bool | operator== (const Path &right) const |
| Returns whether two paths are equal. | |
| bool | operator!= (const Path &path) const |
| Returns whether two paths are not equal. | |
| const std::string & | operator() () const |
| Returns the value of this path. | |
| bool | operator< (const Path &path) const |
| Less operator comparing the actual strings of two paths. | |
Static Public Member Functions | |
| static Directory | createTemporaryDirectory () |
| Creates a new temporary directory. | |
Static Public Member Functions inherited from Ocean::IO::Path | |
| static bool | isSeparator (const char character) |
| Returns whether a given character is a separator. | |
| static char | defaultSeparator () |
| Returns the default separator of a path. | |
Static Protected Member Functions | |
| static Directory | createTemporaryDirectoryApple () |
| Creates a new temporary directory (specialization for Apple platforms). | |
| static bool | existsApple (const std::string &directory) |
| Returns whether a directory exists (specialization for Apple platforms). | |
Additional Inherited Members | |
Public Types inherited from Ocean::IO::Path | |
| enum | Type { TYPE_INVALID = 0 , TYPE_FILE = 1 , TYPE_DIRECTORY = 2 , TYPE_ABSOLUTE = 4 , TYPE_RELATIVE = 8 , TYPE_NETWORK = 16 } |
| Definition of different path types. More... | |
| enum | Separator { SEPARATOR_UNDEFINED = 0 , SEPARATOR_SLASH = '/' , SEPARATOR_BACKSLASH = '\\' } |
| Definition of path separators. More... | |
Protected Member Functions inherited from Ocean::IO::Path | |
| Path ()=default | |
| Creates a new undefined path. | |
| Path (const Path &path)=default | |
| Copy constructor. | |
| Path (const std::string &value) | |
| Creates a new path. | |
| void | checkPath (const Type expectType) |
| Checks the type of this path and trims it. | |
| void | trim () |
| Trims this path. | |
| Path & | operator= (const Path &path)=default |
| Default assign operator. | |
Protected Attributes inherited from Ocean::IO::Path | |
| Type | pathType_ = TYPE_INVALID |
| Path type. | |
| std::string | pathValue_ |
| Path value. | |
This class holds a directory.
Valid directories will end with a separator.
| Ocean::IO::Directory::Directory | ( | ) |
Creates an empty directory.
|
explicit |
Creates a new directory.
| path | Directory path |
|
explicit |
Creates a new directory by a given file.
| file | File to get the directory from |
|
explicit |
Creates a new directory by a given path.
| path | Path to create a directory from |
| std::string Ocean::IO::Directory::base | ( | ) | const |
Returns the base of this directory.
The directory's base is the entire directory path without the ending separator.
The base of e.g. "/path/to/foo/bar/" is "/path/to/foo/bar"
| bool Ocean::IO::Directory::create | ( | ) | const |
Create all necessary sub-directories for the given path, if they do not exist.
|
static |
Creates a new temporary directory.
The directory will be created as a sub-directory inside of a OS-specific temporary files path.
|
staticprotected |
Creates a new temporary directory (specialization for Apple platforms).
The directory will be created as a sub-directory inside of a OS-specific temporary files path.
|
virtual |
|
staticprotected |
Returns whether a directory exists (specialization for Apple platforms).
| directory | Directory to check |
| Directories Ocean::IO::Directory::findDirectories | ( | const bool | recursive = false | ) | const |
Returns all directories of this directory.
| recursive | True, to find sub-directories as well; False, to find direct child directories only |
| Files Ocean::IO::Directory::findFiles | ( | const std::string & | fileType = std::string("*"), |
| const bool | recursive = false |
||
| ) | const |
Returns all files in the directory with the given file format.
| fileType | File type to find files for, for example "png", "txt", or "json". Use "*" to list all files. |
| recursive | True, to find file in all possible sub-directories; False, to find files in this directory only |
|
virtual |
| std::string Ocean::IO::Directory::name | ( | ) | const |
Returns the name of a directory.
Returns a directory composed of this and a relative directory.
| path | Relative path to add |
Returns a file composed of this directory and a relative file.
| file | Relative file |
Adds an relative path to this directory.
| path | Relative path to add |
| Directory & Ocean::IO::Directory::operator-- | ( | ) |
Removes the last sub-directory from this directory.
| Directory Ocean::IO::Directory::operator-- | ( | int | ) |
Removes the last sub-directory from this directory.
| bool Ocean::IO::Directory::remove | ( | const bool | recursively = false | ) | const |
Removes this directory from the filesystem.
| recursively | True, to remove all sub-directories and their files recursively; False, to remove only this directory if empty |