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() {
}
}
ChangeToTempDir::ChangeToTempDir() : initialPath_(fs::current_path()) {
std::string p = dir_.path().string();
::chdir(p.c_str());
ChangeToTempDir::ChangeToTempDir() {
orig_ = fs::current_path();
fs::current_path(path());
}
ChangeToTempDir::~ChangeToTempDir() {
std::string p = initialPath_.string();
::chdir(p.c_str());
if (!orig_.empty()) {
fs::current_path(orig_);
}
}
namespace detail {
......
......@@ -135,8 +135,8 @@ class ChangeToTempDir {
const fs::path& path() const { return dir_.path(); }
private:
fs::path initialPath_;
TemporaryDirectory dir_;
fs::path orig_;
};
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