Switch to std::filesystem

Change-Id: I61a4b4562b3c7fabefb07dced580d2b20d7b6d78
diff --git a/.jenkins.d/00-deps.sh b/.jenkins.d/00-deps.sh
index b5fb9a8..14908f4 100755
--- a/.jenkins.d/00-deps.sh
+++ b/.jenkins.d/00-deps.sh
@@ -7,7 +7,6 @@
     libboost-chrono-dev
     libboost-date-time-dev
     libboost-dev
-    libboost-filesystem-dev
     libboost-log-dev
     libboost-program-options-dev
     libboost-stacktrace-dev
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index 3e001a9..3c724fe 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -136,7 +136,7 @@
         return {
             'CXXFLAGS': [],
             'LINKFLAGS': [],
-            'DEFINES': ['BOOST_ASIO_NO_DEPRECATED', 'BOOST_FILESYSTEM_NO_DEPRECATED'],
+            'DEFINES': ['BOOST_ASIO_NO_DEPRECATED'],
         }
 
     def getOptimizedFlags(self, conf):
diff --git a/src/detail/ca-sqlite.cpp b/src/detail/ca-sqlite.cpp
index 809f91f..ca4458d 100644
--- a/src/detail/ca-sqlite.cpp
+++ b/src/detail/ca-sqlite.cpp
@@ -25,10 +25,10 @@
 #include <ndn-cxx/security/validation-policy.hpp>
 #include <ndn-cxx/util/sqlite3-statement.hpp>
 
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
 #include <boost/property_tree/json_parser.hpp>
 
+#include <filesystem>
+
 namespace ndncert::ca {
 
 using ndn::util::Sqlite3Statement;
@@ -80,21 +80,21 @@
   : CaStorage()
 {
   // Determine the path of sqlite db
-  boost::filesystem::path dbDir;
+  std::filesystem::path dbDir;
   if (!path.empty()) {
-    dbDir = boost::filesystem::path(path);
+    dbDir = std::filesystem::path(path);
   }
   else {
     std::string dbName = caName.toUri();
     std::replace(dbName.begin(), dbName.end(), '/', '_');
     dbName += ".db";
     if (getenv("HOME") != nullptr) {
-      dbDir = boost::filesystem::path(getenv("HOME")) / ".ndncert";
+      dbDir = std::filesystem::path(getenv("HOME")) / ".ndncert";
     }
     else {
-      dbDir = boost::filesystem::current_path() / ".ndncert";
+      dbDir = std::filesystem::current_path() / ".ndncert";
     }
-    boost::filesystem::create_directories(dbDir);
+    std::filesystem::create_directories(dbDir);
     dbDir /= dbName;
   }
 
diff --git a/tests/global-configuration.cpp b/tests/global-configuration.cpp
index e217098..d328d71 100644
--- a/tests/global-configuration.cpp
+++ b/tests/global-configuration.cpp
@@ -22,11 +22,10 @@
 
 #include <ndn-cxx/util/exception.hpp>
 
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
 #include <stdexcept>
 #include <stdlib.h>
+#include <system_error>
 
 namespace ndncert::tests {
 
@@ -40,10 +39,10 @@
       m_home.assign(envHome);
 
     // in case an earlier test run crashed without a chance to run the destructor
-    boost::filesystem::remove_all(TESTDIR);
+    std::filesystem::remove_all(TESTDIR);
 
     auto testHome = TESTDIR / "test-home";
-    boost::filesystem::create_directories(testHome);
+    std::filesystem::create_directories(testHome);
 
     if (::setenv("HOME", testHome.c_str(), 1) != 0)
       NDN_THROW(std::runtime_error("setenv() failed"));
@@ -56,12 +55,12 @@
     else
       ::setenv("HOME", m_home.data(), 1);
 
-    boost::system::error_code ec;
-    boost::filesystem::remove_all(TESTDIR, ec); // ignore error
+    std::error_code ec;
+    std::filesystem::remove_all(TESTDIR, ec); // ignore error
   }
 
 private:
-  static inline const boost::filesystem::path TESTDIR{UNIT_TESTS_TMPDIR};
+  static inline const std::filesystem::path TESTDIR{UNIT_TESTS_TMPDIR};
   std::string m_home;
 };
 
diff --git a/tests/unit-tests/ca-sqlite.t.cpp b/tests/unit-tests/ca-sqlite.t.cpp
index 416c32c..80037ed 100644
--- a/tests/unit-tests/ca-sqlite.t.cpp
+++ b/tests/unit-tests/ca-sqlite.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2017-2022, Regents of the University of California.
+ * Copyright (c) 2017-2024, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
  *
@@ -23,8 +23,8 @@
 #include "tests/boost-test.hpp"
 #include "tests/key-chain-fixture.hpp"
 
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
+#include <filesystem>
+#include <system_error>
 
 namespace ndncert::tests {
 
@@ -34,21 +34,19 @@
 {
 public:
   DatabaseFixture()
+    : dbDir(std::filesystem::path{UNIT_TESTS_TMPDIR} / "test-home" / ".ndncert")
   {
-    boost::filesystem::path parentDir{UNIT_TESTS_TMPDIR};
-    dbDir = parentDir / "test-home" / ".ndncert";
-    if (!boost::filesystem::exists(dbDir)) {
-      boost::filesystem::create_directory(dbDir);
-    }
+    std::filesystem::create_directory(dbDir);
   }
 
   ~DatabaseFixture()
   {
-    boost::filesystem::remove_all(dbDir);
+    std::error_code ec;
+    std::filesystem::remove_all(dbDir, ec); // ignore error
   }
 
 protected:
-  boost::filesystem::path dbDir;
+  std::filesystem::path dbDir;
 };
 
 BOOST_FIXTURE_TEST_SUITE(TestCaSqlite, DatabaseFixture)
diff --git a/wscript b/wscript
index 67ece59..6cda429 100644
--- a/wscript
+++ b/wscript
@@ -39,7 +39,7 @@
     conf.check_sqlite3()
     conf.check_openssl(lib='crypto', atleast_version='1.1.1')
 
-    conf.check_boost(lib='filesystem', mt=True)
+    conf.check_boost()
     if conf.env.BOOST_VERSION_NUMBER < 107100:
         conf.fatal('The minimum supported version of Boost is 1.71.0.\n'
                    'Please upgrade your distribution or manually install a newer version of Boost.\n'