boost::filesystem::path is a wide string on Windows
authorChristopher Dykes <cdykes@fb.com>
Sat, 2 Jul 2016 02:28:10 +0000 (19:28 -0700)
committerFacebook Github Bot 8 <facebook-github-bot-8-bot@fb.com>
Sat, 2 Jul 2016 02:38:31 +0000 (19:38 -0700)
Summary: Which means `.native()` returns a `wstring`, and `.c_str()` returns a `wchar_t*`. As we're using them in places expecting a `char*`, convert to `string` first.

Reviewed By: yfeldblum

Differential Revision: D3506911

fbshipit-source-id: ca34b9888f98106914438490bbd860f9b922ad5e

folly/experimental/test/TestUtilTest.cpp
folly/gen/test/FileTest.cpp
folly/test/ExceptionTest.cpp
folly/test/FileLockTest.cpp

index d2501bbc6c62a8c4c778eb2d6157c29891ce2ab1..7b1eeda380c0e3c80eea72ef1fcdf532b49efb95 100644 (file)
@@ -82,7 +82,7 @@ void testTemporaryDirectory(TemporaryDirectory::Scope scope) {
     EXPECT_TRUE(fs::is_directory(path));
 
     fs::path fp = path / "bar";
-    int fd = open(fp.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0666);
+    int fd = open(fp.string().c_str(), O_RDWR | O_CREAT | O_TRUNC, 0666);
     EXPECT_NE(fd, -1);
     close(fd);
 
index a32714e096fa2f8061a02b2d799d2d7c6e0a2706..a62f2edfdbc10e59818b4ed4c757e160ac612775 100644 (file)
@@ -50,7 +50,7 @@ TEST(FileGen, ByLine) {
     EXPECT_EQ(lines.size(), write(file.fd(), lines.data(), lines.size()));
 
     auto expected = from({lines}) | resplit('\n') | collect;
-    auto found = byLine(file.path().c_str()) | collect;
+    auto found = byLine(file.path().string().c_str()) | collect;
 
     EXPECT_EQ(expected, found) << "For Input: '" << lines << "'";
   }
@@ -74,7 +74,7 @@ TEST_P(FileGenBufferedTest, FileWriter) {
   auto expected = src | resplit('\n') | collect;
 
   src | eachAs<StringPiece>() | toFile(File(file.fd()), bufferSize);
-  auto found = byLine(file.path().c_str()) | collect;
+  auto found = byLine(file.path().string().c_str()) | collect;
 
   EXPECT_TRUE(expected == found);
 }
@@ -86,7 +86,7 @@ TEST(FileGenBufferedTest, FileWriterSimple) {
   auto squares = seq(1, 100) | map([](int x) { return x * x; });
   squares | map(toLine) | eachAs<StringPiece>() | toFile(File(file.fd()));
   EXPECT_EQ(squares | sum,
-            byLine(File(file.path().c_str())) | eachTo<int>() | sum);
+            byLine(File(file.path().string().c_str())) | eachTo<int>() | sum);
 }
 
 INSTANTIATE_TEST_CASE_P(
index 30a70da0d646e206b6fd29f470d59465bc71246f..a77725d9729095ec87470d763066cba918a56888 100644 (file)
@@ -76,7 +76,7 @@ TEST(ExceptionTest, Simple) {
 
   TemporaryDirectory tmpdir;
   auto exnpath = tmpdir.path() / "ExceptionTest";
-  auto fp = fopen(exnpath.c_str(), "w+b");
+  auto fp = fopen(exnpath.string().c_str(), "w+b");
   ASSERT_TRUE(fp != nullptr);
   SCOPE_EXIT { fclose(fp); };
 
index 8001e594b920c2da644555ae4b35b4d81f799294..eaf302eadfd313cb4418b7e0ad504b52ea45d530 100644 (file)
@@ -60,9 +60,9 @@ TEST(File, Locks) {
 
   enum LockMode { EXCLUSIVE, SHARED };
   auto testLock = [&](LockMode mode, bool expectedSuccess) {
-    auto ret = Subprocess({helper.native(),
+    auto ret = Subprocess({helper.string(),
                            mode == SHARED ? "-s" : "-x",
-                           tempFile.path().native()}).wait();
+                           tempFile.path().string()}).wait();
     EXPECT_TRUE(ret.exited());
     if (ret.exited()) {
       EXPECT_EQ(expectedSuccess ? 0 : 42, ret.exitStatus());