Compare commits

...

27 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
f956135e29 Merge remote-tracking branch 'origin/develop' into copilot/refactor-replace-boost-filesystem
# Conflicts:
#	src/test/app/GRPCServerTLS_test.cpp
#	src/test/app/SHAMapStore_test.cpp
#	src/xrpld/app/misc/SHAMapStoreImp.cpp
#	src/xrpld/app/rdb/backend/detail/Node.cpp
#	src/xrpld/core/detail/Config.cpp
2026-06-11 12:28:23 +00:00
copilot-swe-agent[bot]
3e4422df28 Merge remote-tracking branch 'origin/develop' into copilot/refactor-replace-boost-filesystem
# Conflicts:
#	src/xrpld/core/Config.h
#	src/xrpld/core/detail/Config.cpp
2026-05-27 20:55:29 +00:00
copilot-swe-agent[bot]
9f5bf51b31 Merge branch 'develop' of https://github.com/XRPLF/rippled into copilot/refactor-replace-boost-filesystem
# Conflicts:
#	src/libxrpl/server/Vacuum.cpp
#	src/test/app/GRPCServerTLS_test.cpp
#	src/xrpld/app/rdb/backend/detail/Node.cpp
#	src/xrpld/core/detail/Config.cpp

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-05-15 17:38:01 +00:00
copilot-swe-agent[bot]
9ccb7742ca fix: Use std::filesystem::absolute(base/p) to match boost::filesystem::absolute(p,base) behavior
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/41d17280-3340-4246-97d4-06f2bcf365cb

Co-authored-by: mathbunnyru <12270691+mathbunnyru@users.noreply.github.com>
2026-05-07 09:42:04 +00:00
copilot-swe-agent[bot]
336b9c101e refactor: use beast::uniqueRandomPath in SHAMapStoreImp makeBackendRotating
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/3807ab03-d6e1-4466-a2b9-b7512b943bba

Co-authored-by: mathbunnyru <12270691+mathbunnyru@users.noreply.github.com>
2026-05-07 09:31:41 +00:00
Ayaz Salikhov
5fdbedf6ac Merge branch 'develop' into copilot/refactor-replace-boost-filesystem 2026-05-07 10:17:31 +01:00
copilot-swe-agent[bot]
ce4490d793 Merge origin/develop: resolve conflicts (keep std::filesystem, add IWYU pragmas)
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/56410194-a137-4a12-ad17-fc4fffb31d86

Co-authored-by: mathbunnyru <12270691+mathbunnyru@users.noreply.github.com>
2026-05-07 08:55:53 +00:00
copilot-swe-agent[bot]
ba2ff93d6e style: fix clang-format in temp_dir.h (collapse throw statement to one line)
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/8ef69f5f-e752-47b2-a4a3-2746d0dbfe78

Co-authored-by: mathbunnyru <12270691+mathbunnyru@users.noreply.github.com>
2026-05-06 10:21:10 +00:00
copilot-swe-agent[bot]
4714160052 refactor: add prefix param to uniqueRandomPath, use in GRPCServerTLS_test
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/a8d8f682-0faf-4cb5-a330-39dc6fb7408f

Co-authored-by: mathbunnyru <12270691+mathbunnyru@users.noreply.github.com>
2026-05-06 10:04:14 +00:00
Ayaz Salikhov
5147825d61 Merge branch 'develop' into copilot/refactor-replace-boost-filesystem 2026-05-06 10:54:52 +01:00
copilot-swe-agent[bot]
719368ae25 fix: Apply pre-commit and clang-tidy fixes (formatting, braces, naming)
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/a872065b-cdb8-47a7-8acb-3ece056594ca

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-05-04 17:20:36 +00:00
copilot-swe-agent[bot]
3e372656d3 Fix comment in temp_dir.h
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-05-04 16:17:43 +00:00
copilot-swe-agent[bot]
81964068a1 Merge origin/develop: resolve conflicts, keep std::filesystem with develop naming
Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-05-04 16:17:01 +00:00
Ayaz Salikhov
2e0ea38d7d Apply suggestion from @Copilot
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-27 21:14:31 +01:00
Mayukha Vadari
aa1f84e226 fix clang-tidy issues 2026-04-25 12:36:43 -04:00
copilot-swe-agent[bot]
ae7076c054 Address second round of review feedback: non-throwing exists(), direct path streams, errno propagation
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/ebfae1ee-800f-4a23-b484-a709c2321693

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-04-24 21:16:42 +00:00
copilot-swe-agent[bot]
9a221d1291 Address code review feedback: retry loop, comment cleanup, error code improvements
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/629eace2-9c23-40d9-89f5-9ef3099cdf14

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-04-24 18:42:23 +00:00
copilot-swe-agent[bot]
5e6d8a4692 Merge remote-tracking branch 'origin/develop' into copilot/refactor-replace-boost-filesystem
# Conflicts:
#	src/xrpld/core/Config.h

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-04-24 17:59:58 +00:00
Mayukha Vadari
11c7d912f6 fix build 2026-04-24 12:54:09 -04:00
Mayukha Vadari
b7d6cdf713 fix clang-tidy issues 2026-04-24 12:49:36 -04:00
copilot-swe-agent[bot]
193ddcbfac Fix pre-commit and clang-tidy issues using tools
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/e5845adb-dc3f-46cf-8461-0ea7855be1cf

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-04-24 15:38:40 +00:00
copilot-swe-agent[bot]
3a70d9dfba Fix build error and pre-commit include ordering issues
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/e53fe2d3-e57e-4ad9-9d43-5dc1519645fc

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-04-24 14:13:56 +00:00
Mayukha Vadari
03e8a68670 Merge branch 'develop' into copilot/refactor-replace-boost-filesystem 2026-04-24 09:54:16 -04:00
copilot-swe-agent[bot]
28143d74af Increase entropy in SHAMapStoreImp.cpp unique path generation
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/ec2fa57d-2d9c-4388-b4e1-90a40f55b5e8

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-04-24 13:52:06 +00:00
copilot-swe-agent[bot]
ff4c538a9f Address code review: improve random path generation and fix includes
Agent-Logs-Url: https://github.com/XRPLF/rippled/sessions/ec2fa57d-2d9c-4388-b4e1-90a40f55b5e8

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
2026-04-24 13:50:38 +00:00
copilot-swe-agent[bot]
9fe94c47c3 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>
2026-04-24 13:47:08 +00:00
copilot-swe-agent[bot]
3f307f8128 Initial plan 2026-04-24 13:24:30 +00:00
34 changed files with 261 additions and 261 deletions

View File

@@ -1,6 +1,6 @@
#pragma once
#include <boost/filesystem.hpp>
#include <filesystem>
namespace xrpl {
@@ -12,6 +12,6 @@ namespace xrpl {
@throws runtime_error
*/
void
extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const& dst);
extractTarLz4(std::filesystem::path const& src, std::filesystem::path const& dst);
} // namespace xrpl

View File

@@ -1,22 +1,22 @@
#pragma once
#include <boost/filesystem.hpp>
#include <boost/system/error_code.hpp>
#include <filesystem>
#include <optional>
#include <string>
#include <system_error>
namespace xrpl {
std::string
getFileContents(
boost::system::error_code& ec,
boost::filesystem::path const& sourcePath,
std::error_code& ec,
std::filesystem::path const& sourcePath,
std::optional<std::size_t> maxSize = std::nullopt);
void
writeFileContents(
boost::system::error_code& ec,
boost::filesystem::path const& destPath,
std::error_code& ec,
std::filesystem::path const& destPath,
std::string const& contents);
} // namespace xrpl

View File

@@ -4,8 +4,8 @@
#include <xrpl/beast/utility/Journal.h>
#include <boost/beast/core/string.hpp>
#include <boost/filesystem.hpp>
#include <filesystem>
#include <fstream>
#include <map>
#include <memory>
@@ -76,7 +76,7 @@ private:
@return `true` if the file was opened.
*/
bool
open(boost::filesystem::path const& path);
open(std::filesystem::path const& path);
/** Close and re-open the system file associated with the log
This assists in interoperating with external log management tools.
@@ -118,7 +118,7 @@ private:
private:
std::unique_ptr<std::ofstream> stream_;
boost::filesystem::path path_;
std::filesystem::path path_;
};
std::mutex mutable mutex_;
@@ -137,7 +137,7 @@ public:
virtual ~Logs() = default;
bool
open(boost::filesystem::path const& pathToLogFile);
open(std::filesystem::path const& pathToLogFile);
beast::Journal::Sink&
get(std::string const& name);

View File

@@ -6,10 +6,10 @@
#include <xrpl/beast/unit_test/runner.h>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/throw_exception.hpp>
#include <filesystem>
#include <ostream>
#include <sstream>
#include <string>
@@ -25,7 +25,7 @@ makeReason(String const& reason, char const* file, int line)
std::string s(reason);
if (!s.empty())
s.append(": ");
namespace fs = boost::filesystem;
namespace fs = std::filesystem;
s.append(fs::path{file}.filename().string());
s.append("(");
s.append(boost::lexical_cast<std::string>(line));

View File

@@ -1,19 +1,56 @@
#pragma once
#include <boost/filesystem.hpp>
#include <filesystem>
#include <iomanip>
#include <random>
#include <sstream>
#include <stdexcept>
#include <string>
#include <system_error>
namespace beast {
/** Generate a unique, non-existing path under @p base with an optional @p prefix
and a random hex suffix.
Attempts up to @p maxAttempts paths. Throws `std::runtime_error` if a
unique path cannot be found or if the filesystem returns an error while
checking for existence.
*/
inline std::filesystem::path
uniqueRandomPath(
std::filesystem::path const& base,
std::size_t maxAttempts = 100,
std::string const& prefix = "")
{
std::random_device rd;
for (std::size_t attempt = 0; attempt < maxAttempts; ++attempt)
{
std::ostringstream oss;
oss << prefix << std::hex << std::setfill('0') << std::setw(8) << rd() << std::setw(8)
<< rd();
auto candidate = base / oss.str();
std::error_code ec;
bool const exists = std::filesystem::exists(candidate, ec);
if (ec)
{
throw std::runtime_error(
"Unable to check path '" + candidate.string() + "': " + ec.message());
}
if (!exists)
return candidate;
}
throw std::runtime_error("Unable to generate a unique path under '" + base.string() + "'");
}
/** RAII temporary directory.
The directory and all its contents are deleted when
the instance of `temp_dir` is destroyed.
the instance of `TempDir` is destroyed.
*/
class TempDir
{
boost::filesystem::path path_;
std::filesystem::path path_;
public:
#if !GENERATING_DOCS
@@ -25,20 +62,16 @@ public:
/// Construct a temporary directory.
TempDir()
{
auto const dir = boost::filesystem::temp_directory_path();
do
{
path_ = dir / boost::filesystem::unique_path();
} while (boost::filesystem::exists(path_));
boost::filesystem::create_directory(path_);
path_ = uniqueRandomPath(std::filesystem::temp_directory_path());
std::filesystem::create_directory(path_);
}
/// Destroy a temporary directory.
~TempDir()
{
// use non-throwing calls in the destructor
boost::system::error_code ec;
boost::filesystem::remove_all(path_, ec);
std::error_code ec;
std::filesystem::remove_all(path_, ec);
// TODO: warn/notify if ec set ?
}

View File

@@ -3,10 +3,9 @@
#include <xrpl/core/JobTypes.h>
#include <xrpl/json/json_value.h>
#include <boost/filesystem.hpp>
#include <chrono>
#include <cstdint>
#include <filesystem>
#include <functional>
#include <memory>
#include <string>
@@ -43,7 +42,7 @@ public:
*/
struct Setup
{
boost::filesystem::path perfLog;
std::filesystem::path perfLog;
// log_interval is in milliseconds to support faster testing.
milliseconds logInterval{seconds(1)};
};
@@ -148,7 +147,7 @@ public:
};
PerfLog::Setup
setupPerfLog(Section const& section, boost::filesystem::path const& configDir);
setupPerfLog(Section const& section, std::filesystem::path const& configDir);
std::unique_ptr<PerfLog>
makePerfLog(

View File

@@ -6,8 +6,7 @@
#include <xrpl/rdb/DBInit.h>
#include <xrpl/rdb/SociDB.h>
#include <boost/filesystem/path.hpp>
#include <filesystem>
#include <mutex>
#include <optional>
#include <string>
@@ -72,7 +71,7 @@ public:
StartUpType startUp = StartUpType::Normal;
bool standAlone = false;
boost::filesystem::path dataDir;
std::filesystem::path dataDir;
// Indicates whether or not to return the `globalPragma`
// from commonPragma()
bool useGlobalPragma = false;
@@ -135,7 +134,7 @@ public:
template <std::size_t N, std::size_t M>
DatabaseCon(
boost::filesystem::path const& dataDir,
std::filesystem::path const& dataDir,
std::string const& dbName,
std::array<std::string, N> const& pragma,
std::array<char const*, M> const& initSQL,
@@ -147,7 +146,7 @@ public:
// Use this constructor to setup checkpointing
template <std::size_t N, std::size_t M>
DatabaseCon(
boost::filesystem::path const& dataDir,
std::filesystem::path const& dataDir,
std::string const& dbName,
std::array<std::string, N> const& pragma,
std::array<char const*, M> const& initSQL,
@@ -182,7 +181,7 @@ private:
template <std::size_t N, std::size_t M>
DatabaseCon(
boost::filesystem::path const& pPath,
std::filesystem::path const& pPath,
std::vector<std::string> const* commonPragma,
std::array<std::string, N> const& pragma,
std::array<char const*, M> const& initSQL,

View File

@@ -10,7 +10,6 @@
#include <xrpl/protocol/TxSearched.h>
#include <xrpl/rdb/DatabaseCon.h>
#include <boost/filesystem.hpp>
#include <boost/variant.hpp>
namespace xrpl {

View File

@@ -4,8 +4,6 @@
#include <xrpl/rdb/DatabaseCon.h>
#include <xrpl/server/Manifest.h>
#include <boost/filesystem.hpp>
namespace xrpl {
struct SavedState

View File

@@ -2,22 +2,20 @@
#include <xrpl/basics/contract.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <archive.h>
#include <archive_entry.h>
#include <cstddef>
#include <filesystem>
#include <memory>
#include <stdexcept>
namespace xrpl {
void
extractTarLz4(boost::filesystem::path const& src, boost::filesystem::path const& dst)
extractTarLz4(std::filesystem::path const& src, std::filesystem::path const& dst)
{
if (!is_regular_file(src))
if (!std::filesystem::is_regular_file(src))
Throw<std::runtime_error>("Invalid source file");
using archive_ptr = std::unique_ptr<struct archive, void (*)(struct archive*)>;

View File

@@ -1,29 +1,24 @@
#include <xrpl/basics/FileUtilities.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/system/detail/errc.hpp>
#include <boost/system/detail/error_code.hpp>
#include <boost/system/errc.hpp>
#include <cerrno>
#include <cstddef>
#include <filesystem>
#include <fstream>
#include <ios>
#include <iterator>
#include <optional>
#include <string>
#include <system_error>
namespace xrpl {
std::string
getFileContents(
boost::system::error_code& ec,
boost::filesystem::path const& sourcePath,
std::error_code& ec,
std::filesystem::path const& sourcePath,
std::optional<std::size_t> maxSize)
{
using namespace boost::filesystem;
using namespace boost::system::errc;
using namespace std::filesystem;
path const fullPath{canonical(sourcePath, ec)};
if (ec)
@@ -32,15 +27,15 @@ getFileContents(
if (maxSize && (file_size(fullPath, ec) > *maxSize || ec))
{
if (!ec)
ec = make_error_code(file_too_large);
ec = make_error_code(std::errc::file_too_large);
return {};
}
std::ifstream fileStream(fullPath.string(), std::ios::in);
std::ifstream fileStream(fullPath, std::ios::in);
if (!fileStream)
{
ec = make_error_code(static_cast<errc_t>(errno));
ec.assign(errno, std::generic_category());
return {};
}
@@ -49,7 +44,7 @@ getFileContents(
if (fileStream.bad())
{
ec = make_error_code(static_cast<errc_t>(errno));
ec.assign(errno, std::generic_category());
return {};
}
@@ -58,18 +53,15 @@ getFileContents(
void
writeFileContents(
boost::system::error_code& ec,
boost::filesystem::path const& destPath,
std::error_code& ec,
std::filesystem::path const& destPath,
std::string const& contents)
{
using namespace boost::filesystem;
using namespace boost::system::errc;
std::ofstream fileStream(destPath.string(), std::ios::out | std::ios::trunc);
std::ofstream fileStream(destPath, std::ios::out | std::ios::trunc);
if (!fileStream)
{
ec = make_error_code(static_cast<errc_t>(errno));
ec.assign(errno, std::generic_category());
return;
}
@@ -77,7 +69,7 @@ writeFileContents(
if (fileStream.bad())
{
ec = make_error_code(static_cast<errc_t>(errno));
ec.assign(errno, std::generic_category());
return;
}
}

View File

@@ -5,10 +5,10 @@
#include <xrpl/beast/utility/instrumentation.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem/path.hpp>
#include <chrono>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <functional>
#include <iostream>
@@ -54,7 +54,7 @@ Logs::File::isOpen() const noexcept
}
bool
Logs::File::open(boost::filesystem::path const& path)
Logs::File::open(std::filesystem::path const& path)
{
close();
@@ -114,7 +114,7 @@ Logs::Logs(beast::Severity thresh) : thresh_(thresh) // default severity
}
bool
Logs::open(boost::filesystem::path const& pathToLogFile)
Logs::open(std::filesystem::path const& pathToLogFile)
{
return file_.open(pathToLogFile);
}

View File

@@ -16,8 +16,6 @@
#include <xrpl/nodestore/detail/EncodedBlob.h>
#include <xrpl/nodestore/detail/codec.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/system/detail/errc.hpp>
#include <nudb/context.hpp>
@@ -36,12 +34,14 @@
#include <cstdint>
#include <cstdio>
#include <exception>
#include <filesystem>
#include <functional>
#include <memory>
#include <optional>
#include <sstream>
#include <stdexcept>
#include <string>
#include <system_error>
#include <utility>
namespace xrpl::NodeStore {
@@ -131,7 +131,7 @@ public:
void
open(bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt) override
{
using namespace boost::filesystem;
using namespace std::filesystem;
if (db.is_open())
{
// LCOV_EXCL_START
@@ -194,11 +194,12 @@ public:
if (deletePath)
{
boost::filesystem::remove_all(name, ec);
if (ec)
std::error_code fsec;
std::filesystem::remove_all(name, fsec);
if (fsec)
{
JLOG(j.fatal())
<< "Filesystem remove_all of " << name << " failed with: " << ec.message();
JLOG(j.fatal()) << "Filesystem remove_all of " << name
<< " failed with: " << fsec.message();
}
}
}
@@ -352,7 +353,7 @@ private:
static std::size_t
parseBlockSize(std::string const& name, Section const& keyValues, beast::Journal journal)
{
using namespace boost::filesystem;
using namespace std::filesystem;
auto const folder = path(name);
auto const kp = (folder / "nudb.key").string();

View File

@@ -9,9 +9,6 @@
#include <xrpl/nodestore/Scheduler.h>
#include <xrpl/nodestore/Types.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <rocksdb/advanced_options.h>
#include <rocksdb/cache.h>
#include <rocksdb/compression_type.h>
@@ -27,6 +24,7 @@
#include <bit>
#include <cstddef>
#include <filesystem>
#include <functional>
#include <stdexcept>
#include <string>
@@ -265,8 +263,8 @@ public:
db.reset();
if (deletePath_)
{
boost::filesystem::path const dir = name;
boost::filesystem::remove_all(dir);
std::filesystem::path const dir = name;
std::filesystem::remove_all(dir);
}
}
}

View File

@@ -5,13 +5,11 @@
#include <xrpl/core/JobQueue.h>
#include <xrpl/core/ServiceRegistry.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <soci/blob.h>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <mutex>
#include <stdexcept>
#include <string>
@@ -45,8 +43,8 @@ getSociSqliteInit(std::string const& name, std::string const& dir, std::string c
Throw<std::runtime_error>(
"Sqlite databases must specify a dir and a name. Name: " + name + " Dir: " + dir);
}
boost::filesystem::path file(dir);
if (is_directory(file))
std::filesystem::path file(dir);
if (std::filesystem::is_directory(file))
file /= name + ext;
return file.string();
}

View File

@@ -5,13 +5,12 @@
#include <xrpl/rdb/DBInit.h>
#include <xrpl/rdb/DatabaseCon.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/format.hpp> // IWYU pragma: keep
#include <soci/into.h>
#include <cstdint>
#include <filesystem>
#include <iostream>
#include <memory>
@@ -20,12 +19,12 @@ namespace xrpl {
bool
doVacuumDB(DatabaseCon::Setup const& setup, beast::Journal j)
{
boost::filesystem::path const dbPath = setup.dataDir / kTxDbName;
std::filesystem::path const dbPath = setup.dataDir / kTxDbName;
uintmax_t const dbSize = file_size(dbPath);
uintmax_t const dbSize = std::filesystem::file_size(dbPath);
XRPL_ASSERT(dbSize != static_cast<uintmax_t>(-1), "xrpl::doVacuumDB : file_size succeeded");
if (auto available = space(dbPath.parent_path()).available; available < dbSize)
if (auto available = std::filesystem::space(dbPath.parent_path()).available; available < dbSize)
{
std::cerr << "The database filesystem must have at least as "
"much free space as the size of "

View File

@@ -2,12 +2,11 @@
#include <test/jtx/envconfig.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/beast/utility/temp_dir.h>
#include <xrpl/config/Constants.h>
#include <xrpl/proto/org/xrpl/rpc/v1/get_ledger.pb.h>
#include <xrpl/proto/org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h>
#include <boost/filesystem/operations.hpp>
#include <grpcpp/client_context.h>
#include <grpcpp/create_channel.h>
#include <grpcpp/grpcpp.h>
@@ -17,6 +16,7 @@
#include <chrono>
#include <filesystem>
#include <fstream>
#include <ios>
#include <memory>
#include <stdexcept>
#include <string>
@@ -254,10 +254,8 @@ public:
TemporaryTLSCertificates()
{
auto tmpDir = std::filesystem::temp_directory_path();
auto uniqueDirName =
boost::filesystem::unique_path(std::string(kCertsDirPrefix) + "%%%%%%%%");
tempDir_ = tmpDir / uniqueDirName.string();
tempDir_ = beast::uniqueRandomPath(
std::filesystem::temp_directory_path(), 100, std::string(kCertsDirPrefix));
std::filesystem::create_directories(tempDir_);
writeFile(tempDir_ / kCaCertFilename, kCaCertContent);

View File

@@ -18,16 +18,16 @@
#include <xrpl/protocol/jss.h>
#include <boost/algorithm/string/erase.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/system/detail/error_code.hpp>
#include <cassert>
#include <filesystem>
#include <fstream>
#include <ios>
#include <memory>
#include <optional>
#include <stdexcept>
#include <string>
#include <system_error>
namespace xrpl {
@@ -139,7 +139,7 @@ class LedgerLoad_test : public beast::unit_test::Suite
{
testcase("Load ledger: Bad Files");
using namespace test::jtx;
using namespace boost::filesystem;
using namespace std::filesystem;
// empty path
except([&] {
@@ -161,8 +161,8 @@ class LedgerLoad_test : public beast::unit_test::Suite
});
// make a corrupted version of the ledger file (last 10 bytes removed).
boost::system::error_code ec;
auto ledgerFileCorrupt = boost::filesystem::path{sd.dbPath} / "ledgerdata_bad.json";
std::error_code ec;
auto ledgerFileCorrupt = std::filesystem::path{sd.dbPath} / "ledgerdata_bad.json";
copy_file(sd.ledgerFile, ledgerFileCorrupt, copy_options::overwrite_existing, ec);
if (!BEAST_EXPECTS(!ec, ec.message()))
return;

View File

@@ -22,14 +22,12 @@
#include <xrpl/server/Manifest.h>
#include <xrpl/server/Wallet.h>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <algorithm>
#include <array>
#include <cassert>
#include <cstdint>
#include <exception>
#include <filesystem>
#include <limits>
#include <memory>
#include <optional>
@@ -56,18 +54,18 @@ private:
}
static void
cleanupDatabaseDir(boost::filesystem::path const& dbPath)
cleanupDatabaseDir(std::filesystem::path const& dbPath)
{
using namespace boost::filesystem;
using namespace std::filesystem;
if (!exists(dbPath) || !is_directory(dbPath) || !is_empty(dbPath))
return;
remove(dbPath);
}
static void
setupDatabaseDir(boost::filesystem::path const& dbPath)
setupDatabaseDir(std::filesystem::path const& dbPath)
{
using namespace boost::filesystem;
using namespace std::filesystem;
if (!exists(dbPath))
{
create_directory(dbPath);
@@ -80,10 +78,10 @@ private:
Throw<std::runtime_error>("Cannot create directory: " + dbPath.string());
}
}
static boost::filesystem::path
static std::filesystem::path
getDatabasePath()
{
return boost::filesystem::current_path() / "manifest_test_databases";
return std::filesystem::current_path() / "manifest_test_databases";
}
public:
@@ -352,7 +350,7 @@ public:
BEAST_EXPECT(loaded.revoked(pk));
}
}
boost::filesystem::remove(getDatabasePath() / boost::filesystem::path(dbName));
std::filesystem::remove(getDatabasePath() / std::filesystem::path(dbName));
}
void

View File

@@ -22,10 +22,9 @@
#include <xrpl/protocol/XRPAmount.h>
#include <xrpl/protocol/jss.h>
#include <boost/filesystem/path.hpp>
#include <atomic>
#include <cstdint>
#include <filesystem>
#include <limits>
#include <map>
#include <memory>
@@ -492,7 +491,7 @@ public:
makeBackendRotating(jtx::Env& env, NodeStoreScheduler& scheduler, std::string path)
{
Section section{env.app().config().section(Sections::kNodeDatabase)};
boost::filesystem::path newPath;
std::filesystem::path newPath;
if (!BEAST_EXPECT(path.size()))
return {};

View File

@@ -15,13 +15,12 @@
#include <xrpl/protocol/jss.h>
#include <boost/algorithm/string/join.hpp>
#include <boost/filesystem/directory.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <date/date.h>
#include <chrono>
#include <filesystem>
#include <fstream>
#include <memory>
#include <ostream>
@@ -704,7 +703,7 @@ public:
.effectiveOverlap = detail::kDefaultEffectiveOverlap,
.expectedRefreshMin = 60 * 24}}); // max of 24 hours
}
using namespace boost::filesystem;
using namespace std::filesystem;
for (auto const& file : directory_iterator(good.subdir()))
{
remove_all(file);

View File

@@ -4,8 +4,7 @@
#include <xrpl/basics/FileUtilities.h>
#include <xrpl/beast/unit_test/suite.h>
#include <boost/system/detail/errc.hpp>
#include <boost/system/detail/error_code.hpp>
#include <system_error>
namespace xrpl {
@@ -16,7 +15,6 @@ public:
testGetFileContents()
{
using namespace xrpl::detail;
using namespace boost::system;
static constexpr char const* kExpectedContents =
"This file is very short. That's all we need.";
@@ -24,7 +22,7 @@ public:
FileDirGuard const file(
*this, "test_file", "test.txt", "This is temporary text that should get overwritten");
error_code ec;
std::error_code ec;
auto const path = file.file();
writeFileContents(ec, path, kExpectedContents);
@@ -47,7 +45,7 @@ public:
{
// Test with small max
auto const bad = getFileContents(ec, path, 16);
BEAST_EXPECT(ec && ec.value() == boost::system::errc::file_too_large);
BEAST_EXPECT(ec && ec == std::errc::file_too_large);
BEAST_EXPECT(bad.empty());
}
}

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.
@@ -66,14 +63,14 @@ class PerfLog_test : public beast::unit_test::Suite
// The error code is intentionally ignored: if the path doesn't
// exist (the common case on a clean runner) remove_all returns
// an error, and that's fine — there's nothing to clean up.
using namespace boost::filesystem;
boost::system::error_code ec;
using namespace std::filesystem;
std::error_code ec;
remove_all(logDir(), ec);
}
~Fixture()
{
using namespace boost::filesystem;
using namespace std::filesystem;
auto const dir{logDir()};
auto const file{logFile()};
@@ -96,7 +93,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";
}
@@ -129,7 +126,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))
@@ -201,7 +198,7 @@ public:
void
testFileCreation()
{
using namespace boost::filesystem;
using namespace std::filesystem;
{
// Verify a PerfLog creates its file when constructed.
@@ -256,22 +253,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 {
return std::ofstream{p.c_str(), std::ios::out | std::ios::app}.is_open();
auto fileWriteable = [](std::filesystem::path const& p) -> bool {
return std::ofstream{p, 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.
@@ -295,9 +293,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);
}
}
@@ -962,7 +962,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()));

View File

@@ -10,7 +10,6 @@
#include <xrpl/protocol/SystemParameters.h> // IWYU pragma: keep
#include <xrpl/server/Port.h>
#include <boost/filesystem/operations.hpp>
#include <boost/format.hpp> // IWYU pragma: keep
#include <boost/format/free_funcs.hpp>
#include <boost/lexical_cast/bad_lexical_cast.hpp>
@@ -20,6 +19,7 @@
#include <cstdint>
#include <cstdlib>
#include <exception>
#include <filesystem>
#include <fstream>
#include <optional>
#include <ostream>
@@ -179,7 +179,7 @@ public:
[[nodiscard]] bool
dataDirExists() const
{
return boost::filesystem::is_directory(dataDir_);
return std::filesystem::is_directory(dataDir_);
}
[[nodiscard]] bool
@@ -192,7 +192,7 @@ public:
{
try
{
using namespace boost::filesystem;
using namespace std::filesystem;
if (rmDataDir_)
rmDir(dataDir_);
}
@@ -273,7 +273,7 @@ public:
class Config_test final : public TestSuite
{
private:
using path = boost::filesystem::path;
using path = std::filesystem::path;
public:
void
@@ -309,7 +309,7 @@ port_wss_admin
{
testcase("config_file");
using namespace boost::filesystem;
using namespace std::filesystem;
auto const cwd = current_path();
// Test both config file names.
@@ -425,7 +425,7 @@ port_wss_admin
{
testcase("database_path");
using namespace boost::filesystem;
using namespace std::filesystem;
{
boost::format cc("[database_path]\n%1%\n");
@@ -601,7 +601,7 @@ main
{
testcase("validators_file");
using namespace boost::filesystem;
using namespace std::filesystem;
{
// load should throw for missing specified validators file
boost::format cc("[validators_file]\n%1%\n");

View File

@@ -19,6 +19,7 @@
#include <cstdint>
#include <cstring>
#include <exception>
#include <filesystem>
#include <iterator>
#include <limits>
#include <stdexcept>
@@ -31,7 +32,7 @@ class SociDB_test final : public TestSuite
{
private:
static void
setupSQLiteConfig(BasicConfig& config, boost::filesystem::path const& dbPath)
setupSQLiteConfig(BasicConfig& config, std::filesystem::path const& dbPath)
{
config.overwrite(Sections::kSqdb, Keys::kBackend, "sqlite");
auto value = dbPath.string();
@@ -40,18 +41,18 @@ private:
}
static void
cleanupDatabaseDir(boost::filesystem::path const& dbPath)
cleanupDatabaseDir(std::filesystem::path const& dbPath)
{
using namespace boost::filesystem;
using namespace std::filesystem;
if (!exists(dbPath) || !is_directory(dbPath) || !is_empty(dbPath))
return;
remove(dbPath);
}
static void
setupDatabaseDir(boost::filesystem::path const& dbPath)
setupDatabaseDir(std::filesystem::path const& dbPath)
{
using namespace boost::filesystem;
using namespace std::filesystem;
if (!exists(dbPath))
{
create_directory(dbPath);
@@ -64,10 +65,10 @@ private:
Throw<std::runtime_error>("Cannot create directory: " + dbPath.string());
}
}
static boost::filesystem::path
static std::filesystem::path
getDatabasePath()
{
return boost::filesystem::current_path() / "socidb_test_databases";
return std::filesystem::current_path() / "socidb_test_databases";
}
public:
@@ -157,7 +158,7 @@ public:
checkValues(s);
}
{
namespace bfs = boost::filesystem;
namespace bfs = std::filesystem;
// Remove the database
bfs::path const dbPath(sc.connectionString());
if (bfs::is_regular_file(dbPath))
@@ -287,7 +288,7 @@ public:
#endif
}
{
namespace bfs = boost::filesystem;
namespace bfs = std::filesystem;
// Remove the database
bfs::path const dbPath(sc.connectionString());
if (bfs::is_regular_file(dbPath))
@@ -339,7 +340,7 @@ public:
s << "SELECT LedgerSeq FROM Ledgers;", soci::into(ledgersLS);
BEAST_EXPECT(ledgersLS.size() == numRows);
}
namespace bfs = boost::filesystem;
namespace bfs = std::filesystem;
// Remove the database
bfs::path const dbPath(sc.connectionString());
if (bfs::is_regular_file(dbPath))

View File

@@ -4,8 +4,7 @@
#include <xrpl/basics/contract.h>
#include <boost/filesystem.hpp>
#include <filesystem>
#include <fstream>
namespace xrpl::detail {
@@ -16,7 +15,7 @@ namespace xrpl::detail {
class DirGuard
{
protected:
using path = boost::filesystem::path;
using path = std::filesystem::path;
private:
path subDir_;
@@ -43,7 +42,7 @@ public:
DirGuard(beast::unit_test::Suite& test, path subDir, bool useCounter = true)
: subDir_(std::move(subDir)), test_(test)
{
using namespace boost::filesystem;
using namespace std::filesystem;
static auto kSubDirCounter = 0;
if (useCounter)
@@ -69,7 +68,7 @@ public:
{
try
{
using namespace boost::filesystem;
using namespace std::filesystem;
if (rmSubDir_)
rmDir(subDir_);
@@ -126,7 +125,7 @@ public:
{
try
{
using namespace boost::filesystem;
using namespace std::filesystem;
if (exists(file_))
{
remove(file_);
@@ -156,7 +155,7 @@ public:
[[nodiscard]] bool
fileExists() const
{
return boost::filesystem::exists(file_);
return std::filesystem::exists(file_);
}
};

View File

@@ -48,6 +48,7 @@
#include <sstream>
#include <stdexcept>
#include <string>
#include <system_error>
#include <utility>
#include <vector>
@@ -614,7 +615,7 @@ GRPCServerImpl::createServerCredentials()
try
{
boost::system::error_code ec;
std::error_code ec;
grpc::SslServerCredentialsOptions sslOpts;
grpc::SslServerCredentialsOptions::PemKeyCertPair keyCertPair;

View File

@@ -11,6 +11,7 @@
#include <xrpl/beast/core/CurrentThreadName.h>
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/beast/utility/instrumentation.h>
#include <xrpl/beast/utility/temp_dir.h>
#include <xrpl/config/BasicConfig.h>
#include <xrpl/config/Constants.h>
#include <xrpl/ledger/Ledger.h>
@@ -24,13 +25,12 @@
#include <xrpl/shamap/SHAMapTreeNode.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/filesystem/directory.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <algorithm>
#include <cstdint>
#include <filesystem>
#include <functional>
#include <ios>
#include <limits>
#include <memory>
#include <mutex>
@@ -392,10 +392,10 @@ SHAMapStoreImp::dbPaths()
if (boost::iequals(get(section, Keys::kType), "memory"))
return;
boost::filesystem::path dbPath = get(section, Keys::kPath);
if (boost::filesystem::exists(dbPath))
std::filesystem::path dbPath = get(section, Keys::kPath);
if (std::filesystem::exists(dbPath))
{
if (!boost::filesystem::is_directory(dbPath))
if (!std::filesystem::is_directory(dbPath))
{
journal_.error() << "node db path must be a directory. " << dbPath.string();
Throw<std::runtime_error>("node db path must be a directory.");
@@ -403,7 +403,7 @@ SHAMapStoreImp::dbPaths()
}
else
{
boost::filesystem::create_directories(dbPath);
std::filesystem::create_directories(dbPath);
}
SavedState state = stateDb_.getState();
@@ -414,8 +414,8 @@ SHAMapStoreImp::dbPaths()
return false;
// Check if configured "path" matches stored directory path
using namespace boost::filesystem;
auto const stored{path(sPath)};
using namespace std::filesystem;
auto const stored{std::filesystem::path(sPath)};
if (stored.parent_path() == dbPath)
return false;
@@ -433,9 +433,9 @@ SHAMapStoreImp::dbPaths()
bool writableDbExists = false;
bool archiveDbExists = false;
std::vector<boost::filesystem::path> pathsToDelete;
for (boost::filesystem::directory_iterator it(dbPath);
it != boost::filesystem::directory_iterator();
std::vector<std::filesystem::path> pathsToDelete;
for (std::filesystem::directory_iterator it(dbPath);
it != std::filesystem::directory_iterator();
++it)
{
if (state.writableDb.compare(it->path().string()) == 0)
@@ -456,7 +456,7 @@ SHAMapStoreImp::dbPaths()
(!archiveDbExists && !state.archiveDb.empty()) || (writableDbExists != archiveDbExists) ||
state.writableDb.empty() != state.archiveDb.empty())
{
boost::filesystem::path stateDbPathName = app_.config().legacy(Sections::kDatabasePath);
std::filesystem::path stateDbPathName = app_.config().legacy(Sections::kDatabasePath);
stateDbPathName /= dbName_;
stateDbPathName += "*";
@@ -478,15 +478,15 @@ SHAMapStoreImp::dbPaths()
}
// The necessary directories exist. Now, remove any others.
for (boost::filesystem::path const& p : pathsToDelete)
boost::filesystem::remove_all(p);
for (std::filesystem::path const& p : pathsToDelete)
std::filesystem::remove_all(p);
}
std::unique_ptr<NodeStore::Backend>
SHAMapStoreImp::makeBackendRotating(std::string path)
{
Section section{app_.config().section(Sections::kNodeDatabase)};
boost::filesystem::path newPath;
std::filesystem::path newPath;
if (!path.empty())
{
@@ -494,10 +494,7 @@ SHAMapStoreImp::makeBackendRotating(std::string path)
}
else
{
boost::filesystem::path p = get(section, Keys::kPath);
p /= dbPrefix_;
p += ".%%%%";
newPath = boost::filesystem::unique_path(p);
newPath = beast::uniqueRandomPath(get(section, Keys::kPath), 100, dbPrefix_ + ".");
}
section.set(Keys::kPath, newPath.string());

View File

@@ -12,6 +12,7 @@
#include <boost/thread/shared_mutex.hpp>
#include <filesystem>
#include <mutex>
#include <shared_mutex>
@@ -204,7 +205,7 @@ class ValidatorList
ManifestCache& validatorManifests_;
ManifestCache& publisherManifests_;
TimeKeeper& timeKeeper_;
boost::filesystem::path const dataPath_;
std::filesystem::path const dataPath_;
beast::Journal const j_;
std::shared_mutex mutable mutex_;
using scoped_lock = std::scoped_lock<decltype(mutex_)>;
@@ -803,7 +804,7 @@ private:
/** Get the filename used for caching UNLs
*/
boost::filesystem::path
std::filesystem::path
getCacheFileName(scoped_lock const&, PublicKey const& pubKey) const;
/** Build a Json representation of the collection, suitable for

View File

@@ -29,12 +29,8 @@
#include <xrpl/server/Manifest.h>
#include <xrpl/server/NetworkOPs.h>
#include <boost/filesystem/operations.hpp>
#include <boost/regex/v5/regex.hpp>
#include <boost/regex/v5/regex_match.hpp>
#include <boost/system/detail/errc.hpp>
#include <boost/system/detail/error_code.hpp>
#include <boost/system/errc.hpp>
#include <xrpl.pb.h>
@@ -43,6 +39,7 @@
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <filesystem>
#include <functional>
#include <iterator>
#include <limits>
@@ -54,6 +51,7 @@
#include <shared_mutex>
#include <string>
#include <string_view>
#include <system_error>
#include <utility>
#include <vector>
@@ -288,7 +286,7 @@ ValidatorList::load(
return true;
}
boost::filesystem::path
std::filesystem::path
ValidatorList::getCacheFileName(ValidatorList::scoped_lock const&, PublicKey const& pubKey) const
{
return dataPath_ / (kFilePrefix + strHex(pubKey));
@@ -372,9 +370,9 @@ ValidatorList::cacheValidatorFile(ValidatorList::scoped_lock const& lock, Public
if (dataPath_.empty())
return;
boost::filesystem::path const filename = getCacheFileName(lock, pubKey);
std::filesystem::path const filename = getCacheFileName(lock, pubKey);
boost::system::error_code ec;
std::error_code ec;
json::Value value = buildFileData(strHex(pubKey), publisherLists_.at(pubKey), j_);
// xrpld should be the only process writing to this file, so
@@ -1283,8 +1281,7 @@ std::vector<std::string>
ValidatorList::loadLists()
{
using namespace std::string_literals;
using namespace boost::filesystem;
using namespace boost::system::errc;
using namespace std::filesystem;
std::scoped_lock const lock{mutex_};
@@ -1292,12 +1289,12 @@ ValidatorList::loadLists()
sites.reserve(publisherLists_.size());
for (auto const& [pubKey, publisherCollection] : publisherLists_)
{
boost::system::error_code ec;
std::error_code ec;
if (publisherCollection.status == PublisherStatus::Available)
continue;
boost::filesystem::path const filename = getCacheFileName(lock, pubKey);
std::filesystem::path const filename = getCacheFileName(lock, pubKey);
auto const fullPath{canonical(filename, ec)};
if (ec)
@@ -1308,7 +1305,7 @@ ValidatorList::loadLists()
{
// Treat an empty file as a missing file, because
// nobody else is going to write it.
ec = make_error_code(no_such_file_or_directory);
ec = make_error_code(std::errc::no_such_file_or_directory);
}
if (ec)
continue;

View File

@@ -38,7 +38,6 @@
#include <xrpl/rdb/RelationalDatabase.h>
#include <xrpl/rdb/SociDB.h>
#include <boost/filesystem/operations.hpp>
#include <boost/format/free_funcs.hpp>
#include <boost/optional/optional.hpp> // IWYU pragma: keep
#include <boost/system/detail/error_code.hpp>
@@ -54,6 +53,7 @@
#include <cstddef>
#include <cstdint>
#include <exception>
#include <filesystem>
#include <functional>
#include <limits>
#include <map>
@@ -62,6 +62,7 @@
#include <sstream>
#include <stdexcept>
#include <string>
#include <system_error>
#include <utility>
#include <variant>
#include <vector>
@@ -1291,8 +1292,8 @@ getTransaction(
bool
dbHasSpace(soci::session& session, Config const& config, beast::Journal j)
{
boost::filesystem::space_info const space =
boost::filesystem::space(config.legacy(Sections::kDatabasePath));
std::filesystem::space_info const space =
std::filesystem::space(config.legacy(Sections::kDatabasePath));
if (space.available < megabytes(512))
{
@@ -1303,9 +1304,9 @@ dbHasSpace(soci::session& session, Config const& config, beast::Journal j)
if (config.useTxTables())
{
DatabaseCon::Setup const dbSetup = setupDatabaseCon(config);
boost::filesystem::path const dbPath = dbSetup.dataDir / kTxDbName;
boost::system::error_code ec;
std::optional<std::uint64_t> dbSize = boost::filesystem::file_size(dbPath, ec);
std::filesystem::path const dbPath = dbSetup.dataDir / kTxDbName;
std::error_code ec;
std::optional<std::uint64_t> dbSize = std::filesystem::file_size(dbPath, ec);
if (ec)
{
JLOG(j.error()) << "Error checking transaction db file size: " << ec.message();

View File

@@ -9,9 +9,8 @@
#include <xrpl/protocol/SystemParameters.h> // VFALCO Breaks levelization
#include <xrpl/rdb/DatabaseCon.h>
#include <boost/filesystem.hpp> // VFALCO FIX: This include should not be here
#include <cstdint>
#include <filesystem>
#include <optional>
#include <string>
#include <unordered_set>
@@ -82,17 +81,17 @@ public:
static char const* const kValidatorsFileName;
/** Returns the full path and filename of the debug log file. */
[[nodiscard]] boost::filesystem::path
[[nodiscard]] std::filesystem::path
getDebugLogFile() const;
private:
boost::filesystem::path configFile_;
std::filesystem::path configFile_;
public:
boost::filesystem::path configDir;
std::filesystem::path configDir;
private:
boost::filesystem::path debugLogfile_;
std::filesystem::path debugLogfile_;
void
load();

View File

@@ -21,21 +21,19 @@
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/format/free_funcs.hpp>
#include <boost/multiprecision/detail/endian.hpp>
#include <boost/predef.h>
#include <boost/regex.hpp> // IWYU pragma: keep
#include <boost/regex/v5/regex.hpp>
#include <boost/regex/v5/regex_match.hpp>
#include <boost/system/detail/error_code.hpp>
#include <algorithm>
#include <array>
#include <chrono>
#include <cstdint>
#include <cstdlib>
#include <filesystem>
#include <iostream>
#include <iterator>
#include <limits>
@@ -45,6 +43,7 @@
#include <sstream>
#include <stdexcept>
#include <string>
#include <system_error>
#include <thread>
#include <type_traits>
#include <utility>
@@ -313,13 +312,13 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
// directory, use the current working directory as the
// config directory and that with "db" as the data
// directory.
boost::filesystem::path dataDir;
std::filesystem::path dataDir;
if (!strConf.empty())
{
// --conf=<path> : everything is relative that file.
configFile_ = strConf;
configDir = boost::filesystem::absolute(configFile_);
configDir = std::filesystem::absolute(configFile_);
configDir.remove_filename();
dataDir = configDir / kDatabaseDirName;
}
@@ -330,13 +329,13 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
// Check if either of the config files exist in the current working
// directory, in which case the databases will be stored in a
// subdirectory.
configDir = boost::filesystem::current_path();
configDir = std::filesystem::current_path();
dataDir = configDir / kDatabaseDirName;
configFile_ = configDir / kConfigFileName;
if (boost::filesystem::exists(configFile_))
if (std::filesystem::exists(configFile_))
break;
configFile_ = configDir / kConfigLegacyName;
if (boost::filesystem::exists(configFile_))
if (std::filesystem::exists(configFile_))
break;
// Check if the home directory is set, and optionally the XDG config
@@ -363,10 +362,10 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
dataDir = strXdgDataHome + "/" + systemName();
configDir = strXdgConfigHome + "/" + systemName();
configFile_ = configDir / kConfigFileName;
if (boost::filesystem::exists(configFile_))
if (std::filesystem::exists(configFile_))
break;
configFile_ = configDir / kConfigLegacyName;
if (boost::filesystem::exists(configFile_))
if (std::filesystem::exists(configFile_))
break;
}
@@ -374,7 +373,7 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
dataDir = "/var/lib/" + systemName();
configDir = "/etc/" + systemName();
configFile_ = configDir / kConfigFileName;
if (boost::filesystem::exists(configFile_))
if (std::filesystem::exists(configFile_))
break;
configFile_ = configDir / kConfigLegacyName;
} while (false);
@@ -387,7 +386,7 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
std::string const dbPath(legacy(Sections::kDatabasePath));
if (!dbPath.empty())
{
dataDir = boost::filesystem::path(dbPath);
dataDir = std::filesystem::path(dbPath);
}
else if (runStandalone_)
{
@@ -397,13 +396,13 @@ Config::setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStand
if (!dataDir.empty())
{
boost::system::error_code ec;
boost::filesystem::create_directories(dataDir, ec);
std::error_code ec;
std::filesystem::create_directories(dataDir, ec);
if (ec)
Throw<std::runtime_error>(boost::str(boost::format("Can not create %s") % dataDir));
legacy(Sections::kDatabasePath, boost::filesystem::absolute(dataDir).string());
legacy(Sections::kDatabasePath, std::filesystem::absolute(dataDir).string());
}
HTTPClient::initializeSSLContext(this->sslVerifyDir, this->sslVerifyFile, this->sslVerify, j_);
@@ -455,7 +454,7 @@ Config::load()
if (!quiet_)
std::cerr << "Loading: " << configFile_ << "\n";
boost::system::error_code ec;
std::error_code ec;
auto const fileContents = getFileContents(ec, configFile_);
if (ec)
@@ -508,8 +507,8 @@ Config::loadFromString(std::string const& fileContents)
std::string dbPath;
if (getSingleSection(secConfig, Sections::kDatabasePath, dbPath, j_))
{
boost::filesystem::path const p(dbPath);
legacy(Sections::kDatabasePath, boost::filesystem::absolute(p).string());
std::filesystem::path const p(dbPath);
legacy(Sections::kDatabasePath, std::filesystem::absolute(p).string());
}
}
@@ -968,7 +967,7 @@ Config::loadFromString(std::string const& fileContents)
// If no path was specified, then look for validators.txt
// in the same directory as the config file, but don't complain
// if we can't find it.
boost::filesystem::path validatorsFile;
std::filesystem::path validatorsFile;
if (getSingleSection(secConfig, Sections::kValidatorsFile, strTemp, j_))
{
@@ -983,7 +982,7 @@ Config::loadFromString(std::string const& fileContents)
if (!validatorsFile.is_absolute() && !configDir.empty())
validatorsFile = configDir / validatorsFile;
if (!boost::filesystem::exists(validatorsFile))
if (!std::filesystem::exists(validatorsFile))
{
Throw<std::runtime_error>(
std::string("The file specified in [") + Sections::kValidatorsFile +
@@ -992,8 +991,8 @@ Config::loadFromString(std::string const& fileContents)
validatorsFile.string());
}
else if (
!boost::filesystem::is_regular_file(validatorsFile) &&
!boost::filesystem::is_symlink(validatorsFile))
!std::filesystem::is_regular_file(validatorsFile) &&
!std::filesystem::is_symlink(validatorsFile))
{
Throw<std::runtime_error>(
std::string("Invalid file specified in [") + Sections::kValidatorsFile +
@@ -1006,24 +1005,24 @@ Config::loadFromString(std::string const& fileContents)
if (!validatorsFile.empty())
{
if (!boost::filesystem::exists(validatorsFile))
if (!std::filesystem::exists(validatorsFile))
{
validatorsFile.clear();
}
else if (
!boost::filesystem::is_regular_file(validatorsFile) &&
!boost::filesystem::is_symlink(validatorsFile))
!std::filesystem::is_regular_file(validatorsFile) &&
!std::filesystem::is_symlink(validatorsFile))
{
validatorsFile.clear();
}
}
}
if (!validatorsFile.empty() && boost::filesystem::exists(validatorsFile) &&
(boost::filesystem::is_regular_file(validatorsFile) ||
boost::filesystem::is_symlink(validatorsFile)))
if (!validatorsFile.empty() && std::filesystem::exists(validatorsFile) &&
(std::filesystem::is_regular_file(validatorsFile) ||
std::filesystem::is_symlink(validatorsFile)))
{
boost::system::error_code ec;
std::error_code ec;
auto const data = getFileContents(ec, validatorsFile);
if (ec)
{
@@ -1156,7 +1155,7 @@ Config::loadFromString(std::string const& fileContents)
}
}
boost::filesystem::path
std::filesystem::path
Config::getDebugLogFile() const
{
auto logFile = debugLogfile_;
@@ -1165,17 +1164,17 @@ Config::getDebugLogFile() const
{
// Unless an absolute path for the log file is specified, the
// path is relative to the config file directory.
logFile = boost::filesystem::absolute(logFile, configDir);
logFile = std::filesystem::absolute(configDir / logFile);
}
if (!logFile.empty())
{
auto logDir = logFile.parent_path();
if (!boost::filesystem::is_directory(logDir))
if (!std::filesystem::is_directory(logDir))
{
boost::system::error_code ec;
boost::filesystem::create_directories(logDir, ec);
std::error_code ec;
std::filesystem::create_directories(logDir, ec);
// If we fail, we warn but continue so that the calling code can
// decide how to handle this situation.

View File

@@ -14,11 +14,9 @@
#include <xrpl/json/json_writer.h>
#include <xrpl/protocol/jss.h>
#include <boost/filesystem/operations.hpp>
#include <boost/system/detail/error_code.hpp>
#include <chrono>
#include <cstdint>
#include <filesystem>
#include <functional>
#include <ios>
#include <memory>
@@ -26,6 +24,7 @@
#include <ostream>
#include <set>
#include <string>
#include <system_error>
#include <unordered_map>
#include <utility>
#include <vector>
@@ -217,10 +216,10 @@ PerfLogImp::openLog()
logFile_.close();
auto logDir = setup_.perfLog.parent_path();
if (!boost::filesystem::is_directory(logDir))
if (!std::filesystem::is_directory(logDir))
{
boost::system::error_code ec;
boost::filesystem::create_directories(logDir, ec);
std::error_code ec;
std::filesystem::create_directories(logDir, ec);
if (ec)
{
JLOG(j_.fatal()) << "Unable to create performance log "
@@ -475,17 +474,17 @@ PerfLogImp::stop()
//-----------------------------------------------------------------------------
PerfLog::Setup
setupPerfLog(Section const& section, boost::filesystem::path const& configDir)
setupPerfLog(Section const& section, std::filesystem::path const& configDir)
{
PerfLog::Setup setup;
std::string perfLog;
set(perfLog, "perf_log", section);
if (!perfLog.empty())
{
setup.perfLog = boost::filesystem::path(perfLog);
setup.perfLog = std::filesystem::path(perfLog);
if (setup.perfLog.is_relative())
{
setup.perfLog = boost::filesystem::absolute(setup.perfLog, configDir);
setup.perfLog = std::filesystem::absolute(configDir / setup.perfLog);
}
}