From 35e9dfc719087620bba711ab65579b430a25036f Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Fri, 1 Jul 2016 19:28:10 -0700 Subject: [PATCH] boost::filesystem::path is a wide string on Windows 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 | 2 +- folly/gen/test/FileTest.cpp | 6 +++--- folly/test/ExceptionTest.cpp | 2 +- folly/test/FileLockTest.cpp | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/folly/experimental/test/TestUtilTest.cpp b/folly/experimental/test/TestUtilTest.cpp index d2501bbc..7b1eeda3 100644 --- a/folly/experimental/test/TestUtilTest.cpp +++ b/folly/experimental/test/TestUtilTest.cpp @@ -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); diff --git a/folly/gen/test/FileTest.cpp b/folly/gen/test/FileTest.cpp index a32714e0..a62f2edf 100644 --- a/folly/gen/test/FileTest.cpp +++ b/folly/gen/test/FileTest.cpp @@ -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() | 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() | toFile(File(file.fd())); EXPECT_EQ(squares | sum, - byLine(File(file.path().c_str())) | eachTo() | sum); + byLine(File(file.path().string().c_str())) | eachTo() | sum); } INSTANTIATE_TEST_CASE_P( diff --git a/folly/test/ExceptionTest.cpp b/folly/test/ExceptionTest.cpp index 30a70da0..a77725d9 100644 --- a/folly/test/ExceptionTest.cpp +++ b/folly/test/ExceptionTest.cpp @@ -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); }; diff --git a/folly/test/FileLockTest.cpp b/folly/test/FileLockTest.cpp index 8001e594..eaf302ea 100644 --- a/folly/test/FileLockTest.cpp +++ b/folly/test/FileLockTest.cpp @@ -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()); -- 2.34.1