|
Sharg 1.2.2-rc.1
The argument parser for bio-c++ tools.
|
A safe guard to manage a filesystem entry, e.g. a file or a directory. More...
#include <sharg/detail/safe_filesystem_entry.hpp>
Public Member Functions | |
| bool | remove () |
| Removes a file or empty directory. | |
| bool | remove_no_throw () const noexcept |
| Removes a file or empty directory. | |
| std::uintmax_t | remove_all () |
| Removes a file or directory and all its contents, recursively. | |
Constructors, destructor and assignment | |
| safe_filesystem_entry ()=delete | |
| Deleted. | |
| safe_filesystem_entry (safe_filesystem_entry const &)=delete | |
| Deleted. | |
| safe_filesystem_entry (safe_filesystem_entry &&)=default | |
| Defaulted. | |
| safe_filesystem_entry & | operator= (safe_filesystem_entry const &)=delete |
| Deleted. | |
| safe_filesystem_entry & | operator= (safe_filesystem_entry &&)=default |
| Defaulted. | |
| safe_filesystem_entry (std::filesystem::path p) | |
| Constructs the safe guard from a std::filesystem::path. | |
| ~safe_filesystem_entry () | |
| Calls std::filesystem::remove_all on the wrapped entry. | |
Private Attributes | |
| std::filesystem::path | entry |
| The managed resource. | |
A safe guard to manage a filesystem entry, e.g. a file or a directory.
This raii-wrapper class allows for a safe removal of a created filesystem entry such as a directory or file. This wrapper class assumes owning semantics. It is not copy-constructible or copy-assignable. In order to prevent misuse also the default constructor is deleted.
The following example demonstrates the use case.
|
inline |
Constructs the safe guard from a std::filesystem::path.
| p | The path pointing to a filesystem entry. |
|
inline |
Removes a file or empty directory.
true if the file was deleted, false if it did not exist. | std::filesystem::filesystem_error | on underlying OS API errors. |
Internally calls std::filesystem::remove on the stored std::filesystem::path.
|
inline |
Removes a file or directory and all its contents, recursively.
| std::filesystem::filesystem_error | on underlying OS API errors. |
Internally calls std::filesystem::remove_all on the stored std::filesystem::path.
|
inlinenoexcept |
Removes a file or empty directory.
true if the file was deleted, false if it did not exist. | std::filesystem::filesystem_error | on underlying OS API errors. |
Internally calls std::filesystem::remove on the stored std::filesystem::path.