Switch to std::filesystem

Drop the dependency on Boost.Filesystem

Change-Id: I5d6f6fe38cd0cf1c6996221188fa63db146dc9f9
diff --git a/tests/unit/security/pib/pib-impl.t.cpp b/tests/unit/security/pib/pib-impl.t.cpp
index d3d73de..7f624fd 100644
--- a/tests/unit/security/pib/pib-impl.t.cpp
+++ b/tests/unit/security/pib/pib-impl.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -25,7 +25,8 @@
 #include "tests/boost-test.hpp"
 #include "tests/unit/security/pib/pib-data-fixture.hpp"
 
-#include <boost/filesystem.hpp>
+#include <filesystem>
+
 #include <boost/mp11/list.hpp>
 
 namespace ndn::tests {
@@ -46,14 +47,14 @@
 public:
   ~PibSqlite3Fixture()
   {
-    boost::filesystem::remove_all(m_path);
+    std::filesystem::remove_all(m_path);
   }
 
 private:
-  const boost::filesystem::path m_path{boost::filesystem::path(UNIT_TESTS_TMPDIR) / "TestPibImpl"};
+  const std::filesystem::path m_path{std::filesystem::path(UNIT_TESTS_TMPDIR) / "TestPibImpl"};
 
 public:
-  PibSqlite3 pib{m_path.string()};
+  PibSqlite3 pib{m_path};
 };
 
 using PibImpls = boost::mp11::mp_list<PibMemoryFixture, PibSqlite3Fixture>;
diff --git a/tests/unit/security/tpm/back-end-wrapper-file.hpp b/tests/unit/security/tpm/back-end-wrapper-file.hpp
index 6d8a663..cd25978 100644
--- a/tests/unit/security/tpm/back-end-wrapper-file.hpp
+++ b/tests/unit/security/tpm/back-end-wrapper-file.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -24,7 +24,7 @@
 
 #include "ndn-cxx/security/tpm/impl/back-end-file.hpp"
 
-#include <boost/filesystem.hpp>
+#include <filesystem>
 
 namespace ndn::tests {
 
@@ -35,14 +35,14 @@
 {
 public:
   BackEndWrapperFile()
-    : m_tmpPath(boost::filesystem::path(UNIT_TESTS_TMPDIR) / "TpmBackEndFile")
-    , m_impl(make_unique<security::tpm::BackEndFile>(m_tmpPath.string()))
+    : m_tmpPath(std::filesystem::path(UNIT_TESTS_TMPDIR) / "TpmBackEndFile")
+    , m_impl(make_unique<security::tpm::BackEndFile>(m_tmpPath))
   {
   }
 
   ~BackEndWrapperFile()
   {
-    boost::filesystem::remove_all(m_tmpPath);
+    std::filesystem::remove_all(m_tmpPath);
   }
 
   security::tpm::BackEnd&
@@ -58,7 +58,7 @@
   }
 
 private:
-  const boost::filesystem::path m_tmpPath;
+  const std::filesystem::path m_tmpPath;
   const unique_ptr<security::tpm::BackEnd> m_impl;
 };
 
diff --git a/tests/unit/security/trust-anchor-container.t.cpp b/tests/unit/security/trust-anchor-container.t.cpp
index 246ef1c..b711ba6 100644
--- a/tests/unit/security/trust-anchor-container.t.cpp
+++ b/tests/unit/security/trust-anchor-container.t.cpp
@@ -25,8 +25,6 @@
 #include "tests/key-chain-fixture.hpp"
 #include "tests/unit/clock-fixture.hpp"
 
-#include <boost/filesystem/operations.hpp>
-
 namespace ndn::tests {
 
 using namespace ndn::security;
@@ -38,20 +36,20 @@
 public:
   TrustAnchorContainerFixture()
   {
-    boost::filesystem::create_directories(certDirPath);
+    std::filesystem::create_directories(certDirPath);
 
     identity1 = m_keyChain.createIdentity("/TestAnchorContainer/First");
     cert1 = identity1.getDefaultKey().getDefaultCertificate();
-    saveCert(cert1, certPath1.string());
+    saveCert(cert1, certPath1);
 
     identity2 = m_keyChain.createIdentity("/TestAnchorContainer/Second");
     cert2 = identity2.getDefaultKey().getDefaultCertificate();
-    saveCert(cert2, certPath2.string());
+    saveCert(cert2, certPath2);
   }
 
   ~TrustAnchorContainerFixture() override
   {
-    boost::filesystem::remove_all(certDirPath);
+    std::filesystem::remove_all(certDirPath);
   }
 
   void
@@ -73,9 +71,9 @@
   }
 
 public:
-  const boost::filesystem::path certDirPath{boost::filesystem::path(UNIT_TESTS_TMPDIR) / "test-cert-dir"};
-  const boost::filesystem::path certPath1{certDirPath / "trust-anchor-1.cert"};
-  const boost::filesystem::path certPath2{certDirPath / "trust-anchor-2.cert"};
+  const std::filesystem::path certDirPath{std::filesystem::path(UNIT_TESTS_TMPDIR) / "test-cert-dir"};
+  const std::filesystem::path certPath1{certDirPath / "trust-anchor-1.cert"};
+  const std::filesystem::path certPath2{certDirPath / "trust-anchor-2.cert"};
 
   TrustAnchorContainer anchorContainer;
 
@@ -100,20 +98,20 @@
   BOOST_CHECK_NO_THROW(anchorContainer.insert("group1", Certificate(cert1)));
   BOOST_CHECK_EQUAL(cert, anchorContainer.find(cert1.getName())); // still the same instance of the certificate
   // cannot add dynamic group when static already exists
-  BOOST_CHECK_THROW(anchorContainer.insert("group1", certPath1.string(), 1_s), TrustAnchorContainer::Error);
+  BOOST_CHECK_THROW(anchorContainer.insert("group1", certPath1, 1_s), TrustAnchorContainer::Error);
   BOOST_CHECK_EQUAL(anchorContainer.getGroup("group1").size(), 1);
   BOOST_CHECK_EQUAL(anchorContainer.size(), 1);
 
   // From file
-  anchorContainer.insert("group2", certPath2.string(), 1_s);
+  anchorContainer.insert("group2", certPath2, 1_s);
   BOOST_CHECK(anchorContainer.find(cert2.getName()) != nullptr);
   BOOST_CHECK(anchorContainer.find(identity2.getName()) != nullptr);
   BOOST_CHECK_THROW(anchorContainer.insert("group2", Certificate(cert2)), TrustAnchorContainer::Error);
-  BOOST_CHECK_THROW(anchorContainer.insert("group2", certPath2.string(), 1_s), TrustAnchorContainer::Error);
+  BOOST_CHECK_THROW(anchorContainer.insert("group2", certPath2, 1_s), TrustAnchorContainer::Error);
   BOOST_CHECK_EQUAL(anchorContainer.getGroup("group2").size(), 1);
   BOOST_CHECK_EQUAL(anchorContainer.size(), 2);
 
-  boost::filesystem::remove(certPath2);
+  std::filesystem::remove(certPath2);
   advanceClocks(1_s, 11);
 
   BOOST_CHECK(anchorContainer.find(identity2.getName()) == nullptr);
@@ -134,15 +132,15 @@
 
 BOOST_AUTO_TEST_CASE(DynamicAnchorFromDir)
 {
-  boost::filesystem::remove(certPath2);
+  std::filesystem::remove(certPath2);
 
-  anchorContainer.insert("group", certDirPath.string(), 1_s, true /* isDir */);
+  anchorContainer.insert("group", certDirPath, 1_s, /*isDir*/ true);
 
   BOOST_CHECK(anchorContainer.find(identity1.getName()) != nullptr);
   BOOST_CHECK(anchorContainer.find(identity2.getName()) == nullptr);
   BOOST_CHECK_EQUAL(anchorContainer.getGroup("group").size(), 1);
 
-  saveCert(cert2, certPath2.string());
+  saveCert(cert2, certPath2);
 
   advanceClocks(100_ms, 11);
 
@@ -150,7 +148,7 @@
   BOOST_CHECK(anchorContainer.find(identity2.getName()) != nullptr);
   BOOST_CHECK_EQUAL(anchorContainer.getGroup("group").size(), 2);
 
-  boost::filesystem::remove_all(certDirPath);
+  std::filesystem::remove_all(certDirPath);
 
   advanceClocks(100_ms, 11);
 
@@ -161,7 +159,7 @@
 
 BOOST_AUTO_TEST_CASE(FindByInterest)
 {
-  anchorContainer.insert("group1", certPath1.string(), 1_s);
+  anchorContainer.insert("group1", certPath1, 1_s);
 
   checkFindByInterest(identity1.getName(), true, cert1);
   checkFindByInterest(identity1.getName().getPrefix(-1), true, cert1);
diff --git a/tests/unit/security/validation-policy-config.t.cpp b/tests/unit/security/validation-policy-config.t.cpp
index 746ac90..34412a1 100644
--- a/tests/unit/security/validation-policy-config.t.cpp
+++ b/tests/unit/security/validation-policy-config.t.cpp
@@ -62,7 +62,7 @@
 public:
   ValidationPolicyConfigFixture()
   {
-    boost::filesystem::create_directories(path);
+    std::filesystem::create_directories(path);
     baseConfig = R"CONF(
         rule
         {
@@ -85,7 +85,7 @@
 
   ~ValidationPolicyConfigFixture()
   {
-    boost::filesystem::remove_all(path);
+    std::filesystem::remove_all(path);
   }
 
 private:
@@ -101,7 +101,7 @@
   }
 
 protected:
-  const boost::filesystem::path path{boost::filesystem::path(UNIT_TESTS_TMPDIR) / "security" / "validation-policy-config"};
+  const std::filesystem::path path{std::filesystem::path(UNIT_TESTS_TMPDIR) / "security" / "validation-policy-config"};
   std::string baseConfig;
 
   using Packet = PacketType;
@@ -115,14 +115,14 @@
   {
     BOOST_CHECK_EQUAL(this->policy.m_isConfigured, false);
 
-    this->saveIdentityCert(this->identity, (this->path / "identity.ndncert").string());
+    this->saveIdentityCert(this->identity, this->path / "identity.ndncert");
     this->policy.load(this->baseConfig + R"CONF(
         trust-anchor
         {
           type file
           file-name "trust-anchor.ndncert"
         }
-      )CONF", (this->path / "test-config").string());
+      )CONF", this->path / "test-config");
 
     BOOST_CHECK_EQUAL(this->policy.m_isConfigured, true);
     BOOST_CHECK_EQUAL(this->policy.m_shouldBypass, false);
@@ -135,7 +135,7 @@
 public:
   LoadFileWithFileAnchor()
   {
-    std::string configFile = (this->path / "config.conf").string();
+    auto configFile = this->path / "config.conf";
     {
       std::ofstream config(configFile);
       config << this->baseConfig << R"CONF(
@@ -147,7 +147,7 @@
         )CONF";
     }
 
-    this->saveIdentityCert(this->identity, (this->path / "identity.ndncert").string());
+    this->saveIdentityCert(this->identity, this->path / "identity.ndncert");
 
     BOOST_CHECK_EQUAL(this->policy.m_isConfigured, false);
 
@@ -164,7 +164,7 @@
 public:
   LoadFileWithMultipleFileAnchors()
   {
-    std::string configFile = (this->path / "config.conf").string();
+    auto configFile = this->path / "config.conf";
     {
       std::ofstream config(configFile);
       config << this->baseConfig << R"CONF(
@@ -181,7 +181,7 @@
         )CONF";
     }
 
-    this->saveIdentityCert(this->identity, (this->path / "identity.ndncert").string());
+    this->saveIdentityCert(this->identity, this->path / "identity.ndncert");
 
     BOOST_CHECK_EQUAL(this->policy.m_isConfigured, false);
 
@@ -206,11 +206,11 @@
         }
       )CONF");
 
-    this->saveIdentityCert(this->identity, (this->path / "identity.ndncert").string());
+    this->saveIdentityCert(this->identity, this->path / "identity.ndncert");
 
     BOOST_CHECK_EQUAL(this->policy.m_isConfigured, false);
 
-    this->policy.load(section, (this->path / "test-config").string());
+    this->policy.load(section, this->path / "test-config");
 
     BOOST_CHECK_EQUAL(this->policy.m_isConfigured, true);
     BOOST_CHECK_EQUAL(this->policy.m_shouldBypass, false);
@@ -238,7 +238,7 @@
           type base64
           base64-string ")CONF" + os.str() + R"CONF("
         }
-      )CONF", (this->path / "test-config").string());
+      )CONF", this->path / "test-config");
 
     BOOST_CHECK_EQUAL(this->policy.m_isConfigured, true);
     BOOST_CHECK_EQUAL(this->policy.m_shouldBypass, false);
@@ -307,8 +307,8 @@
   {
     BOOST_CHECK_EQUAL(this->policy.m_isConfigured, false);
 
-    boost::filesystem::create_directories(this->path / "keys");
-    this->saveIdentityCert(this->identity, (this->path / "keys" / "identity.ndncert").string());
+    std::filesystem::create_directories(this->path / "keys");
+    this->saveIdentityCert(this->identity, this->path / "keys" / "identity.ndncert");
 
     this->policy.load(this->baseConfig + R"CONF(
         trust-anchor
@@ -317,7 +317,7 @@
           dir keys
           )CONF" + Refresh::getRefreshString() + R"CONF(
         }
-      )CONF", (this->path / "test-config").string());
+      )CONF", this->path / "test-config");
 
     BOOST_CHECK_EQUAL(this->policy.m_isConfigured, true);
     BOOST_CHECK_EQUAL(this->policy.m_shouldBypass, false);
@@ -713,7 +713,7 @@
   using Packet = Data;
   Packet unsignedPacket("/Security/ValidatorFixture/Sub1/Sub2/Packet");
 
-  boost::filesystem::remove(this->path / "keys" / "identity.ndncert");
+  std::filesystem::remove(this->path / "keys" / "identity.ndncert");
   this->advanceClocks(Refresh::getRefreshTime(), 3);
 
   Packet packet = unsignedPacket;
diff --git a/tests/unit/security/validator-config.t.cpp b/tests/unit/security/validator-config.t.cpp
index 3cfb122..8ca4245 100644
--- a/tests/unit/security/validator-config.t.cpp
+++ b/tests/unit/security/validator-config.t.cpp
@@ -51,28 +51,27 @@
 {
 public:
   ValidatorConfigFixture()
-    : path(boost::filesystem::path(UNIT_TESTS_TMPDIR) / "security" / "validator-config")
+    : path(std::filesystem::path(UNIT_TESTS_TMPDIR) / "security" / "validator-config")
     , validator(make_unique<security::CertificateFetcherOffline>())
   {
-    boost::filesystem::create_directories(path);
+    std::filesystem::create_directories(path);
     config = R"CONF(
         trust-anchor
         {
           type any
         }
       )CONF";
-    configFile = (this->path / "config.conf").string();
-    std::ofstream f(configFile.c_str());
-    f << config;
+    configFile = path / "config.conf";
+    std::ofstream(configFile) << config;
   }
 
   ~ValidatorConfigFixture()
   {
-    boost::filesystem::remove_all(path);
+    std::filesystem::remove_all(path);
   }
 
 public:
-  const boost::filesystem::path path;
+  const std::filesystem::path path;
   std::string config;
   std::string configFile;
   ValidatorConfig validator;