summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@intel.com>2018-07-20 10:52:36 -0700
committerVernon Mauery <vernon.mauery@linux.intel.com>2018-08-08 17:06:54 +0000
commit185b9f8b9d71e92cd31ee32baa09b5807c4a46e9 (patch)
tree30a54df77abcd3729f3930c58a02c9f7fa390958
parentc5046574c66b835173d00b7ed21e2bc008d5ca5f (diff)
downloadphosphor-host-ipmid-185b9f8b9d71e92cd31ee32baa09b5807c4a46e9.zip
phosphor-host-ipmid-185b9f8b9d71e92cd31ee32baa09b5807c4a46e9.tar.gz
Standardize use of filesystem
If <filesystem> exists, use that, if it doesn't, try <experimental/filesystem>. Either way, access it from std via a namespace splice. Change-Id: I5b35ee9f74b88e188cb3ca3fed9abaec64933697 Signed-off-by: Vernon Mauery <vernon.mauery@intel.com>
-rw-r--r--apphandler.cpp14
-rw-r--r--chassishandler.cpp12
-rw-r--r--selutility.cpp12
-rw-r--r--sensordatahandler.cpp12
-rw-r--r--storagehandler.cpp12
-rw-r--r--transporthandler.cpp12
6 files changed, 67 insertions, 7 deletions
diff --git a/apphandler.cpp b/apphandler.cpp
index e69829f..05da67e 100644
--- a/apphandler.cpp
+++ b/apphandler.cpp
@@ -7,6 +7,17 @@
#include "types.hpp"
#include "utils.hpp"
+#if __has_include(<filesystem>)
+#include <filesystem>
+#elif __has_include(<experimental/filesystem>)
+#include <experimental/filesystem>
+namespace std {
+ // splice experimental::filesystem into std
+ namespace filesystem = std::experimental::filesystem;
+}
+#else
+# error filesystem not available
+#endif
#include <fstream>
#include <stdio.h>
#include <stdint.h>
@@ -16,7 +27,6 @@
#include <vector>
#include <string>
#include <cstddef>
-#include <experimental/filesystem>
#include <arpa/inet.h>
#include "transporthandler.hpp"
@@ -49,7 +59,7 @@ using namespace sdbusplus::xyz::openbmc_project::Common::Error;
using Version = sdbusplus::xyz::openbmc_project::Software::server::Version;
using Activation =
sdbusplus::xyz::openbmc_project::Software::server::Activation;
-namespace fs = std::experimental::filesystem;
+namespace fs = std::filesystem;
// Offset in get device id command.
typedef struct
diff --git a/chassishandler.cpp b/chassishandler.cpp
index 3092e7c..04bbffe 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -19,7 +19,17 @@
#include <fstream>
#include <future>
#include <chrono>
+#if __has_include(<filesystem>)
+#include <filesystem>
+#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
+namespace std {
+ // splice experimental::filesystem into std
+ namespace filesystem = std::experimental::filesystem;
+}
+#else
+# error filesystem not available
+#endif
#include <string>
#include <map>
@@ -122,7 +132,7 @@ struct GetPOHCountResponse
// Phosphor Host State manager
namespace State = sdbusplus::xyz::openbmc_project::State::server;
-namespace fs = std::experimental::filesystem;
+namespace fs = std::filesystem;
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
diff --git a/selutility.cpp b/selutility.cpp
index b4675d1..5935de2 100644
--- a/selutility.cpp
+++ b/selutility.cpp
@@ -1,6 +1,16 @@
#include <chrono>
#include <vector>
+#if __has_include(<filesystem>)
+#include <filesystem>
+#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
+namespace std {
+ // splice experimental::filesystem into std
+ namespace filesystem = std::experimental::filesystem;
+}
+#else
+# error filesystem not available
+#endif
#include <phosphor-logging/elog-errors.hpp>
#include "host-ipmid/ipmid-api.h"
#include "xyz/openbmc_project/Common/error.hpp"
@@ -241,7 +251,7 @@ void readLoggingObjectPaths(ObjectPaths& paths)
std::sort(paths.begin(), paths.end(), [](const std::string& a,
const std::string& b)
{
- namespace fs = std::experimental::filesystem;
+ namespace fs = std::filesystem;
fs::path pathA(a);
fs::path pathB(b);
auto idA = std::stoul(pathA.filename().string());
diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp
index 2d4ac3a..ef5089a 100644
--- a/sensordatahandler.cpp
+++ b/sensordatahandler.cpp
@@ -1,5 +1,15 @@
#include <bitset>
+#if __has_include(<filesystem>)
+#include <filesystem>
+#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
+namespace std {
+ // splice experimental::filesystem into std
+ namespace filesystem = std::experimental::filesystem;
+}
+#else
+# error filesystem not available
+#endif
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
#include "xyz/openbmc_project/Common/error.hpp"
@@ -409,7 +419,7 @@ namespace get
GetSensorResponse assertion(const Info& sensorInfo)
{
- namespace fs = std::experimental::filesystem;
+ namespace fs = std::filesystem;
fs::path path{ipmi::sensor::inventoryRoot};
path += sensorInfo.sensorPath;
diff --git a/storagehandler.cpp b/storagehandler.cpp
index c020948..f0997e8 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -2,7 +2,17 @@
#include <arpa/inet.h>
#include <chrono>
#include <cstdio>
+#if __has_include(<filesystem>)
+#include <filesystem>
+#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
+namespace std {
+ // splice experimental::filesystem into std
+ namespace filesystem = std::experimental::filesystem;
+}
+#else
+# error filesystem not available
+#endif
#include <mapper.h>
#include <string>
#include <systemd/sd-bus.h>
@@ -203,7 +213,7 @@ ipmi_ret_t getSELEntry(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
}
else
{
- namespace fs = std::experimental::filesystem;
+ namespace fs = std::filesystem;
fs::path path(*iter);
record.nextRecordID = static_cast<uint16_t>
(std::stoul(std::string(path.filename().c_str())));
diff --git a/transporthandler.cpp b/transporthandler.cpp
index 98d9573..95b983a 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -5,7 +5,17 @@
#include <stdint.h>
#include <arpa/inet.h>
#include <string>
+#if __has_include(<filesystem>)
+#include <filesystem>
+#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
+namespace std {
+ // splice experimental::filesystem into std
+ namespace filesystem = std::experimental::filesystem;
+}
+#else
+# error filesystem not available
+#endif
#include "app/channel.hpp"
#include "host-ipmid/ipmid-api.h"
@@ -36,7 +46,7 @@ std::map<int, std::unique_ptr<struct ChannelConfig_t>> channelConfig;
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
-namespace fs = std::experimental::filesystem;
+namespace fs = std::filesystem;
void register_netfn_transport_functions() __attribute__((constructor));
OpenPOWER on IntegriCloud