From c2f19a38379777887869da643e72954b6a6dffc1 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Sun, 8 Aug 2021 16:02:05 +0100 Subject: [PATCH] Passing nano::networks enum in to working_path rather than statically constructing it. --- nano/core_test/core_test_main.cc | 2 +- nano/secure/utility.cpp | 9 ++++----- nano/secure/utility.hpp | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/nano/core_test/core_test_main.cc b/nano/core_test/core_test_main.cc index 7bd3e05b..ee80f5d6 100644 --- a/nano/core_test/core_test_main.cc +++ b/nano/core_test/core_test_main.cc @@ -2,6 +2,7 @@ #include #include +#include #include @@ -9,7 +10,6 @@ namespace nano { void cleanup_dev_directories_on_exit (); void force_nano_dev_network (); -boost::filesystem::path unique_path (); } GTEST_API_ int main (int argc, char ** argv) diff --git a/nano/secure/utility.cpp b/nano/secure/utility.cpp index c15de739..917fb3e8 100644 --- a/nano/secure/utility.cpp +++ b/nano/secure/utility.cpp @@ -6,11 +6,10 @@ static std::vector all_unique_paths; -boost::filesystem::path nano::working_path () +boost::filesystem::path nano::working_path (nano::networks network) { - static nano::network_constants network_constants; auto result (nano::app_path ()); - switch (network_constants.network ()) + switch (network) { case nano::networks::invalid: release_assert (false); @@ -31,9 +30,9 @@ boost::filesystem::path nano::working_path () return result; } -boost::filesystem::path nano::unique_path () +boost::filesystem::path nano::unique_path (nano::networks network) { - auto result (working_path () / boost::filesystem::unique_path ()); + auto result (working_path (network) / boost::filesystem::unique_path ()); all_unique_paths.push_back (result); return result; } diff --git a/nano/secure/utility.hpp b/nano/secure/utility.hpp index 71b59834..ae678294 100644 --- a/nano/secure/utility.hpp +++ b/nano/secure/utility.hpp @@ -1,16 +1,16 @@ #pragma once -#include +#include #include namespace nano { // OS-specific way of finding a path to a home directory. -boost::filesystem::path working_path (); +boost::filesystem::path working_path (nano::networks network = nano::network_constants::active_network); // Get a unique path within the home directory, used for testing. // Any directories created at this location will be removed when a test finishes. -boost::filesystem::path unique_path (); +boost::filesystem::path unique_path (nano::networks network = nano::network_constants::active_network); // Remove all unique tmp directories created by the process void remove_temporary_directories (); // Generic signal handler declarations