c++17: drop experimental::filesystem

Use std::filesystem, and drop support for building with experimental
under c++14.

Tested: Build the repo.
Change-Id: I4af0d9c034dbfef5a65153ba5447b86c961aebf1
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/phosphor-ldap-mapper/Makefile.am b/phosphor-ldap-mapper/Makefile.am
index 1c631e7..7bd58d5 100644
--- a/phosphor-ldap-mapper/Makefile.am
+++ b/phosphor-ldap-mapper/Makefile.am
@@ -12,8 +12,7 @@
 
 phosphor_ldap_mapper_LDFLAGS = $(SDBUSPLUS_LIBS) \
                                $(PHOSPHOR_DBUS_INTERFACES_LIBS) \
-                               $(PHOSPHOR_LOGGING_LIBS) \
-                               -lstdc++fs
+                               $(PHOSPHOR_LOGGING_LIBS)
 
 phosphor_ldap_mapper_CXXFLAGS = $(SYSTEMD_CFLAGS) \
                                 $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) \
diff --git a/phosphor-ldap-mapper/ldap_mapper_entry.cpp b/phosphor-ldap-mapper/ldap_mapper_entry.cpp
index 8410942..781833e 100644
--- a/phosphor-ldap-mapper/ldap_mapper_entry.cpp
+++ b/phosphor-ldap-mapper/ldap_mapper_entry.cpp
@@ -1,4 +1,4 @@
-#include <experimental/filesystem>
+#include <filesystem>
 #include <xyz/openbmc_project/Common/error.hpp>
 #include <xyz/openbmc_project/User/Common/error.hpp>
 #include <phosphor-logging/log.hpp>
@@ -25,8 +25,8 @@
                                  const std::string &privilege,
                                  LDAPMapperMgr &parent) :
     Ifaces(bus, path, true),
-    id(std::stol(std::experimental::filesystem::path(path).filename())),
-    manager(parent), persistPath(filePath)
+    id(std::stol(std::filesystem::path(path).filename())), manager(parent),
+    persistPath(filePath)
 {
     Ifaces::privilege(privilege, true);
     Ifaces::groupName(groupName, true);
@@ -36,8 +36,8 @@
 LDAPMapperEntry::LDAPMapperEntry(sdbusplus::bus::bus &bus, const char *path,
                                  const char *filePath, LDAPMapperMgr &parent) :
     Ifaces(bus, path, true),
-    id(std::stol(std::experimental::filesystem::path(path).filename())),
-    manager(parent), persistPath(filePath)
+    id(std::stol(std::filesystem::path(path).filename())), manager(parent),
+    persistPath(filePath)
 {
 }
 
diff --git a/phosphor-ldap-mapper/ldap_mapper_mgr.cpp b/phosphor-ldap-mapper/ldap_mapper_mgr.cpp
index a1d6e11..b8d755b 100644
--- a/phosphor-ldap-mapper/ldap_mapper_mgr.cpp
+++ b/phosphor-ldap-mapper/ldap_mapper_mgr.cpp
@@ -1,3 +1,4 @@
+#include <filesystem>
 #include <xyz/openbmc_project/Common/error.hpp>
 #include <xyz/openbmc_project/User/Common/error.hpp>
 #include <phosphor-logging/log.hpp>
@@ -52,9 +53,9 @@
 void LDAPMapperMgr::deletePrivilegeMapper(Id id)
 {
     // Delete the persistent representation of the privilege mapper.
-    fs::path mapperPath(persistPath);
+    std::filesystem::path mapperPath(persistPath);
     mapperPath /= std::to_string(id);
-    fs::remove(mapperPath);
+    std::filesystem::remove(mapperPath);
 
     PrivilegeMapperList.erase(id);
 }
@@ -97,15 +98,13 @@
 
 void LDAPMapperMgr::restore()
 {
-    namespace fs = std::experimental::filesystem;
-
-    fs::path dir(persistPath);
-    if (!fs::exists(dir) || fs::is_empty(dir))
+    std::filesystem::path dir(persistPath);
+    if (!std::filesystem::exists(dir) || std::filesystem::is_empty(dir))
     {
         return;
     }
 
-    for (auto &file : fs::directory_iterator(dir))
+    for (auto &file : std::filesystem::directory_iterator(dir))
     {
         std::string id = file.path().filename().c_str();
         size_t idNum = std::stol(id);
diff --git a/phosphor-ldap-mapper/ldap_mapper_serialize.cpp b/phosphor-ldap-mapper/ldap_mapper_serialize.cpp
index 3ef809e..65918fd 100644
--- a/phosphor-ldap-mapper/ldap_mapper_serialize.cpp
+++ b/phosphor-ldap-mapper/ldap_mapper_serialize.cpp
@@ -1,6 +1,7 @@
 #include <cereal/archives/binary.hpp>
 #include <cereal/types/string.hpp>
 #include <fstream>
+#include <filesystem>
 #include <phosphor-logging/log.hpp>
 #include "config.h"
 #include "ldap_mapper_serialize.hpp"
@@ -54,7 +55,8 @@
         privilege(privilege, true);
 }
 
-fs::path serialize(const LDAPMapperEntry& entry, Id id, const fs::path& dir)
+std::filesystem::path serialize(const LDAPMapperEntry& entry, Id id,
+                                const std::filesystem::path& dir)
 {
     auto path = dir / std::to_string(id);
     std::ofstream os(path.c_str(), std::ios::binary);
@@ -63,11 +65,11 @@
     return path;
 }
 
-bool deserialize(const fs::path& path, LDAPMapperEntry& entry)
+bool deserialize(const std::filesystem::path& path, LDAPMapperEntry& entry)
 {
     try
     {
-        if (fs::exists(path))
+        if (std::filesystem::exists(path))
         {
             std::ifstream is(path.c_str(), std::ios::in | std::ios::binary);
             cereal::BinaryInputArchive iarchive(is);
@@ -79,13 +81,13 @@
     catch (cereal::Exception& e)
     {
         log<level::ERR>(e.what());
-        fs::remove(path);
+        std::filesystem::remove(path);
         return false;
     }
     catch (const std::length_error& e)
     {
         log<level::ERR>(e.what());
-        fs::remove(path);
+        std::filesystem::remove(path);
         return false;
     }
 }
diff --git a/phosphor-ldap-mapper/ldap_mapper_serialize.hpp b/phosphor-ldap-mapper/ldap_mapper_serialize.hpp
index 5ab71c0..7d918d8 100644
--- a/phosphor-ldap-mapper/ldap_mapper_serialize.hpp
+++ b/phosphor-ldap-mapper/ldap_mapper_serialize.hpp
@@ -1,6 +1,6 @@
 #pragma once
 
-#include <experimental/filesystem>
+#include <filesystem>
 #include "config.h"
 #include "ldap_mapper_entry.hpp"
 
@@ -9,8 +9,6 @@
 namespace user
 {
 
-namespace fs = std::experimental::filesystem;
-
 /** @brief Serialize and persist LDAP privilege mapper D-Bus object
  *
  *  @param[in] entry - LDAP privilege mapper entry
@@ -18,9 +16,10 @@
  *  @param[in] dir - pathname of directory where the serialized privilege
  *                   mappings are stored.
  *
- *  @return fs::path - pathname of persisted error file
+ *  @return std::filesystem::path - pathname of persisted error file
  */
-fs::path serialize(const LDAPMapperEntry& entry, Id id, const fs::path& dir);
+std::filesystem::path serialize(const LDAPMapperEntry& entry, Id id,
+                                const std::filesystem::path& dir);
 
 /** @brief Deserialize a persisted LDAP privilege mapper into a D-Bus object
  *
@@ -30,7 +29,7 @@
  *
  *  @return bool - true if the deserialization was successful, false otherwise.
  */
-bool deserialize(const fs::path& path, LDAPMapperEntry& entry);
+bool deserialize(const std::filesystem::path& path, LDAPMapperEntry& entry);
 
 } // namespace user
 } // namespace phosphor
diff --git a/phosphor-ldap-mapper/main.cpp b/phosphor-ldap-mapper/main.cpp
index e0d2255..1833a6a 100644
--- a/phosphor-ldap-mapper/main.cpp
+++ b/phosphor-ldap-mapper/main.cpp
@@ -1,5 +1,5 @@
 #include <string>
-#include <experimental/filesystem>
+#include <filesystem>
 #include "config.h"
 #include "ldap_mapper_mgr.hpp"
 
@@ -13,7 +13,7 @@
                                             LDAP_MAPPER_PERSIST_PATH);
 
     // Create a directory to persist errors.
-    std::experimental::filesystem::create_directories(LDAP_MAPPER_PERSIST_PATH);
+    std::filesystem::create_directories(LDAP_MAPPER_PERSIST_PATH);
 
     // Restore the serialized LDAP group privilege mapping.
     mapperMgr.restore();