Use .string() not .native() in TestUtil.cpp
authorOrvid King <blah38621@gmail.com>
Tue, 4 Aug 2015 23:02:44 +0000 (16:02 -0700)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Wed, 5 Aug 2015 00:22:23 +0000 (17:22 -0700)
Summary: Because `.native()` returns a wide string on MSVC, but a normal string is expected by the rest of the code.
Closes #283

Reviewed By: @yfeldblum

Differential Revision: D2307488

Pulled By: @sgolemon

folly/experimental/TestUtil.cpp

index 26e26b0ae81a6e7e352dc095d4235391cf6ae2fd..ae84cc3166265744508beb2199d77f676a5cd8dd 100644 (file)
@@ -55,7 +55,7 @@ TemporaryFile::TemporaryFile(StringPiece namePrefix,
     closeOnDestruction_(closeOnDestruction),
     fd_(-1),
     path_(generateUniquePath(std::move(dir), namePrefix)) {
-  fd_ = open(path_.c_str(), O_RDWR | O_CREAT | O_EXCL, 0666);
+  fd_ = open(path_.string().c_str(), O_RDWR | O_CREAT | O_EXCL, 0666);
   checkUnixError(fd_, "open failed");
 
   if (scope_ == Scope::UNLINK_IMMEDIATELY) {
@@ -112,12 +112,12 @@ TemporaryDirectory::~TemporaryDirectory() {
 }
 
 ChangeToTempDir::ChangeToTempDir() : initialPath_(fs::current_path()) {
-  std::string p = dir_.path().native();
+  std::string p = dir_.path().string();
   ::chdir(p.c_str());
 }
 
 ChangeToTempDir::~ChangeToTempDir() {
-  std::string p = initialPath_.native();
+  std::string p = initialPath_.string();
   ::chdir(p.c_str());
 }
 
@@ -141,7 +141,7 @@ CaptureFD::CaptureFD(int fd) : fd_(fd), readOffset_(0) {
   oldFDCopy_ = dup(fd_);
   PCHECK(oldFDCopy_ != -1) << "Could not copy FD " << fd_;
 
-  int file_fd = open(file_.path().c_str(), O_WRONLY|O_CREAT, 0600);
+  int file_fd = open(file_.path().string().c_str(), O_WRONLY|O_CREAT, 0600);
   PCHECK(dup2(file_fd, fd_) != -1) << "Could not replace FD " << fd_
     << " with " << file_fd;
   PCHECK(close(file_fd) != -1) << "Could not close " << file_fd;
@@ -162,13 +162,13 @@ CaptureFD::~CaptureFD() {
 
 std::string CaptureFD::read() {
   std::string contents;
-  std::string filename = file_.path().native();
+  std::string filename = file_.path().string();
   PCHECK(folly::readFile(filename.c_str(), contents));
   return contents;
 }
 
 std::string CaptureFD::readIncremental() {
-  std::string filename = file_.path().native();
+  std::string filename = file_.path().string();
   // Yes, I know that I could just keep the file open instead. So sue me.
   folly::File f(openNoInt(filename.c_str(), O_RDONLY), true);
   auto size = lseek(f.fd(), 0, SEEK_END) - readOffset_;