mirror of
https://github.com/XRPLF/clio.git
synced 2026-04-29 15:37:53 +00:00
refactor: Remove boost filesystem (#1859)
This commit is contained in:
@@ -34,10 +34,9 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@@ -82,7 +81,7 @@ ConfigFileJson::ConfigFileJson(boost::json::object jsonObj)
|
||||
}
|
||||
|
||||
std::expected<ConfigFileJson, Error>
|
||||
ConfigFileJson::makeConfigFileJson(boost::filesystem::path configFilePath)
|
||||
ConfigFileJson::makeConfigFileJson(std::filesystem::path const& configFilePath)
|
||||
{
|
||||
try {
|
||||
if (auto const in = std::ifstream(configFilePath.string(), std::ios::in | std::ios::binary); in) {
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
#include "util/newconfig/Error.hpp"
|
||||
#include "util/newconfig/Types.hpp"
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/json/object.hpp>
|
||||
|
||||
#include <expected>
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
* @return A ConfigFileJson object if parsing user file is successful. Error otherwise
|
||||
*/
|
||||
[[nodiscard]] static std::expected<ConfigFileJson, Error>
|
||||
makeConfigFileJson(boost::filesystem::path configFilePath);
|
||||
makeConfigFileJson(std::filesystem::path const& configFilePath);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "util/Assert.hpp"
|
||||
#include "util/LoggerFixtures.hpp"
|
||||
#include "util/TmpFile.hpp"
|
||||
#include "util/config/Config.hpp"
|
||||
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
@@ -29,8 +30,6 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
#include <optional>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
@@ -236,36 +235,10 @@ TEST_F(ConfigTest, Extend)
|
||||
ASSERT_EQ(custom.c, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Simple temporary file util
|
||||
*/
|
||||
class TmpFile {
|
||||
public:
|
||||
TmpFile(std::string const& data) : tmpPath_{boost::filesystem::unique_path().string()}
|
||||
{
|
||||
std::ofstream of;
|
||||
of.open(tmpPath_);
|
||||
of << data;
|
||||
of.close();
|
||||
}
|
||||
~TmpFile()
|
||||
{
|
||||
std::remove(tmpPath_.c_str());
|
||||
}
|
||||
std::string
|
||||
path() const
|
||||
{
|
||||
return tmpPath_;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string tmpPath_;
|
||||
};
|
||||
|
||||
TEST_F(ConfigTest, File)
|
||||
{
|
||||
auto tmp = TmpFile(kJSON_DATA);
|
||||
auto conf = ConfigReader::open(tmp.path());
|
||||
auto conf = ConfigReader::open(tmp.path);
|
||||
|
||||
ASSERT_EQ(conf.value<int64_t>("top"), 420);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user