Use .string() not .native() when working with boost::filesystem
authorOrvid King <blah38621@gmail.com>
Sun, 13 Sep 2015 23:06:37 +0000 (16:06 -0700)
committerfacebook-github-bot-4 <folly-bot@fb.com>
Sun, 13 Sep 2015 23:20:19 +0000 (16:20 -0700)
Summary: Because .native() produces a wstring under MSVC.
Closes #306

Reviewed By: @yfeldblum

Differential Revision: D2419043

Pulled By: @JoelMarcey

folly/experimental/NestedCommandLineApp.cpp
folly/experimental/io/HugePages.cpp

index 39055bd69eaa8c6dee00b377fc0a62e20e68a5f0..3b37990e94dbbdc9848a08da78455df523a307dd 100644 (file)
@@ -30,7 +30,7 @@ namespace {
 // Guess the program name as basename(executable)
 std::string guessProgramName() {
   try {
-    return fs::executable_path().filename().native();
+    return fs::executable_path().filename().string();
   } catch (const std::exception&) {
     return "UNKNOWN";
   }
@@ -181,7 +181,7 @@ auto NestedCommandLineApp::findCommand(const std::string& name) const
 
 int NestedCommandLineApp::run(int argc, const char* const argv[]) {
   if (programName_.empty()) {
-    programName_ = fs::path(argv[0]).filename().native();
+    programName_ = fs::path(argv[0]).filename().string();
   }
   return run(std::vector<std::string>(argv + 1, argv + argc));
 }
index fc98e1361eb21819498e2085a5dab64730a9d15a..d86afdd35eeb5651bd7d8fc7f31eed51f5b22278 100644 (file)
@@ -77,7 +77,7 @@ HugePageSizeVec readRawHugePageSizes() {
   HugePageSizeVec vec;
   fs::path path("/sys/kernel/mm/hugepages");
   for (fs::directory_iterator it(path); it != fs::directory_iterator(); ++it) {
-    std::string filename(it->path().filename().native());
+    std::string filename(it->path().filename().string());
     if (boost::regex_match(filename, match, regex)) {
       StringPiece numStr(filename.data() + match.position(1), match.length(1));
       vec.emplace_back(to<size_t>(numStr) * 1024);
@@ -178,7 +178,7 @@ HugePageSizeVec readHugePageSizes() {
       // Store mount point
       fs::path path(parts[1].begin(), parts[1].end());
       struct stat st;
-      const int ret = stat(path.c_str(), &st);
+      const int ret = stat(path.string().c_str(), &st);
       if (ret == -1 && errno == ENOENT) {
         return;
       }