updated build system
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2024-10-19 15:58:51 -05:00
parent 8feb244dc9
commit cf6a370eea

View File

@ -121,6 +121,7 @@ auto get_free_drive_space(std::string_view path)
});
return li.QuadPart;
}
#endif // defined(_WIN32)
#if defined(__linux__)
@ -150,23 +151,21 @@ auto get_free_drive_space(std::string_view path)
return st.f_bfree * static_cast<std::uint64_t>(st.f_frsize);
#endif // defined(__APPLE__)
}
catch (const std::exception &e) {
} catch (const std::exception &e) {
utils::error::handle_exception(function_name, e);
}
catch (...) {
} catch (...) {
utils::error::handle_exception(function_name);
}
return std::nullopt;
}
}
auto get_free_drive_space(
std::wstring_view path) -> std::optional<std::uint64_t> {
auto get_free_drive_space(std::wstring_view path)
-> std::optional<std::uint64_t> {
return get_free_drive_space(utils::string::to_utf8(path));
}
}
auto get_time(std::string_view path,
auto get_time(std::string_view path,
time_type type) -> std::optional<std::uint64_t> {
auto times = get_times(path);
if (times.has_value()) {
@ -174,14 +173,14 @@ auto get_free_drive_space(std::string_view path)
}
return std::nullopt;
}
}
auto get_time(std::wstring_view path,
auto get_time(std::wstring_view path,
time_type type) -> std::optional<std::uint64_t> {
return get_time(utils::string::to_utf8(path), type);
}
}
auto get_times(std::string_view path) -> std::optional<file_times> {
auto get_times(std::string_view path) -> std::optional<file_times> {
REPERTORY_USES_FUNCTION_NAME();
try {
@ -200,12 +199,10 @@ auto get_free_drive_space(std::string_view path)
if (res) {
ret.accessed =
utils::time::windows_file_time_to_unix_time(times.at(1U));
ret.created =
utils::time::windows_file_time_to_unix_time(times.at(0U));
ret.created = utils::time::windows_file_time_to_unix_time(times.at(0U));
ret.modified =
utils::time::windows_file_time_to_unix_time(times.at(2U));
ret.written =
utils::time::windows_file_time_to_unix_time(times.at(2U));
ret.written = utils::time::windows_file_time_to_unix_time(times.at(2U));
return ret;
}
}
@ -258,14 +255,14 @@ auto get_free_drive_space(std::string_view path)
}
return std::nullopt;
}
}
auto get_times(std::wstring_view path) -> std::optional<file_times> {
auto get_times(std::wstring_view path) -> std::optional<file_times> {
return get_times(utils::string::to_utf8(path));
}
}
auto get_total_drive_space(
std::string_view path) -> std::optional<std::uint64_t> {
auto get_total_drive_space(std::string_view path)
-> std::optional<std::uint64_t> {
REPERTORY_USES_FUNCTION_NAME();
try {
@ -318,20 +315,19 @@ auto get_free_drive_space(std::string_view path)
}
return std::nullopt;
}
}
auto get_total_drive_space(
std::wstring_view path) -> std::optional<std::uint64_t> {
auto get_total_drive_space(std::wstring_view path)
-> std::optional<std::uint64_t> {
return get_total_drive_space(utils::string::to_utf8(path));
}
}
auto i_fs_item::get_time(time_type type)
const -> std::optional<std::uint64_t> {
auto i_fs_item::get_time(time_type type) const -> std::optional<std::uint64_t> {
return utils::file::get_time(get_path(), type);
}
}
auto i_file::read_all(data_buffer & data, std::uint64_t offset,
std::size_t * total_read) -> bool {
auto i_file::read_all(data_buffer &data, std::uint64_t offset,
std::size_t *total_read) -> bool {
data_buffer buffer;
buffer.resize(get_read_buffer_size());
@ -358,14 +354,14 @@ auto get_free_drive_space(std::string_view path)
}
return false;
}
}
#if defined(PROJECT_ENABLE_JSON)
#if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
auto read_json_file(std::string_view path, nlohmann::json & data,
auto read_json_file(std::string_view path, nlohmann::json &data,
std::optional<std::string_view> password) -> bool {
#else // !defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
auto read_json_file(std::string_view path, nlohmann::json & data) -> bool {
auto read_json_file(std::string_view path, nlohmann::json &data) -> bool {
#endif // defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
REPERTORY_USES_FUNCTION_NAME();
@ -414,13 +410,13 @@ auto get_free_drive_space(std::string_view path)
}
return false;
}
}
#if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
auto write_json_file(std::string_view path, const nlohmann::json &data,
auto write_json_file(std::string_view path, const nlohmann::json &data,
std::optional<std::string_view> password) -> bool {
#else // !defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
auto write_json_file(std::string_view path,
auto write_json_file(std::string_view path,
const nlohmann::json &data) -> bool {
#endif // defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
REPERTORY_USES_FUNCTION_NAME();
@ -442,8 +438,7 @@ auto get_free_drive_space(std::string_view path)
data_buffer encrypted_data{};
utils::encryption::encrypt_data(
*password,
reinterpret_cast<const unsigned char *>(str_data.c_str()),
*password, reinterpret_cast<const unsigned char *>(str_data.c_str()),
str_data.size(), encrypted_data);
return file->write(encrypted_data, 0U);
}
@ -460,10 +455,10 @@ auto get_free_drive_space(std::string_view path)
}
return false;
}
}
#if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
auto read_json_file(std::wstring_view path, nlohmann::json & data,
auto read_json_file(std::wstring_view path, nlohmann::json &data,
std::optional<std::wstring_view> password) -> bool {
if (password.has_value()) {
auto password_a = utils::string::to_utf8(*password);
@ -471,9 +466,9 @@ auto get_free_drive_space(std::string_view path)
}
return read_json_file(utils::string::to_utf8(path), data, std::nullopt);
}
}
auto write_json_file(std::wstring_view path, const nlohmann::json &data,
auto write_json_file(std::wstring_view path, const nlohmann::json &data,
std::optional<std::wstring_view> password) -> bool {
if (password.has_value()) {
auto password_a = utils::string::to_utf8(*password);
@ -481,29 +476,29 @@ auto get_free_drive_space(std::string_view path)
}
return write_json_file(utils::string::to_utf8(path), data, std::nullopt);
}
}
#else // !defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
auto read_json_file(std::wstring_view path, nlohmann::json & data) -> bool {
auto read_json_file(std::wstring_view path, nlohmann::json &data) -> bool {
return read_json_file(utils::string::to_utf8(path), data);
}
}
auto write_json_file(std::wstring_view path,
auto write_json_file(std::wstring_view path,
const nlohmann::json &data) -> bool {
return write_json_file(utils::string::to_utf8(path), data);
}
}
#endif // defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
#endif // defined(PROJECT_ENABLE_JSON)
#if defined(PROJECT_ENABLE_LIBDSM)
static constexpr const auto validate_smb_path =
static constexpr const auto validate_smb_path =
[](std::string_view path) -> bool {
return (not utils::string::begins_with(path, "///") &&
utils::string::begins_with(path, "//") &&
// not utils::string::contains(path, " ") &&
std::count(path.begin(), path.end(), '/') >= 3U);
};
};
auto smb_create_smb_path(std::string_view smb_path,
auto smb_create_smb_path(std::string_view smb_path,
std::string_view rel_path) -> std::string {
REPERTORY_USES_FUNCTION_NAME();
@ -537,9 +532,9 @@ auto get_free_drive_space(std::string_view path)
}
return path;
}
}
auto smb_create_and_validate_relative_path(
auto smb_create_and_validate_relative_path(
std::string_view smb_path, std::string_view path) -> std::string {
REPERTORY_USES_FUNCTION_NAME();
@ -568,9 +563,9 @@ auto get_free_drive_space(std::string_view path)
return utils::file::smb_create_relative_path(std::string{smb_path} + '/' +
std::string{path});
}
}
auto smb_create_relative_path(std::string_view smb_path) -> std::string {
auto smb_create_relative_path(std::string_view smb_path) -> std::string {
REPERTORY_USES_FUNCTION_NAME();
if (not validate_smb_path(smb_path)) {
@ -588,9 +583,9 @@ auto get_free_drive_space(std::string_view path)
auto parts = repertory::utils::string::split(path, '\\', false);
parts.erase(parts.begin(), std::next(parts.begin(), 2U));
return "\\" + utils::string::join(parts, '\\');
}
}
auto smb_create_search_path(std::string_view smb_path) -> std::string {
auto smb_create_search_path(std::string_view smb_path) -> std::string {
REPERTORY_USES_FUNCTION_NAME();
if (not validate_smb_path(smb_path)) {
@ -609,9 +604,9 @@ auto get_free_drive_space(std::string_view path)
auto search_path = repertory::utils::string::join(parts, '\\');
return search_path.empty() ? "\\*" : "\\" + search_path + "\\*";
}
}
auto smb_get_parent_path(std::string_view smb_path) -> std::string {
auto smb_get_parent_path(std::string_view smb_path) -> std::string {
REPERTORY_USES_FUNCTION_NAME();
if (not validate_smb_path(smb_path)) {
@ -622,8 +617,7 @@ auto get_free_drive_space(std::string_view path)
});
}
auto parts =
repertory::utils::string::split(smb_path.substr(2U), '/', false);
auto parts = repertory::utils::string::split(smb_path.substr(2U), '/', false);
if (parts.size() > 2U) {
parts.erase(std::prev(parts.end()), parts.end());
}
@ -638,9 +632,9 @@ auto get_free_drive_space(std::string_view path)
}
return parent_smb_path;
}
}
auto smb_get_root_path(std::string_view smb_path) -> std::string {
auto smb_get_root_path(std::string_view smb_path) -> std::string {
REPERTORY_USES_FUNCTION_NAME();
if (not validate_smb_path(smb_path)) {
@ -651,16 +645,15 @@ auto get_free_drive_space(std::string_view path)
});
}
auto parts =
repertory::utils::string::split(smb_path.substr(2U), '/', false);
auto parts = repertory::utils::string::split(smb_path.substr(2U), '/', false);
if (parts.size() > 2U) {
parts.erase(std::next(parts.begin(), 2U), parts.end());
}
return "//" + utils::string::join(parts, '/');
}
}
auto smb_get_unc_path(std::string_view smb_path) -> std::string {
auto smb_get_unc_path(std::string_view smb_path) -> std::string {
REPERTORY_USES_FUNCTION_NAME();
if (not validate_smb_path(smb_path)) {
@ -674,9 +667,9 @@ auto get_free_drive_space(std::string_view path)
std::string unc_path{smb_path};
utils::path::format_path(unc_path, "\\", "/");
return '\\' + unc_path;
}
}
auto smb_get_uri_path(std::string_view smb_path) -> std::string {
auto smb_get_uri_path(std::string_view smb_path) -> std::string {
REPERTORY_USES_FUNCTION_NAME();
if (not validate_smb_path(smb_path)) {
@ -688,9 +681,9 @@ auto get_free_drive_space(std::string_view path)
}
return "smb:" + std::string{smb_path};
}
}
auto smb_get_uri_path(std::string_view smb_path, std::string_view user,
auto smb_get_uri_path(std::string_view smb_path, std::string_view user,
std::string_view password) -> std::string {
REPERTORY_USES_FUNCTION_NAME();
@ -704,9 +697,9 @@ auto get_free_drive_space(std::string_view path)
return "smb://" + std::string{user} + ':' + std::string{password} + '@' +
std::string{smb_path.substr(2U)};
}
}
auto smb_parent_is_same(std::string_view smb_path1,
auto smb_parent_is_same(std::string_view smb_path1,
std::string_view smb_path2) -> bool {
if (not(validate_smb_path(smb_path1) && validate_smb_path(smb_path2))) {
return false;
@ -724,6 +717,6 @@ auto get_free_drive_space(std::string_view path)
return std::equal(parts1.begin(), std::next(parts1.begin(), 2U),
parts2.begin());
}
}
#endif // defined(PROJECT_ENABLE_LIBDSM)
} // namespace repertory::utils::file