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

This commit is contained in:
2024-08-20 15:02:13 -05:00
parent aa9c7d1ec1
commit 1236bf1829
9 changed files with 369 additions and 41 deletions

View File

@ -21,51 +21,32 @@
*/
#include "utils/error.hpp"
namespace {
struct default_exception_handler final
: repertory::utils::error::i_exception_handler {
void handle_exception(std::string_view function_name) const override {
std::cerr << function_name << "|exception|unknown" << std::endl;
}
void handle_exception(std::string_view function_name,
const std::exception &ex) const override {
std::cerr << function_name << "|exception|"
<< (ex.what() == nullptr ? "unknown" : ex.what()) << std::endl;
}
};
static default_exception_handler default_handler{};
static std::atomic<repertory::utils::error::i_exception_handler *>
exception_handler{
&default_handler,
};
} // namespace
namespace repertory::utils::error {
std::atomic<const i_exception_handler *> exception_handler{
&default_exception_handler};
void handle_exception(std::string_view function_name) {
i_exception_handler *handler{exception_handler};
const i_exception_handler *handler{exception_handler};
if (handler != nullptr) {
handler->handle_exception(function_name);
return;
}
default_handler.handle_exception(function_name);
default_exception_handler.handle_exception(function_name);
}
void handle_exception(std::string_view function_name,
const std::exception &ex) {
i_exception_handler *handler{exception_handler};
const i_exception_handler *handler{exception_handler};
if (handler != nullptr) {
handler->handle_exception(function_name, ex);
return;
}
default_handler.handle_exception(function_name, ex);
default_exception_handler.handle_exception(function_name, ex);
}
void set_exception_handler(i_exception_handler *handler) {
void set_exception_handler(const i_exception_handler *handler) {
exception_handler = handler;
}
} // namespace repertory::utils::error

View File

@ -0,0 +1,52 @@
/*
Copyright <2018-2024> <scott.e.graves@protonmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "utils/file.hpp"
#if defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
namespace repertory::utils::file {
auto enc_file::attach_file(fs_file_t file) -> fs_file_t {}
enc_file::enc_file(fs_file_t file) : file_(std::move(file)) {}
void enc_file::close() {}
void enc_file::flush() const {}
auto enc_file::get_time(time_types type) const -> std::uint64_t {}
auto enc_file::move_to(std::string_view path) -> bool {}
auto enc_file::read(unsigned char *data, std::size_t to_read,
std::uint64_t offset, std::size_t *total_read) -> bool {}
auto enc_file::remove() -> bool {}
auto enc_file::truncate(std::size_t size) -> bool {}
auto enc_file::write(const unsigned char *data, std::size_t to_write,
std::size_t offset, std::size_t *total_written) -> bool {}
auto enc_file::size() const -> std::uint64_t {}
} // namespace repertory::utils::file
#endif // defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)

View File

@ -182,17 +182,18 @@ auto get_parent_directory(std::wstring_view path) -> std::wstring {
get_parent_directory(utils::string::to_utf8(path)));
}
auto is_trash_directory(std::string_view path) -> bool {
std::string dir_sep_t{get_directory_seperator<char>()};
auto contains_trash_directory(std::string_view path) -> bool {
auto parts = utils::string::split(utils::string::to_lower(absolute(path)),
get_directory_seperator<char>(), false);
auto trash_path = utils::string::to_lower(absolute(path));
return utils::string::begins_with(trash_path, dir_sep_t + ".trash-") ||
utils::string::begins_with(trash_path, dir_sep_t + ".trashes") ||
utils::string::begins_with(trash_path, dir_sep_t + "$recycle.bin");
return std::find_if(parts.begin(), parts.end(), [](auto &&part) -> bool {
return utils::string::begins_with(part, ".trash-") ||
part == ".trashes" || part == "$recycle.bin";
}) != parts.end();
}
auto is_trash_directory(std::wstring_view path) -> bool {
return is_trash_directory(utils::string::to_utf8(path));
auto contains_trash_directory(std::wstring_view path) -> bool {
return contains_trash_directory(utils::string::to_utf8(path));
}
auto make_file_uri(std::string_view path) -> std::string {

View File

@ -97,7 +97,7 @@ auto time64_to_unix_time(const __time64_t &time) -> std::uint64_t {
// https://www.frenk.com/2009/12/convert-filetime-to-unix-timestamp/
auto unix_time_to_filetime(std::uint64_t unix_time) -> FILETIME {
const auto win_time = (unix_time / 100ULL) + 116444736000000000ULL;
auto win_time = (unix_time / 100ULL) + 116444736000000000ULL;
FILETIME file_time{};
file_time.dwHighDateTime = static_cast<DWORD>(win_time >> 32U);
file_time.dwLowDateTime = win_time & 0xFFFFFFFF;