Manages directories.
More...
#include <Dir.h>
|
|
using | FilterFunction = std::function< bool(const std::string &)> |
| | An alias for the filter function.
|
| |
|
using | PathCallback = std::function< void(const std::string &)> |
| | An alias for the path callback function.
|
| |
|
| static bool | Exists (const std::string &path) |
| | Checks whether a directory exists. More...
|
| |
| static bool | Remove (const std::string &path) |
| | Removes a directory and deletes all its subfolders and files. More...
|
| |
| static bool | Create (const std::string &path, bool extend_permissions=false) |
| | Creates a directory and all required directories specified in the path. More...
|
| |
| static std::string | TempDirectory () |
| | Gets a platform-specific temporary path. More...
|
| |
| static bool | FileExists (const std::string &file_path) |
| | Checks whether the provided file exists. More...
|
| |
| static uint64_t | Size (const std::string &path, FilterFunction filter_fn={}) |
| | Calculates the size of a directory. More...
|
| |
| static bool | IsReadOnly (const std::string &path) |
| | Checks if the current application and user has a read only access to given path. More...
|
| |
| static void | ForEachDirectory (const std::string &path, PathCallback path_fn) |
| | Iterates through top-level directories in the provided path and calls the provided callback function for each directory. More...
|
| |
◆ Create()
| static bool olp::utils::Dir::Create |
( |
const std::string & |
path, |
|
|
bool |
extend_permissions = false |
|
) |
| |
|
static |
Creates a directory and all required directories specified in the path.
- Parameters
-
| path | The path of the directory. |
| extend_permissions | Controls the permission extension. |
Note: extend_permissions are applicable for Unix systems, if enabled, it sets the 0777 permissions for created folders.
- Returns
- True if the operation is successful; false otherwise.
◆ Exists()
| static bool olp::utils::Dir::Exists |
( |
const std::string & |
path | ) |
|
|
static |
Checks whether a directory exists.
- Parameters
-
| path | The path of the directory. |
- Returns
- True if the directory exists; false otherwise.
◆ FileExists()
| static bool olp::utils::Dir::FileExists |
( |
const std::string & |
file_path | ) |
|
|
static |
Checks whether the provided file exists.
- Parameters
-
| file_path | The path of the file. |
- Returns
- True if the file with the given path exists; false otherwise.
◆ ForEachDirectory()
| static void olp::utils::Dir::ForEachDirectory |
( |
const std::string & |
path, |
|
|
PathCallback |
path_fn |
|
) |
| |
|
static |
Iterates through top-level directories in the provided path and calls the provided callback function for each directory.
- Parameters
-
| path | The path of the root directory. |
| path_fn | The callback function with a relative path. |
◆ IsReadOnly()
| static bool olp::utils::Dir::IsReadOnly |
( |
const std::string & |
path | ) |
|
|
static |
Checks if the current application and user has a read only access to given path.
- Parameters
-
| path | The path to check for read only access. |
- Returns
- True if current application and user has read only access to the path.
◆ Remove()
| static bool olp::utils::Dir::Remove |
( |
const std::string & |
path | ) |
|
|
static |
Removes a directory and deletes all its subfolders and files.
- Parameters
-
| path | The path of the directory. |
- Returns
- True if the operation is successful; false otherwise.
◆ Size()
| static uint64_t olp::utils::Dir::Size |
( |
const std::string & |
path, |
|
|
FilterFunction |
filter_fn = {} |
|
) |
| |
|
static |
Calculates the size of a directory.
Use a filter to exclude unnecessary files or directories from the calculation.
- Note
- This method will go all the way recursive for as long as needed to gather all files which pass the given filter.
- Parameters
-
| path | The path of the directory. |
| filter_fn | The filter function. |
- Returns
- The calculated size.
◆ TempDirectory()
| static std::string olp::utils::Dir::TempDirectory |
( |
| ) |
|
|
static |
Gets a platform-specific temporary path.
- Returns
- The platform-specific temporary path of the directory.
The documentation for this class was generated from the following file:
- olp-cpp-sdk-core/include/olp/core/utils/Dir.h