diff --git a/support/3rd_party/include/utils/encryption.hpp b/support/3rd_party/include/utils/encryption.hpp index 93e88476..41ea2cf7 100644 --- a/support/3rd_party/include/utils/encryption.hpp +++ b/support/3rd_party/include/utils/encryption.hpp @@ -35,6 +35,7 @@ inline constexpr const std::uint32_t encryption_header_size{ crypto_aead_xchacha20poly1305_IETF_ABYTES, }; +#if defined(PROJECT_ENABLE_BOOST) [[nodiscard]] auto decrypt_data( std::string_view data, std::string_view password, std::optional hasher = std::nullopt) -> data_buffer; @@ -43,9 +44,6 @@ inline constexpr const std::uint32_t encryption_header_size{ std::string_view data, std::string_view password, std::optional hasher = std::nullopt) -> data_buffer; -[[nodiscard]] auto generate_key(std::string_view encryption_token) -> key_type; - -#if defined(PROJECT_ENABLE_BOOST) template [[nodiscard]] inline auto decrypt_data(const key_type &key, const unsigned char *buffer, @@ -154,6 +152,8 @@ encrypt_data(const std::array key_type; } // namespace repertory::utils::encryption #endif // defined(PROJECT_ENABLE_LIBSODIUM) diff --git a/support/3rd_party/include/utils/path.hpp b/support/3rd_party/include/utils/path.hpp index 2dbd2604..b4f9aa3d 100644 --- a/support/3rd_party/include/utils/path.hpp +++ b/support/3rd_party/include/utils/path.hpp @@ -241,6 +241,7 @@ template &paths) -> string_t { format_path(path, get_directory_seperator(), get_not_directory_seperator()); + return absolute(std::accumulate( paths.begin(), paths.end(), path, [](auto next_path, auto &&path_part) { if (next_path.empty()) { diff --git a/support/3rd_party/include/utils/string.hpp b/support/3rd_party/include/utils/string.hpp index 30a0d979..2d648cf7 100644 --- a/support/3rd_party/include/utils/string.hpp +++ b/support/3rd_party/include/utils/string.hpp @@ -323,7 +323,7 @@ template inline auto replace(string_t &src, typename string_t::value_type character, typename string_t::value_type with, std::size_t start_pos) -> string_t & { - if (not src.empty() && (start_pos < src.size())) { + if (start_pos < src.size()) { std::replace(std::next(src.begin(), start_pos), src.end(), character, with); } @@ -335,12 +335,13 @@ inline auto replace(string_t &src, std::basic_string_view find, std::basic_string_view with, std::size_t start_pos) -> string_t & { - if (not src.empty() && (start_pos < src.size())) { + if (start_pos < src.size()) { while ((start_pos = src.find(find, start_pos)) != string_t::npos) { src.replace(start_pos, find.size(), with); start_pos += with.size(); } } + return src; } diff --git a/support/3rd_party/src/utils/encryption.cpp b/support/3rd_party/src/utils/encryption.cpp index 7fc27638..a67cd20c 100644 --- a/support/3rd_party/src/utils/encryption.cpp +++ b/support/3rd_party/src/utils/encryption.cpp @@ -22,7 +22,6 @@ #include "utils/encryption.hpp" #if defined(PROJECT_ENABLE_LIBSODIUM) - namespace { using nonce_t = std::array; @@ -45,6 +44,7 @@ static constexpr const auto nonce_size{sizeof(nonce_t)}; } // namespace namespace repertory::utils::encryption { +#if defined(PROJECT_ENABLE_BOOST) auto decrypt_data(std::string_view data, std::string_view password, std::optional hasher) -> data_buffer { auto key = @@ -71,6 +71,7 @@ auto encrypt_data(std::string_view data, std::string_view password, return buf; } +#endif // defined(PROJECT_ENABLE_BOOST) auto generate_key(std::string_view encryption_token) -> key_type { crypto_hash_sha256_state state{}; diff --git a/support/3rd_party/test/src/utils/path_test.cpp b/support/3rd_party/test/src/utils/path_test.cpp index f4d3b041..438ea0d7 100644 --- a/support/3rd_party/test/src/utils/path_test.cpp +++ b/support/3rd_party/test/src/utils/path_test.cpp @@ -22,6 +22,7 @@ #include "gtest/gtest.h" #include "utils/path.hpp" +#include "utils/string.hpp" namespace repertory { TEST(utils_path, constants) { @@ -39,16 +40,41 @@ TEST(utils_path, directory_seperator) { #if defined(_WIN32) EXPECT_EQ(utils::path::backslash, utils::path::directory_seperator); EXPECT_EQ(utils::path::backslash_w, utils::path::directory_seperator_w); + EXPECT_EQ(utils::path::slash, utils::path::not_directory_seperator); EXPECT_EQ(utils::path::slash_w, utils::path::not_directory_seperator_w); #else // !defined(_WIN32) EXPECT_EQ(utils::path::slash, utils::path::directory_seperator); EXPECT_EQ(utils::path::slash_w, utils::path::directory_seperator_w); + EXPECT_EQ(utils::path::backslash, utils::path::not_directory_seperator); EXPECT_EQ(utils::path::backslash_w, utils::path::not_directory_seperator_w); #endif // defined(_WIN32) } +TEST(utils_path, get_directory_seperator) { +#if defined(_WIN32) + EXPECT_EQ(utils::path::backslash, + utils::path::get_directory_seperator()); + EXPECT_EQ(utils::path::backslash_w, + utils::path::get_directory_seperator()); + + EXPECT_EQ(utils::path::slash, + utils::path::get_not_directory_seperator()); + EXPECT_EQ(utils::path::slash_w, + utils::path::get_not_directory_seperator()); +#else // !defined(_WIN32) + EXPECT_EQ(utils::path::slash, utils::path::get_directory_seperator()); + EXPECT_EQ(utils::path::slash_w, + utils::path::get_directory_seperator()); + + EXPECT_EQ(utils::path::backslash, + utils::path::get_not_directory_seperator()); + EXPECT_EQ(utils::path::backslash_w, + utils::path::get_not_directory_seperator()); +#endif // defined(_WIN32) +} + TEST(utils_path, get_backslash) { EXPECT_EQ(utils::path::backslash, utils::path::get_backslash()); EXPECT_EQ(utils::path::backslash_w, utils::path::get_backslash()); @@ -59,6 +85,16 @@ TEST(utils_path, get_dot) { EXPECT_EQ(utils::path::dot_w, utils::path::get_dot()); } +TEST(utils_path, get_dot_slash) { + EXPECT_EQ(utils::path::dot_slash, utils::path::get_dot_slash()); + EXPECT_EQ(utils::path::dot_slash_w, utils::path::get_dot_slash()); +} + +TEST(utils_path, get_slash) { + EXPECT_EQ(utils::path::slash, utils::path::get_slash()); + EXPECT_EQ(utils::path::slash_w, utils::path::get_slash()); +} + TEST(utils_path, combine) { auto s = utils::path::combine(R"(\test\path)", {});