Switch to std::filesystem

Change-Id: If70258048d6f54c3e9f0a25bf8f3e327411c42ac
diff --git a/.jenkins.d/00-deps.sh b/.jenkins.d/00-deps.sh
index d16fe41..d55a187 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-iostreams-dev
     libboost-log-dev
     libboost-program-options-dev
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index 9899d05..090e65d 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/storage/sqlite-storage.cpp b/src/storage/sqlite-storage.cpp
index a9627ff..0ee3f7c 100644
--- a/src/storage/sqlite-storage.cpp
+++ b/src/storage/sqlite-storage.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2019, Regents of the University of California.
+ * Copyright (c) 2014-2024, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -18,15 +18,12 @@
  */
 
 #include "sqlite-storage.hpp"
-#include "config.hpp"
 
+#include <ndn-cxx/util/logger.hpp>
 #include <ndn-cxx/util/sha256.hpp>
 #include <ndn-cxx/util/sqlite3-statement.hpp>
 
-#include <boost/filesystem.hpp>
-#include <istream>
-
-#include <ndn-cxx/util/logger.hpp>
+#include <filesystem>
 
 namespace repo {
 
@@ -35,25 +32,22 @@
 SqliteStorage::SqliteStorage(const std::string& dbPath)
 {
   if (dbPath.empty()) {
-    m_dbPath = std::string("ndn_repo.db");
-    NDN_LOG_DEBUG("Create db file in local location [" << m_dbPath << "]. " );
-    NDN_LOG_DEBUG("You can assign the path using -d option" );
+    m_dbPath = "ndn_repo.db";
   }
   else {
-    boost::filesystem::path fsPath(dbPath);
-    boost::filesystem::file_status fsPathStatus = boost::filesystem::status(fsPath);
-    if (!boost::filesystem::is_directory(fsPathStatus)) {
-      if (!boost::filesystem::create_directory(boost::filesystem::path(fsPath))) {
-        NDN_THROW(Error("Folder '" + dbPath + "' does not exists and cannot be created"));
+    std::filesystem::path fsPath(dbPath);
+    if (!std::filesystem::is_directory(fsPath)) {
+      if (!std::filesystem::create_directory(fsPath)) {
+        NDN_THROW(Error("Directory '" + dbPath + "' does not exists and cannot be created"));
       }
     }
-
     m_dbPath = dbPath + "/ndn_repo.db";
   }
+
+  NDN_LOG_DEBUG("Using database file " << m_dbPath);
   initializeRepo();
 }
 
-
 void
 SqliteStorage::initializeRepo()
 {
@@ -95,7 +89,7 @@
   Name name = data.getFullName(); // store the full name
   ndn::util::Sqlite3Statement stmt(m_db, "INSERT INTO NDN_REPO_V2 (name, data) VALUES (?, ?);");
 
-  //Insert
+  // Insert
   // Bind NULL to name value in NDN_REPO_V2 when initialize result.
   auto result = sqlite3_bind_null(stmt, 1);
   if (result == SQLITE_OK) {
@@ -106,7 +100,6 @@
     result = stmt.bind(2, data.wireEncode(), SQLITE_STATIC);
   }
 
-  int id = 0;
   if (result == SQLITE_OK) {
     int rc = 0;
     rc = stmt.step();
@@ -115,12 +108,11 @@
       NDN_THROW(Error("Insert failed"));
     }
     sqlite3_reset(stmt);
-    id = sqlite3_last_insert_rowid(m_db);
+    return sqlite3_last_insert_rowid(m_db);
   }
   else {
-    NDN_THROW(Error("Some error with insert"));
+    NDN_THROW(Error("Database insert failure (code: " + std::to_string(result)));
   }
-  return id;
 }
 
 bool
@@ -250,7 +242,7 @@
       break;
     }
     else {
-      NDN_THROW(Error("Database query failure (code: " + ndn::to_string(rc)));
+      NDN_THROW(Error("Database query failure (code: " + std::to_string(rc)));
     }
   }
 }
@@ -266,8 +258,7 @@
     NDN_THROW(Error("Database query failure"));
   }
 
-  uint64_t nData = stmt.getInt(0);
-  return nData;
+  return stmt.getInt(0);
 }
 
 } // namespace repo
diff --git a/tests/identity-management-fixture.cpp b/tests/identity-management-fixture.cpp
index ef5ab5c..106797b 100644
--- a/tests/identity-management-fixture.cpp
+++ b/tests/identity-management-fixture.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2022, Regents of the University of California.
+ * Copyright (c) 2014-2024, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -25,7 +25,7 @@
 #include <ndn-cxx/security/certificate.hpp>
 #include <ndn-cxx/util/io.hpp>
 
-#include <boost/filesystem.hpp>
+#include <filesystem>
 
 namespace repo::tests {
 
@@ -37,9 +37,9 @@
 
 IdentityManagementFixture::~IdentityManagementFixture()
 {
-  boost::system::error_code ec;
+  std::error_code ec;
   for (const auto& certFile : m_certFiles) {
-    boost::filesystem::remove(certFile, ec); // ignore error
+    std::filesystem::remove(certFile, ec); // ignore error
   }
 }
 
diff --git a/tests/repo-storage-fixture.hpp b/tests/repo-storage-fixture.hpp
index f573736..83b3f3f 100644
--- a/tests/repo-storage-fixture.hpp
+++ b/tests/repo-storage-fixture.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2018-2022, Regents of the University of California.
+ * Copyright (c) 2018-2024, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -23,27 +23,22 @@
 #include "storage/repo-storage.hpp"
 #include "storage/sqlite-storage.hpp"
 
-#include <boost/filesystem.hpp>
+#include <filesystem>
 
 namespace repo::tests {
 
 class RepoStorageFixture
 {
 public:
-  RepoStorageFixture()
-    : store(std::make_shared<SqliteStorage>("unittestdb"))
-    , handle(std::make_shared<RepoStorage>(*store))
-  {
-  }
-
   ~RepoStorageFixture()
   {
-    boost::filesystem::remove_all(boost::filesystem::path("unittestdb"));
+    std::error_code ec;
+    std::filesystem::remove_all(std::filesystem::path("unittestdb"), ec);
   }
 
 public:
-  std::shared_ptr<Storage> store;
-  std::shared_ptr<RepoStorage> handle;
+  std::shared_ptr<Storage> store = std::make_shared<SqliteStorage>("unittestdb");
+  std::shared_ptr<RepoStorage> handle = std::make_shared<RepoStorage>(*store);
 };
 
 } // namespace repo::tests
diff --git a/tests/sqlite-fixture.hpp b/tests/sqlite-fixture.hpp
index c478d64..dbe5ea0 100644
--- a/tests/sqlite-fixture.hpp
+++ b/tests/sqlite-fixture.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2022, Regents of the University of California.
+ * Copyright (c) 2014-2024, Regents of the University of California.
  *
  * This file is part of NDN repo-ng (Next generation of NDN repository).
  * See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -22,26 +22,22 @@
 
 #include "storage/sqlite-storage.hpp"
 
-#include <boost/filesystem.hpp>
+#include <filesystem>
 
 namespace repo::tests {
 
 class SqliteFixture
 {
 public:
-  SqliteFixture()
-    : handle(new SqliteStorage("unittestdb"))
-  {
-  }
-
   ~SqliteFixture()
   {
-    delete handle;
-    boost::filesystem::remove_all(boost::filesystem::path("unittestdb"));
+    handle.reset();
+    std::error_code ec;
+    std::filesystem::remove_all(std::filesystem::path("unittestdb"), ec);
   }
 
 public:
-  SqliteStorage* handle;
+  std::unique_ptr<SqliteStorage> handle = std::make_unique<SqliteStorage>("unittestdb");
 };
 
 } // namespace repo::tests
diff --git a/wscript b/wscript
index e6a986e..d2c16f6 100644
--- a/wscript
+++ b/wscript
@@ -39,7 +39,7 @@
 
     conf.check_sqlite3()
 
-    conf.check_boost(lib='filesystem program_options', mt=True)
+    conf.check_boost(lib='program_options', mt=True)
 
     if conf.env.WITH_TESTS:
         conf.check_boost(lib='unit_test_framework', mt=True, uselib_store='BOOST_TESTS')