The wrapper for file system directory operations.
More...
List of all members.
Classes |
class | Iterator |
| The iterator over the files and subdirectories. More...
|
Static Public Member Functions |
static bool | empty (const std::string &path) |
| Checks if the directory is empty.
|
static void | ensureExists (const std::string &path) |
| Creates new directory if it does not exist.
|
static bool | ensureExistsAndEmpty (const std::string &name, bool needEraseContent=0) |
| Prepares an empty directory.
|
static std::shared_ptr< Iterator > | enumerate (const std::string &path) |
| Creates the iterator over the entries in the directory.
|
static void | eraseContent (const std::string &path) |
| Removes any content of the directory.
|
static bool | exists (const std::string &path) |
| Checks if the directory exists.
|
static std::string | mixNameComponents (const std::string &part1, const std::string &part2) |
| Combines two parts of the UNIX path.
|
static void | remove (const std::string &path) |
| Removes the empty directory.
|
Detailed Description
This class wraps the most popular operations with directories in files system. Its generally purposed for automatic verifying the error code returned by system calls and throwing SystemException instances on failures.
- See also:
- File SystemException
Member Function Documentation
bool Directory::empty |
( |
const std::string & |
path | ) |
[static] |
Note, if the directory does not exists this method signales that through SystemException and returns nothing.
- Parameters:
-
[in] | path | The path of the directory to check |
- Returns:
- Non-zero if the directory is empty and zero otherwise
void Directory::ensureExists |
( |
const std::string & |
path | ) |
[static] |
- Parameters:
-
[in | path The path of the directory to create] |
bool Directory::ensureExistsAndEmpty |
( |
const std::string & |
name, |
|
|
bool |
needEraseContent = 0 |
|
) |
| [static] |
This method helps to get an empty directory at specified path. It can do in two modes depending on the action performed in case when the directory already exists. In first mode this method always erases directory content, in second it only checks is existing directory empty or not but never touches its contents. The result of checking in second mode is returned through the return value.
- Parameters:
-
[in] | path | The path of the directory to get empty |
[in] | needEraseContent | Allows to delete all subdirectories and files if the directory exists and not empty |
- Returns:
- Non-zero if the directory is empty and zero if it is not empty and we may not delete its content
Directory::Iterator::Ptr Directory::enumerate |
( |
const std::string & |
path | ) |
[static] |
This method creates the iterator prepared to enumerate all files and subdirectories inside of the directory given by path. If the directory is inaccessible for reading the SystemException will be thrown.
- Parameters:
-
[in] | path | The path of the directory to enumerate files in |
- Returns:
- The prepared iterator
void Directory::eraseContent |
( |
const std::string & |
path | ) |
[static] |
- Parameters:
-
[in] | path | The path of the directory to erase content in |
DEEPSOLVER_BEGIN_NAMESPACE bool Directory::exists |
( |
const std::string & |
path | ) |
[static] |
- Parameters:
-
[in] | path | The path of the directory to check |
- Returns:
- Non-zero if the directory exists and zero otherwise
std::string Directory::mixNameComponents |
( |
const std::string & |
part1, |
|
|
const std::string & |
part2 |
|
) |
| [static] |
This method just takes care of the double slashes absence in constructed name.
- Parameters:
-
[in] | part1 | The first part of the path to construct |
[in] | part2 | The second part of the path to construct |
- Returns:
- The constructed path
void Directory::remove |
( |
const std::string & |
path | ) |
[static] |
- Parameters:
-
[in] | path | The path of the directory to remove |