Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove boost::filesystem references #2073

Merged
7 commits merged into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ namespace atomic_dex

application::application(QObject* pParent) : QObject(pParent)
{
fs::path settings_path = (atomic_dex::utils::get_current_configs_path() / "cfg.ini");
std::filesystem::path settings_path = (atomic_dex::utils::get_current_configs_path() / "cfg.ini");
#if defined(_WIN32) || defined(WIN32)
this->entity_registry_.set<QSettings>(QString::fromStdWString(settings_path.wstring()), QSettings::IniFormat);
#else
Expand Down Expand Up @@ -493,7 +493,7 @@ namespace atomic_dex
this->m_secondary_coin_fully_enabled = false;
this->m_primary_coin_fully_enabled = false;
system_manager_.get_system<qt_wallet_manager>().set_status("None");
return fs::remove(utils::get_atomic_dex_config_folder() / "default.wallet");
return std::filesystem::remove(utils::get_atomic_dex_config_folder() / "default.wallet");
}

void application::connect_signals()
Expand Down
54 changes: 27 additions & 27 deletions src/app/main.prerequisites.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ connect_signals_handler()
{
SPDLOG_INFO("connecting signal SIGABRT to the signal handler");
#if defined(linux) || defined(__APPLE__)
if (fs::exists("./backtrace.dump"))
if (std::filesystem::exists("./backtrace.dump"))
{
// there is a backtrace
std::ifstream ifs("./backtrace.dump");
Expand All @@ -130,7 +130,7 @@ connect_signals_handler()

// cleaning up
ifs.close();
fs::remove("./backtrace.dump");
std::filesystem::remove("./backtrace.dump");
}
#endif
std::signal(SIGABRT, &signal_handler);
Expand Down Expand Up @@ -169,7 +169,7 @@ static void init_logging()
constexpr size_t spdlog_max_file_size = 7777777;
constexpr size_t spdlog_max_file_rotation = 3;

fs::path path = atomic_dex::utils::get_atomic_dex_current_log_file();
std::filesystem::path path = atomic_dex::utils::get_atomic_dex_current_log_file();
spdlog::init_thread_pool(qsize_spdlog, spdlog_thread_count);
auto tp = spdlog::thread_pool();
auto stdout_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
Expand Down Expand Up @@ -242,7 +242,7 @@ init_timezone_db()
try
{
using namespace std::string_literals;
auto install_db_tz_path = std::make_unique<fs::path>(ag::core::assets_real_path() / "tools" / "timezone" / "tzdata");
auto install_db_tz_path = std::make_unique<std::filesystem::path>(ag::core::assets_real_path() / "tools" / "timezone" / "tzdata");
date::set_install(install_db_tz_path->string());
SPDLOG_INFO("Timezone db successfully initialized");
}
Expand All @@ -256,57 +256,57 @@ init_timezone_db()
static void
setup_default_themes()
{
const fs::path theme_path = atomic_dex::utils::get_themes_path();
fs::path original_theme_path{ag::core::assets_real_path() / "themes"};
fs_error_code ec;
const std::filesystem::path theme_path = atomic_dex::utils::get_themes_path();
std::filesystem::path original_theme_path{ag::core::assets_real_path() / "themes"};
std::error_code ec;

LOG_PATH_CMP("Checking for setup default themes - theme_path: {} original_theme_path: {}", theme_path, original_theme_path);
LOG_PATH("copying default themes into directory: {}", theme_path);
//fs::remove_all(theme_path);
fs::copy(original_theme_path, theme_path, fs::copy_options::recursive | fs::copy_options::overwrite_existing, ec);
//std::filesystem::remove_all(theme_path);
std::filesystem::copy(original_theme_path, theme_path, std::filesystem::copy_options::recursive | std::filesystem::copy_options::overwrite_existing, ec);
if (ec)
{
SPDLOG_ERROR("fs::error: {}", ec.message());
SPDLOG_ERROR("std::filesystem::error: {}", ec.message());
}

ec.clear();

//! Logo
{
const fs::path logo_path = atomic_dex::utils::get_logo_path();
fs::path original_logo_path{ag::core::assets_real_path() / "logo"};
const std::filesystem::path logo_path = atomic_dex::utils::get_logo_path();
std::filesystem::path original_logo_path{ag::core::assets_real_path() / "logo"};

LOG_PATH_CMP("Checking for setup default logo - logo_path: {} original_logo_path: {}", logo_path, original_logo_path);
//fs::remove_all(logo_path);
fs::copy(original_logo_path, logo_path, fs::copy_options::recursive | fs::copy_options::overwrite_existing, ec);
//std::filesystem::remove_all(logo_path);
std::filesystem::copy(original_logo_path, logo_path, std::filesystem::copy_options::recursive | std::filesystem::copy_options::overwrite_existing, ec);
LOG_PATH("copying default logo into directory: {}", logo_path);
if (ec)
{
SPDLOG_ERROR("fs::error: {}", ec.message());
SPDLOG_ERROR("std::filesystem::error: {}", ec.message());
}
}
}

static void
check_settings_reconfiguration(const fs::path& path)
check_settings_reconfiguration(const std::filesystem::path& path)
{
SPDLOG_INFO("Checking for settings ini reconfiguration");
using namespace atomic_dex::utils;
using namespace atomic_dex;
const fs::path previous_path = get_atomic_dex_data_folder() / get_precedent_raw_version() / "configs" / "cfg.ini";
if (fs::exists(previous_path) && !fs::exists(path))
const std::filesystem::path previous_path = get_atomic_dex_data_folder() / get_precedent_raw_version() / "configs" / "cfg.ini";
if (std::filesystem::exists(previous_path) && !std::filesystem::exists(path))
{
fs_error_code ec;
std::error_code ec;
LOG_PATH_CMP("Copying {} to {}", previous_path, path);
fs::copy(previous_path, path, ec);
std::filesystem::copy(previous_path, path, ec);
if (ec)
{
SPDLOG_ERROR("error occured when copying previous cfg.ini : {}", ec.message());
}

SPDLOG_INFO("Deleting previous cfg after reconfiguring it");
ec.clear();
fs::remove_all(get_atomic_dex_data_folder() / get_precedent_raw_version(), ec);
std::filesystem::remove_all(get_atomic_dex_data_folder() / get_precedent_raw_version(), ec);
if (ec)
{
SPDLOG_ERROR("error occured when deleting previous path");
Expand Down Expand Up @@ -364,11 +364,11 @@ run_app(int argc, char** argv)
qputenv("QT_ENABLE_GLYPH_CACHE_WORKAROUND", "1");
qputenv("QML_USE_GLYPHCACHE_WORKAROUND", "1");

fs::path old_path = fs::path(std::getenv("HOME")) / ".atomic_qt";
fs::path target_path = atomic_dex::utils::get_atomic_dex_data_folder();
SPDLOG_INFO("{} exists -> {}", old_path.string(), fs::exists(old_path));
SPDLOG_INFO("{} exists -> {}", target_path.string(), fs::exists(target_path));
if (fs::exists(old_path) && !fs::exists(target_path))
std::filesystem::path old_path = std::filesystem::path(std::getenv("HOME")) / ".atomic_qt";
std::filesystem::path target_path = atomic_dex::utils::get_atomic_dex_data_folder();
SPDLOG_INFO("{} exists -> {}", old_path.string(), std::filesystem::exists(old_path));
SPDLOG_INFO("{} exists -> {}", target_path.string(), std::filesystem::exists(target_path));
if (std::filesystem::exists(old_path) && !std::filesystem::exists(target_path))
{
SPDLOG_INFO("Renaming: {} to {}", old_path.string(), target_path.string());
QDir dir;
Expand All @@ -386,7 +386,7 @@ run_app(int argc, char** argv)
init_sodium();
clean_previous_run();
setup_default_themes();
fs::path settings_path = (atomic_dex::utils::get_current_configs_path() / "cfg.ini");
std::filesystem::path settings_path = (atomic_dex::utils::get_current_configs_path() / "cfg.ini");
check_settings_reconfiguration(settings_path);
init_dpi();

Expand Down
4 changes: 3 additions & 1 deletion src/core/atomicdex/api/mm2/mm2.client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* *
******************************************************************************/

#include <filesystem>

#include <meta/detection/detection.hpp>

#include "enable_slp_rpc.hpp"
Expand Down Expand Up @@ -130,7 +132,7 @@ namespace atomic_dex::mm2
catch (const std::exception& error)
{
SPDLOG_ERROR(
"{} l{} f[{}], exception caught {} for rpc {}, body: {}", __FUNCTION__, __LINE__, fs::path(__FILE__).filename().string(), error.what(),
"{} l{} f[{}], exception caught {} for rpc {}, body: {}", __FUNCTION__, __LINE__, std::filesystem::path(__FILE__).filename().string(), error.what(),
rpc_command, body);
answer.rpc_result_code = -1;
answer.raw_result = error.what();
Expand Down
8 changes: 4 additions & 4 deletions src/core/atomicdex/config/addressbook.cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace atomic_dex
{
nlohmann::json load_addressbook_cfg(const std::string& wallet_name)
{
const fs::path source_folder{utils::get_atomic_dex_addressbook_folder()};
const fs::path in_path {source_folder / wallet_name};
const std::filesystem::path source_folder{utils::get_atomic_dex_addressbook_folder()};
const std::filesystem::path in_path {source_folder / wallet_name};
QFile ifs;
QString content;
nlohmann::json out;
Expand Down Expand Up @@ -59,8 +59,8 @@ namespace atomic_dex

void update_addressbook_cfg(const nlohmann::json& in, const std::string& wallet_name)
{
const fs::path out_folder{utils::get_atomic_dex_addressbook_folder()};
const fs::path out_path {out_folder / wallet_name};
const std::filesystem::path out_folder{utils::get_atomic_dex_addressbook_folder()};
const std::filesystem::path out_path {out_folder / wallet_name};
QFile output;

utils::create_if_doesnt_exist(out_folder);
Expand Down
10 changes: 5 additions & 5 deletions src/core/atomicdex/config/app.cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace
void
upgrade_cfg(atomic_dex::cfg& config)
{
fs::path cfg_path = atomic_dex::utils::get_current_configs_path() / "cfg.json";
std::filesystem::path cfg_path = atomic_dex::utils::get_current_configs_path() / "cfg.json";
QFile file;
file.setFileName(atomic_dex::std_path_to_qstring(cfg_path));
file.open(QIODevice::ReadOnly | QIODevice::Text);
Expand Down Expand Up @@ -87,13 +87,13 @@ namespace atomic_dex
load_cfg()
{
cfg out;
fs::path cfg_path = utils::get_current_configs_path() / "cfg.json";
if (not fs::exists(cfg_path))
std::filesystem::path cfg_path = utils::get_current_configs_path() / "cfg.json";
if (not std::filesystem::exists(cfg_path))
{
fs::path original_cfg_path{ag::core::assets_real_path() / "config" / "cfg.json"};
std::filesystem::path original_cfg_path{ag::core::assets_real_path() / "config" / "cfg.json"};
//! Copy our json to current version
LOG_PATH_CMP("Copying app cfg: {} to {}", original_cfg_path, cfg_path);
fs::copy_file(original_cfg_path, cfg_path, get_override_options());
std::filesystem::copy_file(original_cfg_path, cfg_path, std::filesystem::copy_options::overwrite_existing);
}

QFile file;
Expand Down
2 changes: 1 addition & 1 deletion src/core/atomicdex/config/mm2.cfg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace atomic_dex
//std::vector<std::string> seednodes{"195.201.91.96", "195.201.91.53", "168.119.174.126", "46.4.78.11", "46.4.87.18"};
//std::vector<std::string> seednodes{"46.4.78.11", "46.4.87.18"};
#ifdef _WIN32
std::string userhome{utils::u8string(fs::path(_wgetenv(L"HOMEPATH")))};
std::string userhome{utils::u8string(std::filesystem::path(_wgetenv(L"HOMEPATH")))};
#else
std::string userhome{std::getenv("HOME")};
#endif
Expand Down
9 changes: 4 additions & 5 deletions src/core/atomicdex/config/raw.mm2.coins.cfg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

//! Project
#include "atomicdex/api/mm2/mm2.constants.hpp"
#include "atomicdex/utilities/fs.prerequisites.hpp"
#include "atomicdex/utilities/global.utilities.hpp"
#include "atomicdex/utilities/qt.utilities.hpp"

Expand Down Expand Up @@ -243,14 +242,14 @@ namespace atomic_dex
{
SPDLOG_INFO("parse_raw_mm2_coins_file");
t_mm2_raw_coins_registry out;
fs::path file_path{atomic_dex::utils::get_current_configs_path() / "coins.json"};
if (not fs::exists(file_path))
std::filesystem::path file_path{atomic_dex::utils::get_current_configs_path() / "coins.json"};
if (not std::filesystem::exists(file_path))
{
fs::path original_mm2_coins_path{ag::core::assets_real_path() / "tools" / "mm2" / "coins"};
std::filesystem::path original_mm2_coins_path{ag::core::assets_real_path() / "tools" / "mm2" / "coins"};
//! Copy our json to current version
LOG_PATH_CMP("Copying mm2 coins cfg: {} to {}", original_mm2_coins_path, file_path);

fs::copy_file(original_mm2_coins_path, file_path, get_override_options());
std::filesystem::copy_file(original_mm2_coins_path, file_path, std::filesystem::copy_options::overwrite_existing);
}

QFile file;
Expand Down
6 changes: 3 additions & 3 deletions src/core/atomicdex/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace atomic_dex
{
inline fs::path get_appdata_folder()
inline std::filesystem::path get_appdata_folder()
{
return utils::get_atomic_dex_data_folder();
}

inline fs::path get_themes_folder()
inline std::filesystem::path get_themes_folder()
{
return utils::get_themes_path();
}

inline fs::path get_theme_folder(std::string theme_name)
inline std::filesystem::path get_theme_folder(std::string theme_name)
{
return utils::get_themes_path() / theme_name;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/atomicdex/filesystem.qml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ namespace atomic_dex

bool filesystem::exists(QString path)
{
return fs::exists(path.toStdString());
return std::filesystem::exists(path.toStdString());
}
}
Loading