updated build system

This commit is contained in:
2024-10-17 11:18:08 -05:00
parent 0bd7070ec5
commit d192904f8c
42 changed files with 975 additions and 1670 deletions

View File

@ -153,9 +153,7 @@ auto get_next_available_port(std::uint16_t first_port,
auto retry_action(retryable_action_t action, std::size_t retry_count,
std::chrono::milliseconds retry_wait) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
for (std::size_t idx = 0U; idx < retry_count; ++idx) {

View File

@ -352,9 +352,7 @@ auto encrypting_reader::create_iostream() const
auto encrypting_reader::reader_function(char *buffer, size_t size,
size_t nitems) -> size_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
const auto read_size = static_cast<std::size_t>(std::min(
static_cast<std::uint64_t>(size * nitems), total_size_ - read_offset_));

View File

@ -32,9 +32,7 @@
namespace repertory::utils::file {
auto change_to_process_directory() -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
#if defined(_WIN32)
@ -100,9 +98,7 @@ auto create_temp_name(std::wstring_view file_part) -> std::wstring {
auto get_free_drive_space(std::string_view path)
-> std::optional<std::uint64_t> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
#if defined(_WIN32)
@ -168,9 +164,7 @@ auto get_time(std::wstring_view path,
}
auto get_times(std::string_view path) -> std::optional<file_times> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
file_times ret{};
@ -244,9 +238,7 @@ auto get_times(std::wstring_view path) -> std::optional<file_times> {
auto get_total_drive_space(std::string_view path)
-> std::optional<std::uint64_t> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
#if defined(_WIN32)
@ -337,9 +329,7 @@ auto read_json_file(std::string_view path, nlohmann::json &data,
#else // !defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
auto read_json_file(std::string_view path, nlohmann::json &data) -> bool {
#endif // defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
auto abs_path = utils::path::absolute(path);
@ -395,9 +385,7 @@ auto write_json_file(std::string_view path, const nlohmann::json &data,
auto write_json_file(std::string_view path,
const nlohmann::json &data) -> bool {
#endif // defined(PROJECT_ENABLE_LIBSODIUM) && defined(PROJECT_ENABLE_BOOST)
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
auto file = file::open_or_create_file(path);

View File

@ -96,9 +96,7 @@ auto traverse_directory(
namespace repertory::utils::file {
auto directory::copy_to(std::string_view new_path,
bool overwrite) const -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
throw std::runtime_error("failed to copy directory|" + path_ + '|' +
@ -114,9 +112,7 @@ auto directory::copy_to(std::string_view new_path,
}
auto directory::count(bool recursive) const -> std::uint64_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
std::uint64_t ret{0U};
@ -149,9 +145,7 @@ auto directory::count(bool recursive) const -> std::uint64_t {
auto directory::create_directory(std::string_view path) const
-> fs_directory_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
auto abs_path = utils::path::combine(path_, {path});
@ -208,9 +202,7 @@ auto directory::exists() const -> bool {
}
auto directory::get_directory(std::string_view path) const -> fs_directory_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
auto dir_path = utils::path::combine(path_, {path});
@ -229,9 +221,7 @@ auto directory::get_directory(std::string_view path) const -> fs_directory_t {
}
auto directory::get_directories() const -> std::vector<fs_directory_t> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
std::vector<fs_directory_t> ret{};
@ -259,9 +249,7 @@ auto directory::get_directories() const -> std::vector<fs_directory_t> {
auto directory::create_file(std::string_view file_name,
bool read_only) const -> fs_file_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
auto file_path = utils::path::combine(path_, {file_name});
@ -276,9 +264,7 @@ auto directory::create_file(std::string_view file_name,
}
auto directory::get_file(std::string_view path) const -> fs_file_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
auto file_path = utils::path::combine(path_, {path});
@ -295,9 +281,7 @@ auto directory::get_file(std::string_view path) const -> fs_file_t {
}
auto directory::get_files() const -> std::vector<fs_file_t> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
std::vector<fs_file_t> ret{};
@ -323,9 +307,7 @@ auto directory::get_files() const -> std::vector<fs_file_t> {
}
auto directory::get_items() const -> std::vector<fs_item_t> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
std::vector<fs_item_t> ret{};
@ -361,9 +343,7 @@ auto directory::is_stop_requested() const -> bool {
}
auto directory::is_symlink() const -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
return std::filesystem::is_symlink(path_);
@ -377,9 +357,7 @@ auto directory::is_symlink() const -> bool {
}
auto directory::move_to(std::string_view new_path) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
throw std::runtime_error("failed to move directory|" + path_ + '|' +
@ -394,9 +372,7 @@ auto directory::move_to(std::string_view new_path) -> bool {
}
auto directory::remove() -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
if (not exists()) {
return true;
@ -420,9 +396,7 @@ auto directory::remove() -> bool {
}
auto directory::remove_recursively() -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not exists()) {
@ -448,9 +422,7 @@ auto directory::remove_recursively() -> bool {
}
auto directory::size(bool recursive) const -> std::uint64_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
std::uint64_t ret{0U};

View File

@ -64,9 +64,7 @@ namespace {
namespace repertory::utils::file {
// auto file::attach_file(native_handle handle,
// bool read_only) -> fs_file_t {
// static constexpr const std::string_view function_name{
// static_cast<const char *>(__FUNCTION__),
// };
// REPERTORY_USES_FUNCTION_NAME();
//
// try {
// std::string path;
@ -132,9 +130,7 @@ void file::open() {
}
auto file::open_file(std::string_view path, bool read_only) -> fs_file_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
auto *ptr = new file{
nullptr,
@ -188,9 +184,7 @@ auto file::open_or_create_file(std::string_view path, bool read_only)
void file::close() { file_.reset(); }
auto file::copy_to(std::string_view new_path, bool overwrite) const -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
auto to_path = utils::path::absolute(new_path);
@ -238,9 +232,7 @@ auto file::get_handle() const -> native_handle {
}
auto file::is_symlink() const -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
return std::filesystem::is_symlink(path_);
@ -254,9 +246,7 @@ auto file::is_symlink() const -> bool {
}
auto file::move_to(std::string_view path) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
auto abs_path = utils::path::absolute(path);
@ -296,9 +286,7 @@ auto file::move_to(std::string_view path) -> bool {
auto file::read(unsigned char *data, std::size_t to_read, std::uint64_t offset,
std::size_t *total_read) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
if (total_read != nullptr) {
(*total_read) = 0U;
@ -345,9 +333,7 @@ auto file::read(unsigned char *data, std::size_t to_read, std::uint64_t offset,
#if defined(PROJECT_ENABLE_LIBSODIUM)
auto file::sha256() -> std::optional<std::string> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
auto should_close{false};
auto read_only{read_only_};
@ -428,9 +414,7 @@ auto file::remove() -> bool {
}
auto file::truncate(std::size_t size) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
auto reopen{false};
if (file_) {
@ -460,9 +444,7 @@ auto file::truncate(std::size_t size) -> bool {
auto file::write(const unsigned char *data, std::size_t to_write,
std::size_t offset, std::size_t *total_written) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
if (total_written != nullptr) {
(*total_written) = 0U;
@ -510,9 +492,7 @@ auto file::write(const unsigned char *data, std::size_t to_write,
}
auto file::size() const -> std::optional<std::uint64_t> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (file_) {

View File

@ -30,9 +30,7 @@ namespace repertory::utils::file {
auto smb_directory::open(std::string_view host, std::string_view user,
std::string_view password, std::string_view path,
stop_type *stop_requested) -> smb_directory_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
smb_session_t session{
@ -113,9 +111,7 @@ auto smb_directory::open(std::wstring_view host, std::wstring_view user,
auto smb_directory::copy_to(std::string_view new_path,
bool overwrite) const -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -136,9 +132,7 @@ auto smb_directory::copy_to(std::string_view new_path,
}
auto smb_directory::count(bool recursive) const -> std::uint64_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -168,9 +162,7 @@ auto smb_directory::count(bool recursive) const -> std::uint64_t {
auto smb_directory::create_directory(std::string_view path) const
-> fs_directory_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -202,9 +194,7 @@ auto smb_directory::create_directory(std::string_view path) const
auto smb_directory::create_file(std::string_view file_name,
bool read_only) const -> fs_file_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -249,9 +239,7 @@ auto smb_directory::create_file(std::string_view file_name,
return nullptr;
}
auto smb_directory::exists() const -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -279,9 +267,7 @@ auto smb_directory::exists() const -> bool {
auto smb_directory::get_directory(std::string_view path) const
-> fs_directory_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -321,9 +307,7 @@ auto smb_directory::get_directory(std::string_view path) const
}
auto smb_directory::get_directories() const -> std::vector<fs_directory_t> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -382,9 +366,7 @@ auto smb_directory::get_directories() const -> std::vector<fs_directory_t> {
}
auto smb_directory::get_file(std::string_view path) const -> fs_file_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -418,9 +400,7 @@ auto smb_directory::get_file(std::string_view path) const -> fs_file_t {
}
auto smb_directory::get_files() const -> std::vector<fs_file_t> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -469,9 +449,7 @@ auto smb_directory::get_files() const -> std::vector<fs_file_t> {
}
auto smb_directory::get_items() const -> std::vector<fs_item_t> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -548,9 +526,7 @@ auto smb_directory::is_stop_requested() const -> bool {
}
auto smb_directory::is_symlink() const -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -567,9 +543,7 @@ auto smb_directory::is_symlink() const -> bool {
}
auto smb_directory::move_to(std::string_view new_path) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -588,9 +562,7 @@ auto smb_directory::move_to(std::string_view new_path) -> bool {
}
auto smb_directory::remove() -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -629,9 +601,7 @@ auto smb_directory::remove() -> bool {
}
auto smb_directory::remove_recursively() -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -654,9 +624,7 @@ auto smb_directory::remove_recursively() -> bool {
}
auto smb_directory::size(bool /* recursive */) const -> std::uint64_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {

View File

@ -37,9 +37,7 @@ void smb_file::close() {
auto smb_file::copy_to(std::string_view new_path,
bool overwrite) const -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -61,9 +59,7 @@ auto smb_file::copy_to(std::string_view new_path,
}
auto smb_file::exists() const -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -90,9 +86,7 @@ auto smb_file::exists() const -> bool {
}
void smb_file::flush() const {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
throw std::runtime_error("failed to flush file|" + path_ +
@ -106,9 +100,7 @@ void smb_file::flush() const {
auto smb_file::get_time(smb_session *session, smb_tid tid, std::string path,
time_type type) -> std::optional<std::uint64_t> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (session == nullptr) {
@ -147,9 +139,7 @@ auto smb_file::get_time(smb_session *session, smb_tid tid, std::string path,
}
auto smb_file::is_symlink() const -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -166,9 +156,7 @@ auto smb_file::is_symlink() const -> bool {
}
auto smb_file::move_to(std::string_view new_path) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (utils::string::begins_with(new_path, "//")) {
@ -218,9 +206,7 @@ auto smb_file::move_to(std::string_view new_path) -> bool {
}
auto smb_file::open(bool read_only) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (fd_.has_value()) {
@ -263,9 +249,7 @@ auto smb_file::open(bool read_only) -> bool {
auto smb_file::read(unsigned char *data, std::size_t to_read,
std::uint64_t offset, std::size_t *total_read) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (total_read != nullptr) {
@ -317,9 +301,7 @@ auto smb_file::read(unsigned char *data, std::size_t to_read,
}
auto smb_file::remove() -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not exists()) {
@ -364,9 +346,7 @@ auto smb_file::remove() -> bool {
}
auto smb_file::size() const -> std::optional<std::uint64_t> {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (not session_) {
@ -393,9 +373,7 @@ auto smb_file::size() const -> std::optional<std::uint64_t> {
}
auto smb_file::truncate(std::size_t size) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
throw std::runtime_error("failed to truncate file|" + path_ + '|' +
@ -411,9 +389,7 @@ auto smb_file::truncate(std::size_t size) -> bool {
auto smb_file::write(const unsigned char *data, std::size_t to_write,
std::size_t offset, std::size_t *total_written) -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
try {
if (total_written != nullptr) {

View File

@ -56,9 +56,7 @@ auto is_uid_member_of_group(const uid_t &uid, const gid_t &gid) -> bool {
}
auto use_getpwuid(uid_t uid, passwd_callback_t callback) -> result {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),
};
REPERTORY_USES_FUNCTION_NAME();
static std::mutex mtx{};
mutex_lock lock{mtx};