Switch to std::filesystem
Change-Id: I61a4b4562b3c7fabefb07dced580d2b20d7b6d78
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)