|
Ninja
|
A class that records a file path and ensures that it is removed on destruction. More...
#include <test.h>
Public Member Functions | |
| const char * | c_str () const |
| ScopedFilePath & | operator= (ScopedFilePath &&) noexcept |
| It would be nice to use '= default' here instead but some old compilers such as GCC from Ubuntu 16.06 will not compile it with "noexcept", so just write it manually. | |
| const std::string & | path () const |
| void | Release () |
| Release the file, the destructor will not remove the file. | |
| bool | released () const |
| ScopedFilePath (const char *path) | |
| ScopedFilePath (const std::string &path) | |
| Constructor just records the file path. | |
| ScopedFilePath (ScopedFilePath &&) noexcept | |
| Allow move operations. | |
| ~ScopedFilePath () | |
| Destructor destroys the file, unless Release() was called. | |
Private Attributes | |
| std::string | path_ |
| bool | released_ = false |
A class that records a file path and ensures that it is removed on destruction.
This ensures that tests do not keep stale files in the current directory where they run, even in case of assertion failure.
|
inline |
Constructor just records the file path.
Definition at line 108 of file test.h.
Referenced by operator=(), and ScopedFilePath().
|
inline |
|
noexcept |
Allow move operations.
Definition at line 240 of file test.cc.
References path_, released_, and ScopedFilePath().
| ScopedFilePath::~ScopedFilePath | ( | ) |
|
inline |
|
noexcept |
It would be nice to use '= default' here instead but some old compilers such as GCC from Ubuntu 16.06 will not compile it with "noexcept", so just write it manually.
Definition at line 248 of file test.cc.
References ScopedFilePath().
|
inline |
Definition at line 122 of file test.h.
References path_.
Referenced by ScopedFilePath(), and ScopedFilePath().
| void ScopedFilePath::Release | ( | ) |
|
inline |
|
private |
Definition at line 126 of file test.h.
Referenced by c_str(), path(), ScopedFilePath(), ScopedFilePath(), ScopedFilePath(), and ~ScopedFilePath().
|
private |
Definition at line 127 of file test.h.
Referenced by Release(), released(), ScopedFilePath(), and ~ScopedFilePath().