Skip to content

Commit

Permalink
*: always include <filesystem>
Browse files Browse the repository at this point in the history
since there is no need to be compatible with GCC older than GCC-8, so
there is no need to use <experimental/filesystem> as an alternative of
<filesystem> anymore.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Jun 9, 2021
1 parent bfd911d commit 756a351
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 108 deletions.
13 changes: 3 additions & 10 deletions src/common/ConfUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,13 @@
#include <algorithm>
#include <cctype>
#include <experimental/iterator>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <sstream>

#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#else
#error std::filesystem not available!
#endif

#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/trim_all.hpp>
#include <boost/spirit/include/qi.hpp>
Expand All @@ -43,6 +34,8 @@ namespace fs = std::experimental::filesystem;
#include "common/utf8.h"
#include "common/ConfUtils.h"

namespace fs = std::filesystem;

using std::ostringstream;
using std::string;

Expand Down
11 changes: 4 additions & 7 deletions src/common/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@
*
*/

#include <boost/type_traits.hpp>
#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
#include <boost/type_traits.hpp>

#include "common/ceph_argparse.h"
#include "common/common_init.h"
#include "common/config.h"
Expand All @@ -43,6 +38,8 @@ namespace fs = std::experimental::filesystem;
// set set_mon_vals()
#define dout_subsys ceph_subsys_monc

namespace fs = std::filesystem;

using std::cerr;
using std::cout;
using std::map;
Expand Down
9 changes: 2 additions & 7 deletions src/global/global_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@
*
*/

#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif

#include "common/async/context_pool.h"
#include "common/ceph_argparse.h"
#include "common/code_environment.h"
Expand Down Expand Up @@ -50,6 +43,8 @@ namespace fs = std::experimental::filesystem;
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_

namespace fs = std::filesystem;

using std::cerr;
using std::string;

Expand Down
10 changes: 3 additions & 7 deletions src/kv/MemDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@
*/

#include "include/compat.h"
#include <filesystem>
#include <set>
#include <map>
#include <string>
#include <memory>
#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
Expand Down Expand Up @@ -44,6 +38,8 @@ namespace fs = std::experimental::filesystem;
#define dwarn dout(0)
#define dinfo dout(0)

namespace fs = std::filesystem;

using std::cerr;
using std::ostream;
using std::string;
Expand Down
14 changes: 5 additions & 9 deletions src/kv/RocksDBStore.cc
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#include <set>
#include <filesystem>
#include <map>
#include <string>
#include <memory>
#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
#include <set>
#include <string>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
Expand Down Expand Up @@ -43,6 +37,8 @@ namespace fs = std::experimental::filesystem;
#undef dout_prefix
#define dout_prefix *_dout << "rocksdb: "

namespace fs = std::filesystem;

using std::function;
using std::list;
using std::map;
Expand Down
12 changes: 4 additions & 8 deletions src/librbd/cache/pwl/DiscardRequest.cc
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#include <filesystem>

#include "common/dout.h"
#include "common/errno.h"
#include "common/hostname.h"
#include "librbd/asio/ContextWQ.h"
#include "librbd/cache/pwl/DiscardRequest.h"

#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif

#include "librbd/cache/pwl/ImageCacheState.h"

#include "librbd/cache/Types.h"
Expand All @@ -28,6 +22,8 @@ namespace fs = std::experimental::filesystem;
#define dout_prefix *_dout << "librbd::cache::pwl:DiscardRequest: " \
<< this << " " << __func__ << ": "

namespace fs = std::filesystem;

namespace librbd {
namespace cache {
namespace pwl {
Expand Down
10 changes: 2 additions & 8 deletions src/mgr/PyModuleRegistry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@

#include "PyModuleRegistry.h"

#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#else
#error std::filesystem not available!
#endif

#include "include/stringify.h"
#include "common/errno.h"
Expand All @@ -42,6 +34,8 @@ namespace fs = std::experimental::filesystem;
#undef dout_prefix
#define dout_prefix *_dout << "mgr[py] "

namespace fs = std::filesystem;

std::set<std::string> obsolete_modules = {
"orchestrator_cli",
};
Expand Down
8 changes: 2 additions & 6 deletions src/test/admin_socket_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@
#ifndef CEPH_ADMIN_SOCKET_OUTPUT_H
#define CEPH_ADMIN_SOCKET_OUTPUT_H

#include <filesystem>
#include <string>
#include <map>
#include <set>
#include <vector>
#if __has_include(<filesystem>) // For extension
#include <filesystem>

namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif

using socket_results = std::map<std::string, std::string>;
using test_functions =
Expand Down
10 changes: 3 additions & 7 deletions src/test/common/test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@
*
*/

#include <filesystem>

#include "gtest/gtest.h"
#include "common/ceph_context.h"
#include "include/util.h"
#include "gtest/gtest.h"

#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif

#if defined(__linux__)
TEST(util, collect_sys_info)
Expand Down
14 changes: 5 additions & 9 deletions src/test/confutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,18 @@
#include "gtest/gtest.h"
#include "include/buffer.h"

#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif

#include <errno.h>
#include <filesystem>
#include <iostream>
#include <stdlib.h>
#include <sstream>

#include <stdlib.h>
#include <stdint.h>
#include <sys/stat.h>
#include <sys/types.h>

namespace fs = std::filesystem;

using ceph::bufferlist;
using std::cerr;
using std::ostringstream;
Expand Down
10 changes: 3 additions & 7 deletions src/test/immutable_object_cache/test_object_store.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#include <filesystem>
#include <iostream>
#include <unistd.h>

#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif

#include "gtest/gtest.h"
#include "include/Context.h"
Expand All @@ -24,6 +18,8 @@ namespace fs = std::experimental::filesystem;

#include "tools/immutable_object_cache/ObjectCacheStore.h"

namespace fs = std::filesystem;

using namespace ceph::immutable_obj_cache;

std::string test_cache_path("/tmp/test_ceph_immutable_shared_cache");
Expand Down
6 changes: 1 addition & 5 deletions src/test/librbd/migration/test_mock_FileStream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
#include "json_spirit/json_spirit.h"
#if __has_include(<filesystem>)
#include <filesystem>

namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif

namespace librbd {
namespace {
Expand Down
8 changes: 2 additions & 6 deletions src/tools/ceph-dencoder/ceph_dencoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@
#include <dlfcn.h>
#include <errno.h>

#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
#include <iomanip>

#include "ceph_ver.h"
Expand All @@ -34,6 +28,8 @@ namespace fs = std::experimental::filesystem;

#define MB(m) ((m) * 1024 * 1024)

namespace fs = std::filesystem;

void usage(ostream &out)
{
out << "usage: ceph-dencoder [commands ...]" << std::endl;
Expand Down
7 changes: 1 addition & 6 deletions src/tools/immutable_object_cache/ObjectCacheStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@

#include "ObjectCacheStore.h"
#include "Utils.h"
#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif

#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_immutable_obj_cache
#undef dout_prefix
#define dout_prefix *_dout << "ceph::cache::ObjectCacheStore: " << this << " " \
<< __func__ << ": "

namespace fs = std::filesystem;

namespace ceph {
namespace immutable_obj_cache {
Expand Down
8 changes: 2 additions & 6 deletions src/tools/rbd_nbd/rbd-nbd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,7 @@
#include <libnl3/netlink/genl/ctrl.h>
#include <libnl3/netlink/genl/mngt.h>

#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#else
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#endif
#include <fstream>
#include <iostream>
#include <memory>
Expand Down Expand Up @@ -86,6 +80,8 @@ namespace fs = std::experimental::filesystem;
#undef dout_prefix
#define dout_prefix *_dout << "rbd-nbd: "

namespace fs = std::filesystem;

using boost::endian::big_to_native;
using boost::endian::native_to_big;

Expand Down

0 comments on commit 756a351

Please sign in to comment.