updated build system
Some checks are pending
BlockStorage/repertory/pipeline/head Build queued...

This commit is contained in:
2024-08-24 16:13:28 -05:00
parent 01f11884aa
commit ea3d69a2ee
9 changed files with 114 additions and 23 deletions

View File

@ -86,6 +86,11 @@ auto traverse_directory(
} // namespace
namespace repertory::utils::file {
auto directory::copy_to(std::string_view new_path,
bool overwrite) const -> bool {
return false;
}
auto directory::count(bool recursive) const -> std::uint64_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),

View File

@ -30,6 +30,9 @@ enc_file::enc_file(fs_file_t file) : file_(std::move(file)) {}
void enc_file::close() {}
auto enc_file::copy_to(std::string_view new_path,
bool overwrite) const -> bool {}
void enc_file::flush() const {}
auto enc_file::move_to(std::string_view path) -> bool {}

View File

@ -23,11 +23,8 @@
#include "utils/collection.hpp"
#include "utils/common.hpp"
#include "utils/encryption.hpp"
#include "utils/error.hpp"
#include "utils/path.hpp"
#include "utils/string.hpp"
#include "utils/time.hpp"
namespace {
[[nodiscard]] auto get_file_size(std::string_view path,
@ -190,6 +187,35 @@ 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__),
};
try {
auto to_path = utils::path::absolute(new_path);
if (directory(to_path).exists()) {
return false;
}
#if defined(_WIN32)
return ::CopyFileA(path_.c_str(), to_path.c_str(),
overwrite ? TRUE : FALSE);
#else // !defined(_WIN32)
return std::filesystem::copy_file(
path_, to_path,
overwrite ? std::filesystem::copy_options::overwrite_existing
: std::filesystem::copy_options::skip_existing);
#endif // defined(_WIN32)
} catch (const std::exception &e) {
utils::error::handle_exception(function_name, e);
} catch (...) {
utils::error::handle_exception(function_name);
}
return false;
}
auto file::exists() const -> bool {
#if defined(_WIN32)
recur_mutex_lock lock{*mtx_};

View File

@ -102,6 +102,30 @@ auto smb_directory::open(std::wstring_view host, std::wstring_view user,
utils::string::to_utf8(share_name));
}
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__),
};
try {
if (not session_) {
throw std::runtime_error("session not found|" + path_);
}
// auto to_path = utils::path::absolute(new_path);
throw std::runtime_error("failed to copy directory|" + path_ + '|' +
std::string{new_path} + "|not implemented");
} catch (const std::exception &e) {
utils::error::handle_exception(function_name, e);
} catch (...) {
utils::error::handle_exception(function_name);
}
return false;
}
auto smb_directory::count(bool recursive) const -> std::uint64_t {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),

View File

@ -35,6 +35,30 @@ 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__),
};
try {
if (not session_) {
throw std::runtime_error("session not found|" + path_);
}
// auto to_path = utils::path::absolute(new_path);
throw std::runtime_error("failed to copy file|" + path_ + '|' +
std::string{new_path} + "|not implemented");
} catch (const std::exception &e) {
utils::error::handle_exception(function_name, e);
} catch (...) {
utils::error::handle_exception(function_name);
}
return false;
}
auto smb_file::exists() const -> bool {
static constexpr const std::string_view function_name{
static_cast<const char *>(__FUNCTION__),

View File

@ -37,6 +37,9 @@ thread_file::thread_file(fs_file_t file) : file_(std::move(file)) {}
void thread_file::close() {}
auto thread_file::copy_to(std::string_view new_path,
bool overwrite) const -> bool {}
void thread_file::flush() const {}
auto thread_file::move_to(std::string_view path) -> bool {}