Commit af89b48f authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Use boost::filesystem::current_path in ChangeToTempDir

Summary:
[Folly] Use `boost::filesystem::current_path` in `ChangeToTempDir`.

It will report failures noisily.

Reviewed By: pixelb

Differential Revision: D6493243

fbshipit-source-id: 423dc0e3a46781e9af42fee69060d31085f1a7c6
parent fc1af2c4
...@@ -129,14 +129,15 @@ TemporaryDirectory::~TemporaryDirectory() { ...@@ -129,14 +129,15 @@ TemporaryDirectory::~TemporaryDirectory() {
} }
} }
ChangeToTempDir::ChangeToTempDir() : initialPath_(fs::current_path()) { ChangeToTempDir::ChangeToTempDir() {
std::string p = dir_.path().string(); orig_ = fs::current_path();
::chdir(p.c_str()); fs::current_path(path());
} }
ChangeToTempDir::~ChangeToTempDir() { ChangeToTempDir::~ChangeToTempDir() {
std::string p = initialPath_.string(); if (!orig_.empty()) {
::chdir(p.c_str()); fs::current_path(orig_);
}
} }
namespace detail { namespace detail {
......
...@@ -135,8 +135,8 @@ class ChangeToTempDir { ...@@ -135,8 +135,8 @@ class ChangeToTempDir {
const fs::path& path() const { return dir_.path(); } const fs::path& path() const { return dir_.path(); }
private: private:
fs::path initialPath_;
TemporaryDirectory dir_; TemporaryDirectory dir_;
fs::path orig_;
}; };
namespace detail { namespace detail {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment