updated build system
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
2024-08-27 19:26:25 -05:00
parent 4e0ad1c710
commit 0db9052c3f
13 changed files with 274 additions and 159 deletions

View File

@ -326,7 +326,11 @@ using vlc_string_t = std::unique_ptr<char, vlc_string_deleter>;
#endif // defined(PROJECT_ENABLE_BOOST)
#if defined(PROJECT_ENABLE_CLI11)
#if defined(PROJECT_IS_MINGW) && !defined(PROJECT_IS_MINGW_UNIX)
#include "CLI/CLI.hpp"
#else // !defined(PROJECT_IS_MINGW) || defined(PROJECT_IS_MINGW_UNIX)
#include "CLI11.hpp"
#endif // defined(PROJECT_IS_MINGW) && !defined(PROJECT_IS_MINGW_UNIX)
#endif // defined(PROJECT_ENABLE_CLI11)
#if defined(PROJECT_ENABLE_CPP_HTTPLIB)

View File

@ -43,6 +43,8 @@ inline constexpr const std::string_view directory_seperator{backslash};
inline constexpr const std::wstring_view directory_seperator_w{backslash_w};
inline constexpr const std::string_view not_directory_seperator{slash};
inline constexpr const std::wstring_view not_directory_seperator_w{slash_w};
inline constexpr const std::string_view unc_notation{"\\\\"};
inline constexpr const std::wstring_view unc_notation_w{L"\\\\"};
#else // !defined(_WIN32)
inline constexpr const std::string_view directory_seperator{slash};
inline constexpr const std::wstring_view directory_seperator_w{slash_w};
@ -177,6 +179,24 @@ get_slash<wchar_t>() -> std::basic_string_view<wchar_t> {
return slash_w;
}
#if defined(_WIN32)
template <typename char_t>
[[nodiscard]] inline constexpr auto
get_unc_notation() -> std::basic_string_view<char_t>;
template <>
[[nodiscard]] inline constexpr auto
get_unc_notation<char>() -> std::basic_string_view<char> {
return unc_notation;
}
template <>
[[nodiscard]] inline constexpr auto
get_unc_notation<wchar_t>() -> std::basic_string_view<wchar_t> {
return unc_notation_w;
}
#endif // defined(_WIN32)
template <typename string_t>
[[nodiscard]] inline auto get_current_path() -> string_t;
@ -332,6 +352,11 @@ template <typename string_t>
get_not_directory_seperator<typename string_t::value_type>());
#if defined(_WIN32)
auto unc_notation_t = get_unc_notation<typename string_t::value_type>();
if (utils::string::begins_with(fmt_path, unc_notation_t)) {
return fmt_path;
}
auto dot_t = get_dot<typename string_t::value_type>();
auto dot_sep_t = string_t{dot_t} + dir_sep_t;
if (fmt_path == dot_t || fmt_path == dot_sep_t) {
@ -385,9 +410,15 @@ format_path(string_t &path,
utils::string::replace(path, not_sep, sep);
#if defined(_WIN32)
auto is_unc{false};
auto long_notation_t = get_long_notation<typename string_t::value_type>();
auto unc_notation_t = get_unc_notation<typename string_t::value_type>();
if (utils::string::begins_with(path, long_notation_t)) {
path = path.substr(long_notation_t.size());
} else if (utils::string::begins_with(path, unc_notation_t)) {
path = path.substr(unc_notation_t.size());
utils::string::left_trim(path, sep.at(0U));
is_unc = true;
}
#endif // defined(_WIN32)
@ -401,7 +432,9 @@ format_path(string_t &path,
}
#if defined(_WIN32)
if ((path.size() >= 2U) && (path.at(1U) == ':')) {
if (is_unc) {
path = string_t{unc_notation_t} + path;
} else if ((path.size() >= 2U) && (path.at(1U) == ':')) {
path[0U] = utils::string::to_lower(string_t(1U, path.at(0U))).at(0U);
}
#endif // defined(_WIN32)

View File

@ -342,7 +342,7 @@ auto directory::remove() -> bool {
return utils::retry_action([this]() -> bool {
try {
#if defined(_WIN32)
return (::RemoveDirectoryA(path_.c_str()));
return ::RemoveDirectoryA(path_.c_str());
#else // !defined(_WIN32)
return (rmdir(path_.c_str()) == 0);
#endif // defined(_WIN32)

View File

@ -437,7 +437,7 @@ auto file::remove() -> bool {
return utils::retry_action([this]() -> bool {
#if defined(_WIN32)
return !!::DeleteFileA(path_.c_str());
return ::DeleteFileA(path_.c_str());
#else // !defined(_WIN32)
std::error_code ec{};
return std::filesystem::remove(path_, ec);

View File

@ -57,6 +57,11 @@ TEST(utils_path, constants) {
EXPECT_EQ(std::wstring_view{L"./"}, utils::path::dot_slash_w);
EXPECT_EQ(std::string_view{"/"}, utils::path::slash);
EXPECT_EQ(std::wstring_view{L"/"}, utils::path::slash_w);
#if defined(_WIN32)
EXPECT_EQ(std::string_view{"\\\\"}, utils::path::unc_notation);
EXPECT_EQ(std::wstring_view{L"\\\\"}, utils::path::unc_notation_w);
#endif // defined(_WIN32)
}
TEST(utils_path, directory_seperator) {
@ -171,6 +176,9 @@ TEST(utils_path, combine) {
s = utils::path::combine("R:", {"\\"});
EXPECT_STREQ(test_path("r:").c_str(), s.c_str());
s = utils::path::combine("\\\\moose", {"cow"});
EXPECT_STREQ("\\\\moose\\cow", s.c_str());
#endif
}
@ -276,14 +284,14 @@ TEST(utils_path, finalize) {
s = utils::path::finalize(R"(\\)");
#if defined(_WIN32)
EXPECT_STREQ(test_path(R"(\)").c_str(), s.c_str());
EXPECT_STREQ("\\\\", s.c_str());
#else
EXPECT_STREQ("/", s.c_str());
#endif
s = utils::path::finalize("//");
#if defined(_WIN32)
EXPECT_STREQ(test_path(R"(\)").c_str(), s.c_str());
EXPECT_STREQ("\\\\", s.c_str());
#else
EXPECT_STREQ("/", s.c_str());
#endif
@ -330,6 +338,18 @@ TEST(utils_path, finalize) {
s = utils::path::finalize("D:/moose/");
EXPECT_STREQ(test_path("d:\\moose").c_str(), s.c_str());
s = utils::path::finalize("\\\\moose\\cow");
EXPECT_STREQ("\\\\moose\\cow", s.c_str());
s = utils::path::finalize("//moose/cow");
EXPECT_STREQ("\\\\moose\\cow", s.c_str());
#else // !defined(_WIN32)
s = utils::path::finalize("\\\\moose\\cow");
EXPECT_STREQ("/moose/cow", s.c_str());
s = utils::path::finalize("//moose/cow");
EXPECT_STREQ("/moose/cow", s.c_str());
#endif // defined(_WIN32)
}
@ -351,6 +371,12 @@ TEST(utils_path, absolute) {
path = utils::path::absolute(R"(./moose)");
EXPECT_STREQ((dir + R"(\moose)").c_str(), path.c_str());
path = utils::path::absolute(R"(\\server\share)");
EXPECT_STREQ(R"(\\server\share)", path.c_str());
path = utils::path::absolute(R"(//server/share)");
EXPECT_STREQ(R"(\\server\share)", path.c_str());
auto home_env = utils::get_environment_variable("USERPROFILE");
#else // !defined(_WIN32)
path = utils::path::absolute(R"(.\moose)");
@ -359,6 +385,9 @@ TEST(utils_path, absolute) {
path = utils::path::absolute(R"(./moose)");
EXPECT_STREQ((dir + R"(/moose)").c_str(), path.c_str());
path = utils::path::absolute(R"(\\server\share)");
EXPECT_STREQ(R"(/server/share)", path.c_str());
auto home_env = utils::get_environment_variable("HOME");
#endif // defined(_WIN32)
auto home = utils::path::absolute(home_env);