From: Kefu Chai Date: Fri, 21 May 2021 04:10:50 +0000 (+0000) Subject: os/bluestore/bluestore_tool: use boost::filesystem as an alternative X-Git-Tag: v17.1.0~1874^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9dedabde520907f99727edf9f916ebb55ccdaa87;p=ceph.git os/bluestore/bluestore_tool: use boost::filesystem as an alternative the libstdc++ shipped with GCC 7.5 does not have good support of std::filesystem, among other things, it does not offer std::filesystem::weakly_canonical(). but boost::filesystem does. and boost::filesystem is compatible with std::filesystem to some degree. so let's use it if is not available, we can take it as a signal that std::filesystem is not quite ready yet. Signed-off-by: Kefu Chai --- diff --git a/src/os/CMakeLists.txt b/src/os/CMakeLists.txt index 9008f2ed8c04..522d572967ac 100644 --- a/src/os/CMakeLists.txt +++ b/src/os/CMakeLists.txt @@ -106,6 +106,11 @@ if(WITH_BLUESTORE) bluestore/bluestore_tool.cc) target_link_libraries(ceph-bluestore-tool os global) + # TODO: drop this linkage once we don't need to build on bionic + if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) + target_link_libraries(ceph-bluestore-tool + Boost::filesystem) + endif() install(TARGETS ceph-bluestore-tool DESTINATION bin) endif() diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index 2eeae694d602..8064d395c9aa 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -9,9 +9,9 @@ #if __has_include() #include namespace fs = std::filesystem; -#elif __has_include() -#include -namespace fs = std::experimental::filesystem; +#else +#include +namespace fs = boost::filesystem; #endif #include #include @@ -249,8 +249,8 @@ static void bluefs_import( BlueFS::FileWriter *h; fs::path file_path(dest_file); - const string dir = file_path.parent_path(); - const string file_name = file_path.filename(); + const string dir = file_path.parent_path().native(); + const string file_name = file_path.filename().native(); bs->open_for_write(dir, file_name, &h, false); uint64_t max_block = 4096; char buf[max_block];