Skip to content

Commit cde062e

Browse files
committed
Switch to std::filesystem
Change-Id: I61a4b4562b3c7fabefb07dced580d2b20d7b6d78
1 parent 85bde92 commit cde062e

File tree

6 files changed

+24
-28
lines changed

6 files changed

+24
-28
lines changed

.jenkins.d/00-deps.sh

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ APT_PKGS=(
77
libboost-chrono-dev
88
libboost-date-time-dev
99
libboost-dev
10-
libboost-filesystem-dev
1110
libboost-log-dev
1211
libboost-program-options-dev
1312
libboost-stacktrace-dev

.waf-tools/default-compiler-flags.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def getDebugFlags(self, conf):
136136
return {
137137
'CXXFLAGS': [],
138138
'LINKFLAGS': [],
139-
'DEFINES': ['BOOST_ASIO_NO_DEPRECATED', 'BOOST_FILESYSTEM_NO_DEPRECATED'],
139+
'DEFINES': ['BOOST_ASIO_NO_DEPRECATED'],
140140
}
141141

142142
def getOptimizedFlags(self, conf):

src/detail/ca-sqlite.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
#include <ndn-cxx/security/validation-policy.hpp>
2626
#include <ndn-cxx/util/sqlite3-statement.hpp>
2727

28-
#include <boost/filesystem/operations.hpp>
29-
#include <boost/filesystem/path.hpp>
3028
#include <boost/property_tree/json_parser.hpp>
3129

30+
#include <filesystem>
31+
3232
namespace ndncert::ca {
3333

3434
using ndn::util::Sqlite3Statement;
@@ -80,21 +80,21 @@ CaSqlite::CaSqlite(const Name& caName, const std::string& path)
8080
: CaStorage()
8181
{
8282
// Determine the path of sqlite db
83-
boost::filesystem::path dbDir;
83+
std::filesystem::path dbDir;
8484
if (!path.empty()) {
85-
dbDir = boost::filesystem::path(path);
85+
dbDir = std::filesystem::path(path);
8686
}
8787
else {
8888
std::string dbName = caName.toUri();
8989
std::replace(dbName.begin(), dbName.end(), '/', '_');
9090
dbName += ".db";
9191
if (getenv("HOME") != nullptr) {
92-
dbDir = boost::filesystem::path(getenv("HOME")) / ".ndncert";
92+
dbDir = std::filesystem::path(getenv("HOME")) / ".ndncert";
9393
}
9494
else {
95-
dbDir = boost::filesystem::current_path() / ".ndncert";
95+
dbDir = std::filesystem::current_path() / ".ndncert";
9696
}
97-
boost::filesystem::create_directories(dbDir);
97+
std::filesystem::create_directories(dbDir);
9898
dbDir /= dbName;
9999
}
100100

tests/global-configuration.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@
2222

2323
#include <ndn-cxx/util/exception.hpp>
2424

25-
#include <boost/filesystem/operations.hpp>
26-
#include <boost/filesystem/path.hpp>
27-
25+
#include <filesystem>
2826
#include <stdexcept>
2927
#include <stdlib.h>
28+
#include <system_error>
3029

3130
namespace ndncert::tests {
3231

@@ -40,10 +39,10 @@ class GlobalConfiguration
4039
m_home.assign(envHome);
4140

4241
// in case an earlier test run crashed without a chance to run the destructor
43-
boost::filesystem::remove_all(TESTDIR);
42+
std::filesystem::remove_all(TESTDIR);
4443

4544
auto testHome = TESTDIR / "test-home";
46-
boost::filesystem::create_directories(testHome);
45+
std::filesystem::create_directories(testHome);
4746

4847
if (::setenv("HOME", testHome.c_str(), 1) != 0)
4948
NDN_THROW(std::runtime_error("setenv() failed"));
@@ -56,12 +55,12 @@ class GlobalConfiguration
5655
else
5756
::setenv("HOME", m_home.data(), 1);
5857

59-
boost::system::error_code ec;
60-
boost::filesystem::remove_all(TESTDIR, ec); // ignore error
58+
std::error_code ec;
59+
std::filesystem::remove_all(TESTDIR, ec); // ignore error
6160
}
6261

6362
private:
64-
static inline const boost::filesystem::path TESTDIR{UNIT_TESTS_TMPDIR};
63+
static inline const std::filesystem::path TESTDIR{UNIT_TESTS_TMPDIR};
6564
std::string m_home;
6665
};
6766

tests/unit-tests/ca-sqlite.t.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22
/*
3-
* Copyright (c) 2017-2022, Regents of the University of California.
3+
* Copyright (c) 2017-2024, Regents of the University of California.
44
*
55
* This file is part of ndncert, a certificate management system based on NDN.
66
*
@@ -23,8 +23,8 @@
2323
#include "tests/boost-test.hpp"
2424
#include "tests/key-chain-fixture.hpp"
2525

26-
#include <boost/filesystem/operations.hpp>
27-
#include <boost/filesystem/path.hpp>
26+
#include <filesystem>
27+
#include <system_error>
2828

2929
namespace ndncert::tests {
3030

@@ -34,21 +34,19 @@ class DatabaseFixture : public KeyChainFixture
3434
{
3535
public:
3636
DatabaseFixture()
37+
: dbDir(std::filesystem::path{UNIT_TESTS_TMPDIR} / "test-home" / ".ndncert")
3738
{
38-
boost::filesystem::path parentDir{UNIT_TESTS_TMPDIR};
39-
dbDir = parentDir / "test-home" / ".ndncert";
40-
if (!boost::filesystem::exists(dbDir)) {
41-
boost::filesystem::create_directory(dbDir);
42-
}
39+
std::filesystem::create_directory(dbDir);
4340
}
4441

4542
~DatabaseFixture()
4643
{
47-
boost::filesystem::remove_all(dbDir);
44+
std::error_code ec;
45+
std::filesystem::remove_all(dbDir, ec); // ignore error
4846
}
4947

5048
protected:
51-
boost::filesystem::path dbDir;
49+
std::filesystem::path dbDir;
5250
};
5351

5452
BOOST_FIXTURE_TEST_SUITE(TestCaSqlite, DatabaseFixture)

wscript

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def configure(conf):
3939
conf.check_sqlite3()
4040
conf.check_openssl(lib='crypto', atleast_version='1.1.1')
4141

42-
conf.check_boost(lib='filesystem', mt=True)
42+
conf.check_boost()
4343
if conf.env.BOOST_VERSION_NUMBER < 107100:
4444
conf.fatal('The minimum supported version of Boost is 1.71.0.\n'
4545
'Please upgrade your distribution or manually install a newer version of Boost.\n'

0 commit comments

Comments
 (0)