Replace boost::filesystem with std::filesystem across codebase

Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/ec2fa57d-2d9c-4388-b4e1-90a40f55b5e8

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-24 13:47:08 +00:00
committed by GitHub
parent 3f307f8128
commit 9fe94c47c3
34 changed files with 239 additions and 244 deletions

View File

@@ -15,14 +15,10 @@
#include <xrpl/protocol/ErrorCodes.h>
#include <xrpl/protocol/jss.h>
#include <boost/filesystem/file_status.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/system/detail/error_code.hpp>
#include <algorithm>
#include <chrono>
#include <cstdint>
#include <filesystem>
#include <fstream>
#include <ios>
#include <iterator>
@@ -31,6 +27,7 @@
#include <ostream>
#include <random>
#include <string>
#include <system_error>
#include <thread>
#include <utility>
#include <vector>
@@ -43,7 +40,7 @@ class PerfLog_test : public beast::unit_test::suite
{
enum class WithFile : bool { no = false, yes = true };
using path = boost::filesystem::path;
using path = std::filesystem::path;
// We're only using Env for its Journal. That Journal gives better
// coverage in unit tests.
@@ -62,7 +59,7 @@ class PerfLog_test : public beast::unit_test::suite
~Fixture()
{
using namespace boost::filesystem;
using namespace std::filesystem;
auto const dir{logDir()};
auto const file{logFile()};
@@ -85,7 +82,7 @@ class PerfLog_test : public beast::unit_test::suite
static path
logDir()
{
using namespace boost::filesystem;
using namespace std::filesystem;
return temp_directory_path() / "perf_log_test_dir";
}
@@ -118,7 +115,7 @@ class PerfLog_test : public beast::unit_test::suite
static void
wait()
{
using namespace boost::filesystem;
using namespace std::filesystem;
auto const path = logFile();
if (!exists(path))
@@ -190,7 +187,7 @@ public:
void
testFileCreation()
{
using namespace boost::filesystem;
using namespace std::filesystem;
{
// Verify a PerfLog creates its file when constructed.
@@ -245,22 +242,23 @@ public:
// Construct and write protect a file to prevent PerfLog
// from creating its file.
boost::system::error_code ec;
boost::filesystem::create_directories(fixture.logDir(), ec);
std::error_code ec;
std::filesystem::create_directories(fixture.logDir(), ec);
if (!BEAST_EXPECT(!ec))
return;
auto fileWriteable = [](boost::filesystem::path const& p) -> bool {
auto fileWriteable = [](std::filesystem::path const& p) -> bool {
return std::ofstream{p.c_str(), std::ios::out | std::ios::app}.is_open();
};
if (!BEAST_EXPECT(fileWriteable(fixture.logFile())))
return;
boost::filesystem::permissions(
std::filesystem::permissions(
fixture.logFile(),
perms::remove_perms | perms::owner_write | perms::others_write |
perms::group_write);
std::filesystem::perms::owner_write | std::filesystem::perms::others_write |
std::filesystem::perms::group_write,
std::filesystem::perm_options::remove);
// If the test is running as root, then the write protect may have
// no effect. Make sure write protect worked before proceeding.
@@ -284,9 +282,11 @@ public:
perfLog->stop();
// Fix file permissions so the file can be cleaned up.
boost::filesystem::permissions(
std::filesystem::permissions(
fixture.logFile(),
perms::add_perms | perms::owner_write | perms::others_write | perms::group_write);
std::filesystem::perms::owner_write | std::filesystem::perms::others_write |
std::filesystem::perms::group_write,
std::filesystem::perm_options::add);
}
}
@@ -951,7 +951,7 @@ public:
// We can't fully test rotate because unit tests must run on Windows,
// and Windows doesn't (may not?) support rotate. But at least call
// the interface and see that it doesn't crash.
using namespace boost::filesystem;
using namespace std::filesystem;
Fixture fixture{env_.app(), j_};
BEAST_EXPECT(!exists(fixture.logDir()));