RAII helper that deletes a file when the FileRemover instance goes out of scope (unless released beforehand). Useful for guaranteeing the cleanup of temporary files.
More...
#include <FileRemover.hpp>
|
| | FileRemover (const std::string &path) |
| | Constructs a FileRemover guarding the file at path. More...
|
| |
| | ~FileRemover () |
| | Destructor. Removes the file at the currently held path unless release() has been called. More...
|
| |
| const std::string & | getPath () const |
| | Returns the file-system path currently guarded by the FileRemover. More...
|
| |
| void | reset (const std::string &new_path) |
| | Replaces the currently held path with new_path; the previously held file is removed immediately. More...
|
| |
| void | release () |
| | Releases the FileRemover from its current path so that the file will not be removed on destruction. More...
|
| |
| FileRemover & | operator= (FileRemover &rhs) |
| | Move-style assignment: takes over the path held by rhs and releases rhs. More...
|
| |
RAII helper that deletes a file when the FileRemover instance goes out of scope (unless released beforehand). Useful for guaranteeing the cleanup of temporary files.
◆ FileRemover()
| CDPL::Util::FileRemover::FileRemover |
( |
const std::string & |
path | ) |
|
|
inline |
Constructs a FileRemover guarding the file at path.
- Parameters
-
| path | The file-system path of the file to remove on destruction. |
◆ ~FileRemover()
| CDPL::Util::FileRemover::~FileRemover |
( |
| ) |
|
Destructor. Removes the file at the currently held path unless release() has been called.
◆ getPath()
| const std::string& CDPL::Util::FileRemover::getPath |
( |
| ) |
const |
Returns the file-system path currently guarded by the FileRemover.
- Returns
- A
const reference to the file-system path.
◆ reset()
| void CDPL::Util::FileRemover::reset |
( |
const std::string & |
new_path | ) |
|
Replaces the currently held path with new_path; the previously held file is removed immediately.
- Parameters
-
| new_path | The new file-system path to guard. |
◆ release()
| void CDPL::Util::FileRemover::release |
( |
| ) |
|
Releases the FileRemover from its current path so that the file will not be removed on destruction.
◆ operator=()
Move-style assignment: takes over the path held by rhs and releases rhs.
- Parameters
-
| rhs | The FileRemover to take over from. |
- Returns
- A reference to itself.
The documentation for this class was generated from the following file: