filesystem is not experimental anymore since c++17
- filesystem is merged into the mainline ISO C++ standard
since C++ 17.
- As the minimum requirement for the project to compile is
mentioned as C++17, we can now safely remove the experimental
filesystem and use them directly instead.
- This would eliminate the stdc++fs dependency when migrated to
meson.
Tested By;
- Compiled in all sdks, and unit tests are passed.
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: Icd63297a533c56e2d1952e99e17ec71747bd0e39
diff --git a/Makefile.am b/Makefile.am
index d27b304..bbf1d41 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -89,8 +89,7 @@
$(SDEVENTPLUS_LIBS) \
$(STDPLUS_LIBS) \
$(PHOSPHOR_DBUS_INTERFACES_LIBS) \
- $(PHOSPHOR_LOGGING_LIBS) \
- -lstdc++fs
+ $(PHOSPHOR_LOGGING_LIBS)
phosphor_network_manager_CXXFLAGS = \
$(SYSTEMD_CFLAGS) \
diff --git a/config_parser.hpp b/config_parser.hpp
index 164d3c3..8af4a34 100644
--- a/config_parser.hpp
+++ b/config_parser.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include <experimental/filesystem>
+#include <filesystem>
#include <map>
#include <string>
#include <tuple>
@@ -18,7 +18,7 @@
using KeyValueMap = std::multimap<std::string, std::string>;
using ValueList = std::vector<std::string>;
-namespace fs = std::experimental::filesystem;
+namespace fs = std::filesystem;
enum class ReturnCode
{
diff --git a/dns_updater.hpp b/dns_updater.hpp
index 32cbb1b..5d23b29 100644
--- a/dns_updater.hpp
+++ b/dns_updater.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include <experimental/filesystem>
+#include <filesystem>
namespace phosphor
{
@@ -11,7 +11,7 @@
namespace updater
{
-namespace fs = std::experimental::filesystem;
+namespace fs = std::filesystem;
constexpr auto RESOLV_CONF = "/etc/resolv.conf";
diff --git a/ethernet_interface.cpp b/ethernet_interface.cpp
index 648595c..677cdd8 100644
--- a/ethernet_interface.cpp
+++ b/ethernet_interface.cpp
@@ -19,7 +19,7 @@
#include <unistd.h>
#include <algorithm>
-#include <experimental/filesystem>
+#include <filesystem>
#include <fstream>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
@@ -439,7 +439,7 @@
type = type.substr(type.rfind('.') + 1);
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
- std::experimental::filesystem::path objectPath;
+ std::filesystem::path objectPath;
objectPath /= objPath;
objectPath /= type;
objectPath /= generateId(ipaddress, prefixLength, gateway);
@@ -449,7 +449,7 @@
std::string EthernetInterface::generateStaticNeighborObjectPath(
const std::string& iPAddress, const std::string& mACAddress) const
{
- std::experimental::filesystem::path objectPath;
+ std::filesystem::path objectPath;
objectPath /= objPath;
objectPath /= "static_neighbor";
objectPath /= generateNeighborId(iPAddress, mACAddress);
@@ -783,7 +783,7 @@
using namespace std::string_literals;
using AddressOrigin =
sdbusplus::xyz::openbmc_project::Network::server::IP::AddressOrigin;
- namespace fs = std::experimental::filesystem;
+ namespace fs = std::filesystem;
// if there is vlan interafce then write the configuration file
// for vlan also.
diff --git a/ethernet_interface.hpp b/ethernet_interface.hpp
index f8086a4..7192e26 100644
--- a/ethernet_interface.hpp
+++ b/ethernet_interface.hpp
@@ -5,7 +5,7 @@
#include "xyz/openbmc_project/Network/IP/Create/server.hpp"
#include "xyz/openbmc_project/Network/Neighbor/CreateStatic/server.hpp"
-#include <experimental/filesystem>
+#include <filesystem>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
#include <string>
@@ -35,7 +35,7 @@
using ServerList = std::vector<std::string>;
using ObjectPath = sdbusplus::message::object_path;
-namespace fs = std::experimental::filesystem;
+namespace fs = std::filesystem;
class Manager; // forward declaration of network manager.
diff --git a/network_manager.hpp b/network_manager.hpp
index c9f95b3..6815d3f 100644
--- a/network_manager.hpp
+++ b/network_manager.hpp
@@ -6,7 +6,7 @@
#include "vlan_interface.hpp"
#include "xyz/openbmc_project/Network/VLAN/Create/server.hpp"
-#include <experimental/filesystem>
+#include <filesystem>
#include <list>
#include <memory>
#include <sdbusplus/bus.hpp>
@@ -22,7 +22,7 @@
using SystemConfPtr = std::unique_ptr<SystemConfiguration>;
using DHCPConfPtr = std::unique_ptr<dhcp::Configuration>;
-namespace fs = std::experimental::filesystem;
+namespace fs = std::filesystem;
namespace details
{
diff --git a/test/Makefile.am b/test/Makefile.am
index d728099..3d63748 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -25,7 +25,7 @@
$(PHOSPHOR_LOGGING_CFLAGS) \
$(PHOSPHOR_DBUS_INTERFACES_CFLAGS)
-generic_ld_flags = -lgtest_main -lgtest -lgmock -lstdc++fs \
+generic_ld_flags = -lgtest_main -lgtest -lgmock \
$(OESDK_TESTCASE_FLAGS) \
$(SYSTEMD_LIBS) \
$(SDBUSPLUS_LIBS) \
diff --git a/test/test_network_manager.cpp b/test/test_network_manager.cpp
index 7943057..df7db77 100644
--- a/test/test_network_manager.cpp
+++ b/test/test_network_manager.cpp
@@ -7,7 +7,7 @@
#include <stdlib.h>
#include <exception>
-#include <experimental/filesystem>
+#include <filesystem>
#include <sdbusplus/bus.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
@@ -21,7 +21,7 @@
std::unique_ptr<Timer> refreshObjectTimer = nullptr;
std::unique_ptr<Timer> restartTimer = nullptr;
-namespace fs = std::experimental::filesystem;
+namespace fs = std::filesystem;
class TestNetworkManager : public testing::Test
{
diff --git a/test/test_vlan_interface.cpp b/test/test_vlan_interface.cpp
index 1dffc7e..76c0828 100644
--- a/test/test_vlan_interface.cpp
+++ b/test/test_vlan_interface.cpp
@@ -9,7 +9,7 @@
#include <netinet/in.h>
#include <exception>
-#include <experimental/filesystem>
+#include <filesystem>
#include <sdbusplus/bus.hpp>
#include <gtest/gtest.h>
@@ -19,7 +19,7 @@
namespace network
{
-namespace fs = std::experimental::filesystem;
+namespace fs = std::filesystem;
class TestVlanInterface : public testing::Test
{
diff --git a/util.cpp b/util.cpp
index c880fd6..63b8f7e 100644
--- a/util.cpp
+++ b/util.cpp
@@ -11,7 +11,7 @@
#include <algorithm>
#include <cstdlib>
#include <cstring>
-#include <experimental/filesystem>
+#include <filesystem>
#include <fstream>
#include <list>
#include <nlohmann/json.hpp>
@@ -33,7 +33,7 @@
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
-namespace fs = std::experimental::filesystem;
+namespace fs = std::filesystem;
uint8_t toV6Cidr(const std::string& subnetMask)
{
diff --git a/vlan_interface.cpp b/vlan_interface.cpp
index 7a1caf7..6fa3b84 100644
--- a/vlan_interface.cpp
+++ b/vlan_interface.cpp
@@ -6,7 +6,7 @@
#include "network_manager.hpp"
#include <algorithm>
-#include <experimental/filesystem>
+#include <filesystem>
#include <fstream>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
diff --git a/watch.hpp b/watch.hpp
index bffed3e..b45f53f 100644
--- a/watch.hpp
+++ b/watch.hpp
@@ -7,7 +7,7 @@
#include <sys/inotify.h>
#include <systemd/sd-event.h>
-#include <experimental/filesystem>
+#include <filesystem>
#include <functional>
#include <map>
@@ -18,7 +18,7 @@
namespace inotify
{
-namespace fs = std::experimental::filesystem;
+namespace fs = std::filesystem;
// Auxiliary callback to be invoked on inotify events
using UserCallBack = std::function<void(const std::string&)>;