proxygen
folly::test::ChangeToTempDir Class Reference

#include <TestUtil.h>

Public Member Functions

 ChangeToTempDir ()
 
 ~ChangeToTempDir ()
 
 ChangeToTempDir (ChangeToTempDir &&)=default
 
ChangeToTempDiroperator= (ChangeToTempDir &&)=default
 
const fs::path & path () const
 

Private Attributes

TemporaryDirectory dir_
 
fs::path orig_
 

Detailed Description

Changes into a temporary directory, and deletes it with all its contents upon destruction, also changing back to the original working directory.

Definition at line 129 of file TestUtil.h.

Constructor & Destructor Documentation

folly::test::ChangeToTempDir::ChangeToTempDir ( )

Definition at line 133 of file TestUtil.cpp.

References folly::test::TemporaryDirectory::path().

133  {
134  orig_ = fs::current_path();
135  fs::current_path(path());
136 }
const fs::path & path() const
Definition: TestUtil.h:138
folly::test::ChangeToTempDir::~ChangeToTempDir ( )

Definition at line 138 of file TestUtil.cpp.

138  {
139  if (!orig_.empty()) {
140  fs::current_path(orig_);
141  }
142 }
folly::test::ChangeToTempDir::ChangeToTempDir ( ChangeToTempDir &&  )
default

Member Function Documentation

ChangeToTempDir& folly::test::ChangeToTempDir::operator= ( ChangeToTempDir &&  )
default
const fs::path& folly::test::ChangeToTempDir::path ( ) const
inline

Definition at line 138 of file TestUtil.h.

138  {
139  return dir_.path();
140  }
TemporaryDirectory dir_
Definition: TestUtil.h:143
const fs::path & path() const
Definition: TestUtil.h:116

Member Data Documentation

TemporaryDirectory folly::test::ChangeToTempDir::dir_
private

Definition at line 143 of file TestUtil.h.

fs::path folly::test::ChangeToTempDir::orig_
private

Definition at line 144 of file TestUtil.h.


The documentation for this class was generated from the following files: