proxygen
|
#include <TestUtil.h>
Public Types | |
enum | Scope { Scope::PERMANENT, Scope::UNLINK_IMMEDIATELY, Scope::UNLINK_ON_DESTRUCTION } |
Public Member Functions | |
TemporaryFile (StringPiece namePrefix=StringPiece(), fs::path dir=fs::path(), Scope scope=Scope::UNLINK_ON_DESTRUCTION, bool closeOnDestruction=true) | |
~TemporaryFile () | |
TemporaryFile (TemporaryFile &&other) noexcept | |
TemporaryFile & | operator= (TemporaryFile &&other) |
void | close () |
int | fd () const |
const fs::path & | path () const |
void | reset () |
Private Member Functions | |
void | assign (TemporaryFile &other) |
Private Attributes | |
Scope | scope_ |
bool | closeOnDestruction_ |
int | fd_ |
fs::path | path_ |
Temporary file.
By default, the file is created in a system-specific location (the value of the TMPDIR environment variable, or /tmp), but you can override that with a different (non-empty) directory passed to the constructor.
By default, the file is closed and deleted when the TemporaryFile object is destroyed, but both these behaviors can be overridden with arguments to the constructor.
Definition at line 40 of file TestUtil.h.
|
strong |
Enumerator | |
---|---|
PERMANENT | |
UNLINK_IMMEDIATELY | |
UNLINK_ON_DESTRUCTION |
Definition at line 42 of file TestUtil.h.
|
explicit |
Definition at line 55 of file TestUtil.cpp.
References folly::checkUnixError(), fd_, path_, scope_, UNLINK_IMMEDIATELY, and folly::WARNING.
folly::test::TemporaryFile::~TemporaryFile | ( | ) |
Definition at line 109 of file TestUtil.cpp.
References reset().
|
inlinenoexcept |
|
inlineprivate |
Definition at line 80 of file TestUtil.h.
References closeOnDestruction_, folly::exchange(), fd_, path_, and scope_.
Referenced by operator=(), and TemporaryFile().
void folly::test::TemporaryFile::close | ( | ) |
Definition at line 78 of file TestUtil.cpp.
References fd_.
Referenced by operator=(), reset(), and TEST().
|
inline |
Definition at line 68 of file TestUtil.h.
References fd_, path(), and reset().
Referenced by folly::symbolizer::test::TEST(), folly::test::TEST(), TEST(), TEST_F(), and TEST_P().
|
inline |
const fs::path & folly::test::TemporaryFile::path | ( | ) | const |
Definition at line 85 of file TestUtil.cpp.
References path_, scope_, and UNLINK_IMMEDIATELY.
Referenced by folly::test::CaptureFD::CaptureFD(), fd(), wangle::getPersistentCacheFilename(), folly::test::CaptureFD::read(), folly::test::CaptureFD::readIncremental(), TEST(), fizz::test::TEST(), folly::test::TEST(), TEST_F(), and TEST_P().
void folly::test::TemporaryFile::reset | ( | ) |
Definition at line 91 of file TestUtil.cpp.
References close(), closeOnDestruction_, fd_, path_, PERMANENT, scope_, and folly::WARNING.
Referenced by fd(), operator=(), and ~TemporaryFile().
|
private |
Definition at line 76 of file TestUtil.h.
|
private |
Definition at line 77 of file TestUtil.h.
Referenced by assign(), close(), fd(), reset(), and TemporaryFile().
|
private |
Definition at line 78 of file TestUtil.h.
Referenced by assign(), path(), folly::test::TemporaryDirectory::path(), reset(), and TemporaryFile().
|
private |
Definition at line 75 of file TestUtil.h.
Referenced by assign(), path(), reset(), and TemporaryFile().