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

This commit is contained in:
2024-10-20 12:01:23 -05:00
parent 104e101158
commit 1f6036ec18
17 changed files with 696 additions and 705 deletions

View File

@ -41,23 +41,23 @@ auto smb_file::copy_to(std::string_view new_path,
try {
if (not session_) {
throw utils::error::create_exception({
function_name,
"session not found",
path_,
});
throw utils::error::create_exception(function_name,
{
"session not found",
path_,
});
}
// auto to_path = utils::path::absolute(new_path);
throw utils::error::create_exception({
function_name,
"failed to copy file",
"not implemented",
std::to_string(overwrite),
new_path,
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to copy file",
"not implemented",
std::to_string(overwrite),
new_path,
path_,
});
} catch (const std::exception &e) {
utils::error::handle_exception(function_name, e);
} catch (...) {
@ -72,11 +72,11 @@ auto smb_file::exists() const -> bool {
try {
if (not session_) {
throw utils::error::create_exception({
function_name,
"session not found",
path_,
});
throw utils::error::create_exception(function_name,
{
"session not found",
path_,
});
}
smb_stat_t st{
@ -102,12 +102,12 @@ void smb_file::flush() const {
REPERTORY_USES_FUNCTION_NAME();
try {
throw utils::error::create_exception({
function_name,
"failed to flush file",
"not implemented",
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to flush file",
"not implemented",
path_,
});
} catch (const std::exception &e) {
utils::error::handle_exception(function_name, e);
} catch (...) {
@ -121,11 +121,11 @@ auto smb_file::get_time(smb_session *session, smb_tid tid, std::string path,
try {
if (session == nullptr) {
throw utils::error::create_exception({
function_name,
"session not found",
path,
});
throw utils::error::create_exception(function_name,
{
"session not found",
path,
});
}
auto rel_path = smb_create_relative_path(path);
@ -134,13 +134,13 @@ auto smb_file::get_time(smb_session *session, smb_tid tid, std::string path,
smb_stat_deleter(),
};
if (not st) {
throw utils::error::create_exception({
function_name,
"failed to stat file",
"not implemented",
rel_path,
path,
});
throw utils::error::create_exception(function_name,
{
"failed to stat file",
"not implemented",
rel_path,
path,
});
}
switch (type) {
@ -170,11 +170,11 @@ auto smb_file::is_symlink() const -> bool {
try {
if (not session_) {
throw utils::error::create_exception({
function_name,
"session not found",
path_,
});
throw utils::error::create_exception(function_name,
{
"session not found",
path_,
});
}
} catch (const std::exception &e) {
@ -191,13 +191,13 @@ auto smb_file::move_to(std::string_view new_path) -> bool {
try {
if (utils::string::begins_with(new_path, "//")) {
throw utils::error::create_exception({
function_name,
"failed to move file",
"new path must be in same share",
new_path,
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to move file",
"new path must be in same share",
new_path,
path_,
});
}
auto from_path = smb_create_relative_path(path_);
@ -214,24 +214,24 @@ auto smb_file::move_to(std::string_view new_path) -> bool {
auto res = smb_tree_connect(session_.get(), share_name_.c_str(), &tid_);
if (res != DSM_SUCCESS) {
throw utils::error::create_exception({
function_name,
"failed to connect to share",
std::to_string(res),
share_name_,
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to connect to share",
std::to_string(res),
share_name_,
path_,
});
}
res = smb_file_mv(session_.get(), tid_, from_path.c_str(), to_path.c_str());
if (res != DSM_SUCCESS) {
throw utils::error::create_exception({
function_name,
"failed to move file",
std::to_string(res),
from_path,
to_path,
});
throw utils::error::create_exception(function_name,
{
"failed to move file",
std::to_string(res),
from_path,
to_path,
});
}
path_ = smb_create_smb_path(path_, to_path);
@ -265,27 +265,27 @@ auto smb_file::open(bool read_only) -> bool {
auto res = smb_tree_connect(session_.get(), share_name_.c_str(), &tid_);
if (res != DSM_SUCCESS) {
throw utils::error::create_exception({
function_name,
"failed to connect to share",
std::to_string(res),
share_name_,
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to connect to share",
std::to_string(res),
share_name_,
path_,
});
}
smb_fd fd{};
res = smb_fopen(session_.get(), tid_, rel_path.c_str(),
read_only ? SMB_MOD_RO : SMB_MOD_RW2, &fd);
if (res != DSM_SUCCESS) {
throw utils::error::create_exception({
function_name,
"failed to open file",
std::to_string(res),
utils::string::from_bool(read_only),
rel_path,
path_,
});
throw utils::error::create_exception(
function_name, {
"failed to open file",
std::to_string(res),
utils::string::from_bool(read_only),
rel_path,
path_,
});
}
fd_ = fd;
@ -311,24 +311,24 @@ auto smb_file::read(unsigned char *data, std::size_t to_read,
}
if (not fd_.has_value()) {
throw utils::error::create_exception({
function_name,
"failed to read file",
"file not open",
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to read file",
"file not open",
path_,
});
}
auto res = smb_fseek(session_.get(), *fd_, static_cast<off_t>(offset),
SMB_SEEK_SET);
if (res == -1) {
throw utils::error::create_exception({
function_name,
"failed to seek file",
std::to_string(res),
std::to_string(offset),
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to seek file",
std::to_string(res),
std::to_string(offset),
path_,
});
}
std::size_t bytes_read{0U};
@ -336,14 +336,14 @@ auto smb_file::read(unsigned char *data, std::size_t to_read,
res = smb_fread(session_.get(), *fd_, &data[bytes_read],
to_read - bytes_read);
if (res == -1) {
throw utils::error::create_exception({
function_name,
"failed to read file",
std::to_string(res),
std::to_string(offset),
std::to_string(to_read),
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to read file",
std::to_string(res),
std::to_string(offset),
std::to_string(to_read),
path_,
});
}
if (res == 0) {
@ -381,26 +381,27 @@ auto smb_file::remove() -> bool {
try {
auto res = smb_tree_connect(session_.get(), share_name_.c_str(), &tid_);
if (res != DSM_SUCCESS) {
throw utils::error::create_exception({
function_name,
"failed to connect to share",
std::to_string(res),
share_name_,
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to connect to share",
std::to_string(res),
share_name_,
path_,
});
}
auto rel_path = smb_create_relative_path(path_);
res = smb_file_rm(session_.get(), tid_, rel_path.c_str());
if (res != DSM_SUCCESS) {
throw utils::error::create_exception({
throw utils::error::create_exception(
function_name,
"failed to remove file",
std::to_string(res),
std::to_string(smb_session_get_nt_status(session_.get())),
rel_path,
path_,
});
{
"failed to remove file",
std::to_string(res),
std::to_string(smb_session_get_nt_status(session_.get())),
rel_path,
path_,
});
}
return true;
@ -426,11 +427,11 @@ auto smb_file::size() const -> std::optional<std::uint64_t> {
try {
if (not session_) {
throw utils::error::create_exception({
function_name,
"session not found",
path_,
});
throw utils::error::create_exception(function_name,
{
"session not found",
path_,
});
}
auto rel_path = smb_create_relative_path(path_);
@ -439,12 +440,12 @@ auto smb_file::size() const -> std::optional<std::uint64_t> {
smb_stat_deleter(),
};
if (not st) {
throw utils::error::create_exception({
function_name,
"failed to stat directory",
rel_path,
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to stat directory",
rel_path,
path_,
});
}
return smb_stat_get(st.get(), SMB_STAT_SIZE);
@ -461,13 +462,13 @@ auto smb_file::truncate(std::size_t size) -> bool {
REPERTORY_USES_FUNCTION_NAME();
try {
throw utils::error::create_exception({
function_name,
"failed to truncate file",
"not implemented",
std::to_string(size),
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to truncate file",
"not implemented",
std::to_string(size),
path_,
});
} catch (const std::exception &e) {
utils::error::handle_exception(function_name, e);
} catch (...) {
@ -487,24 +488,24 @@ auto smb_file::write(const unsigned char *data, std::size_t to_write,
}
if (not fd_.has_value()) {
throw utils::error::create_exception({
function_name,
"failed to write file",
"file not open",
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to write file",
"file not open",
path_,
});
}
auto res = smb_fseek(session_.get(), *fd_, static_cast<off_t>(offset),
SMB_SEEK_SET);
if (res == -1) {
throw utils::error::create_exception({
function_name,
"failed to seek file",
std::to_string(res),
std::to_string(offset),
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to seek file",
std::to_string(res),
std::to_string(offset),
path_,
});
}
std::size_t bytes_written{0U};
@ -513,14 +514,14 @@ auto smb_file::write(const unsigned char *data, std::size_t to_write,
const_cast<unsigned char *>(&data[bytes_written]),
to_write - bytes_written);
if (res == -1) {
throw utils::error::create_exception({
function_name,
"failed to write file",
std::to_string(res),
std::to_string(offset),
std::to_string(to_write),
path_,
});
throw utils::error::create_exception(function_name,
{
"failed to write file",
std::to_string(res),
std::to_string(offset),
std::to_string(to_write),
path_,
});
}
if (res == 0) {