From: Orvid King Date: Sun, 13 Sep 2015 23:06:37 +0000 (-0700) Subject: Use .string() not .native() when working with boost::filesystem X-Git-Tag: deprecate-dynamic-initializer~415 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=42581035875b25d5fc001b32ad7ec016e4e6affe;p=folly.git Use .string() not .native() when working with boost::filesystem Summary: Because .native() produces a wstring under MSVC. Closes #306 Reviewed By: @yfeldblum Differential Revision: D2419043 Pulled By: @JoelMarcey --- diff --git a/folly/experimental/NestedCommandLineApp.cpp b/folly/experimental/NestedCommandLineApp.cpp index 39055bd6..3b37990e 100644 --- a/folly/experimental/NestedCommandLineApp.cpp +++ b/folly/experimental/NestedCommandLineApp.cpp @@ -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(argv + 1, argv + argc)); } diff --git a/folly/experimental/io/HugePages.cpp b/folly/experimental/io/HugePages.cpp index fc98e136..d86afdd3 100644 --- a/folly/experimental/io/HugePages.cpp +++ b/folly/experimental/io/HugePages.cpp @@ -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(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; }