updated build system
This commit is contained in:
@ -103,15 +103,15 @@ app_config::app_config(const provider_type &prov,
|
||||
hc_.api_password = get_provider_api_password(prov_);
|
||||
hc_.api_port = default_api_port(prov_);
|
||||
|
||||
if (not utils::file::create_directories(data_directory_)) {
|
||||
if (not utils::file::directory(data_directory_).create_directory()) {
|
||||
throw startup_exception("unable to create: " + data_directory_);
|
||||
}
|
||||
|
||||
if (not utils::file::create_directories(cache_directory_)) {
|
||||
if (not utils::file::directory(cache_directory_).create_directory()) {
|
||||
throw startup_exception("unable to create: " + cache_directory_);
|
||||
}
|
||||
|
||||
if (not utils::file::create_directories(log_directory_)) {
|
||||
if (not utils::file::directory(log_directory_).create_directory()) {
|
||||
throw startup_exception("unable to create: " + log_directory_);
|
||||
}
|
||||
|
||||
@ -547,7 +547,7 @@ auto app_config::load() -> bool {
|
||||
const auto config_file_path = get_config_file_path();
|
||||
std::cout << config_file_path << std::endl;
|
||||
recur_mutex_lock lock(read_write_mutex_);
|
||||
if (utils::file::is_file(config_file_path)) {
|
||||
if (utils::file::file(config_file_path).exists()) {
|
||||
try {
|
||||
std::ifstream config_file(config_file_path.data());
|
||||
if (config_file.is_open()) {
|
||||
@ -713,9 +713,9 @@ void app_config::save() {
|
||||
|
||||
const auto file_path = get_config_file_path();
|
||||
recur_mutex_lock lock(read_write_mutex_);
|
||||
if (config_changed_ || not utils::file::is_file(file_path)) {
|
||||
if (not utils::file::is_directory(data_directory_)) {
|
||||
if (not utils::file::create_directories(data_directory_)) {
|
||||
if (config_changed_ || not utils::file::file(file_path).exists()) {
|
||||
if (not utils::file::directory(data_directory_).exists()) {
|
||||
if (not utils::file::directory(data_directory_).create_directory()) {
|
||||
utils::error::raise_error(
|
||||
function_name, "failed to create directory|sp|" + data_directory_ +
|
||||
"|err|" +
|
||||
|
@ -38,14 +38,15 @@ auto eviction::check_minimum_requirements(const std::string &file_path)
|
||||
static_cast<const char *>(__FUNCTION__),
|
||||
};
|
||||
|
||||
std::uint64_t file_size{};
|
||||
if (not utils::file::get_file_size(file_path, file_size)) {
|
||||
auto opt_size = utils::file::file{file_path}.size();
|
||||
if (not opt_size.has_value()) {
|
||||
utils::error::raise_error(function_name, utils::get_last_error_code(),
|
||||
file_path, "failed to get file size");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto ret = false;
|
||||
auto file_size{opt_size.value()};
|
||||
auto ret{false};
|
||||
if (file_size != 0U) {
|
||||
std::uint64_t reference_time{};
|
||||
ret = config_.get_eviction_uses_accessed_time()
|
||||
@ -110,9 +111,9 @@ void eviction::service_function() {
|
||||
if (provider_.get_filesystem_item_and_file(api_path, file, fsi) ==
|
||||
api_error::success) {
|
||||
// Only evict files that match expected size
|
||||
std::uint64_t file_size{};
|
||||
if (utils::file::get_file_size(cached_files_list.front(),
|
||||
file_size)) {
|
||||
auto opt_size = utils::file::file{cached_files_list.front()}.size();
|
||||
if (opt_size.has_value()) {
|
||||
auto file_size{opt_size.value()};
|
||||
if (file_size == fsi.size) {
|
||||
// Try to evict file
|
||||
if (fm_.evict_file(fsi.api_path) &&
|
||||
|
@ -93,9 +93,10 @@ auto remote_server::populate_file_info(const std::string &api_path,
|
||||
auto error = drive_.get_item_meta(api_path, META_ATTRIBUTES, meta_attributes);
|
||||
if (error == api_error::success) {
|
||||
if (meta_attributes.empty()) {
|
||||
meta_attributes = utils::file::is_directory(construct_path(api_path))
|
||||
? std::to_string(FILE_ATTRIBUTE_DIRECTORY)
|
||||
: std::to_string(FILE_ATTRIBUTE_NORMAL);
|
||||
meta_attributes =
|
||||
utils::file::directory(construct_path(api_path)).exists()
|
||||
? std::to_string(FILE_ATTRIBUTE_DIRECTORY)
|
||||
: std::to_string(FILE_ATTRIBUTE_NORMAL);
|
||||
drive_.set_item_meta(api_path, META_ATTRIBUTES, meta_attributes);
|
||||
}
|
||||
const auto attributes = utils::string::to_uint32(meta_attributes);
|
||||
@ -324,7 +325,7 @@ auto remote_server::fuse_fgetattr(
|
||||
|
||||
auto res = has_open_info(static_cast<native_handle>(handle), EBADF);
|
||||
if (res == 0) {
|
||||
directory = utils::file::is_directory(file_path);
|
||||
directory = utils::file::directory(file_path).exists();
|
||||
struct stat64 unix_st {};
|
||||
res = fstat64(static_cast<native_handle>(handle), &unix_st);
|
||||
if (res == 0) {
|
||||
@ -488,7 +489,7 @@ auto remote_server::fuse_getattr(const char *path, remote::stat &r_stat,
|
||||
const auto parent_api_path = utils::path::get_parent_api_path(api_path);
|
||||
memset(&r_stat, 0, sizeof(remote::stat));
|
||||
|
||||
directory = utils::file::is_directory(file_path);
|
||||
directory = utils::file::directory(file_path).exists();
|
||||
|
||||
struct stat64 unix_st {};
|
||||
auto res = stat64(file_path.c_str(), &unix_st);
|
||||
@ -651,7 +652,7 @@ auto remote_server::fuse_opendir(const char *path, remote::file_handle &handle)
|
||||
auto res = -1;
|
||||
errno = ENOENT;
|
||||
|
||||
if (utils::file::is_directory(file_path)) {
|
||||
if (utils::file::directory(file_path).exists()) {
|
||||
auto iter = std::make_shared<directory_iterator>(
|
||||
drive_.get_directory_items(utils::path::create_api_path(path)));
|
||||
|
||||
@ -1065,7 +1066,7 @@ auto remote_server::winfsp_can_delete(PVOID file_desc,
|
||||
STATUS_INVALID_HANDLE));
|
||||
if (ret == STATUS_SUCCESS) {
|
||||
ret = static_cast<packet::error_type>(
|
||||
utils::file::is_directory(file_path)
|
||||
utils::file::directory(file_path).exists()
|
||||
? drive_.get_directory_item_count(
|
||||
utils::path::create_api_path(relative_path))
|
||||
? STATUS_DIRECTORY_NOT_EMPTY
|
||||
@ -1090,7 +1091,7 @@ auto remote_server::winfsp_cleanup(PVOID /*file_desc*/, PWSTR file_name,
|
||||
const auto file_path = construct_path(relative_path);
|
||||
was_closed = 0;
|
||||
|
||||
const auto directory = utils::file::is_directory(file_path);
|
||||
const auto directory = utils::file::directory(file_path).exists();
|
||||
if (flags & FileSystemBase::FspCleanupDelete) {
|
||||
remove_all(file_path);
|
||||
was_closed = 1;
|
||||
@ -1170,7 +1171,7 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
|
||||
|
||||
const auto relative_path = utils::string::to_utf8(file_name);
|
||||
const auto file_path = construct_path(relative_path);
|
||||
exists = utils::file::is_file(file_path);
|
||||
exists = utils::file::file(file_path).exists();
|
||||
|
||||
if ((create_options & FILE_DIRECTORY_FILE) != 0U) {
|
||||
attributes |= FILE_ATTRIBUTE_DIRECTORY;
|
||||
@ -1268,8 +1269,8 @@ auto remote_server::winfsp_get_security_by_name(
|
||||
|
||||
auto ret = static_cast<packet::error_type>(STATUS_SUCCESS);
|
||||
const auto file_path = construct_path(file_name);
|
||||
if (utils::file::is_file(file_path) ||
|
||||
(utils::file::is_directory(file_path))) {
|
||||
if (utils::file::file(file_path).exists() ||
|
||||
(utils::file::directory(file_path).exists())) {
|
||||
if (attributes) {
|
||||
remote::file_info file_info{};
|
||||
if ((ret = populate_file_info(construct_api_path(file_path),
|
||||
@ -1318,7 +1319,7 @@ auto remote_server::winfsp_open(
|
||||
|
||||
const auto relative_path = utils::string::to_utf8(file_name);
|
||||
const auto file_path = construct_path(relative_path);
|
||||
const auto directory = utils::file::is_directory(file_path);
|
||||
const auto directory = utils::file::directory(file_path).exists();
|
||||
if (directory) {
|
||||
create_options |= FILE_DIRECTORY_FILE;
|
||||
}
|
||||
@ -1489,11 +1490,11 @@ auto remote_server::winfsp_rename(
|
||||
|
||||
auto res = -1;
|
||||
errno = ENOENT;
|
||||
if (utils::file::is_file(file_path)) {
|
||||
if (utils::file::file(file_path).exists()) {
|
||||
res = drive_.rename_file(construct_api_path(file_path),
|
||||
construct_api_path(new_file_path),
|
||||
replace_if_exists != 0U);
|
||||
} else if (utils::file::is_directory(file_path)) {
|
||||
} else if (utils::file::directory(file_path).exists()) {
|
||||
res = drive_.rename_directory(construct_api_path(file_path),
|
||||
construct_api_path(new_file_path));
|
||||
}
|
||||
@ -1523,7 +1524,7 @@ auto remote_server::winfsp_set_basic_info(
|
||||
if (attributes == INVALID_FILE_ATTRIBUTES) {
|
||||
attributes = 0;
|
||||
} else if (attributes == 0) {
|
||||
attributes = utils::file::is_directory(file_path)
|
||||
attributes = utils::file::directory(file_path).exists()
|
||||
? FILE_ATTRIBUTE_DIRECTORY
|
||||
: FILE_ATTRIBUTE_NORMAL;
|
||||
}
|
||||
@ -1679,7 +1680,7 @@ auto remote_server::json_create_directory_snapshot(
|
||||
auto res = -1;
|
||||
errno = ENOENT;
|
||||
|
||||
if (utils::file::is_directory(file_path)) {
|
||||
if (utils::file::directory(file_path).exists()) {
|
||||
auto iter = std::make_shared<directory_iterator>(
|
||||
drive_.get_directory_items(api_path));
|
||||
auto handle = get_next_handle();
|
||||
|
@ -186,7 +186,7 @@ auto remote_server::fuse_fgetattr(
|
||||
|
||||
auto res = has_compat_open_info(handle, EBADF);
|
||||
if (res == 0) {
|
||||
directory = utils::file::is_directory(file_path);
|
||||
directory = utils::file::directory(file_path).exists();
|
||||
struct _stat64 unix_st {};
|
||||
res = _fstat64(static_cast<int>(handle), &unix_st);
|
||||
if (res == 0) {
|
||||
@ -282,7 +282,7 @@ auto remote_server::fuse_getattr(const char *path, remote::stat &r_st,
|
||||
const auto file_path = construct_path(path);
|
||||
memset(&r_st, 0, sizeof(remote::stat));
|
||||
|
||||
directory = utils::file::is_directory(file_path);
|
||||
directory = utils::file::directory(file_path).exists();
|
||||
|
||||
struct _stat64 st1 {};
|
||||
const auto res = _stat64(file_path.c_str(), &st1);
|
||||
@ -873,7 +873,7 @@ auto remote_server::json_create_directory_snapshot(
|
||||
auto res = -1;
|
||||
errno = ENOENT;
|
||||
|
||||
if (utils::file::is_directory(file_path)) {
|
||||
if (utils::file::directory(file_path).exists()) {
|
||||
auto iter = std::make_shared<directory_iterator>(
|
||||
drive_.get_directory_items(utils::path::create_api_path(path)));
|
||||
auto handle = get_next_handle();
|
||||
@ -1011,8 +1011,11 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
|
||||
|
||||
const auto file_path = utils::string::from_utf8(utils::path::combine(
|
||||
mount_location_, {utils::string::to_utf8(file_name)}));
|
||||
exists = static_cast<BOOLEAN>(utils::file::is_file(utils::path::combine(
|
||||
mount_location_, {utils::string::to_utf8(file_name)})));
|
||||
exists = static_cast<BOOLEAN>(
|
||||
utils::file::file(
|
||||
utils::path::combine(mount_location_,
|
||||
{utils::string::to_utf8(file_name)}))
|
||||
.exists());
|
||||
|
||||
auto create_flags = FILE_FLAG_BACKUP_SEMANTICS;
|
||||
if ((create_options & FILE_DIRECTORY_FILE) != 0U) {
|
||||
|
@ -62,7 +62,7 @@ auto remote_winfsp_drive::winfsp_service::OnStart(ULONG, PWSTR *) -> NTSTATUS {
|
||||
(mount_location[1u] == ':');
|
||||
|
||||
auto ret = drive_letter ? STATUS_DEVICE_BUSY : STATUS_NOT_SUPPORTED;
|
||||
if ((drive_letter && not utils::file::is_directory(mount_location))) {
|
||||
if ((drive_letter && not utils::file::directory(mount_location).exists())) {
|
||||
auto unicode_mount_location = utils::string::from_utf8(mount_location);
|
||||
host_.SetFileSystemName(&unicode_mount_location[0u]);
|
||||
if (config_.get_enable_mount_manager()) {
|
||||
@ -363,33 +363,33 @@ auto remote_winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
||||
utils::path::strip_to_file_name(item_path));
|
||||
if (not marker || (marker && item_found)) {
|
||||
// if (not utils::path::is_ads_file_path(item_path)) {
|
||||
union {
|
||||
UINT8 B[FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) +
|
||||
((MAX_PATH + 1) * sizeof(WCHAR))];
|
||||
FSP_FSCTL_DIR_INFO D;
|
||||
} directory_info_buffer;
|
||||
union {
|
||||
UINT8 B[FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) +
|
||||
((MAX_PATH + 1) * sizeof(WCHAR))];
|
||||
FSP_FSCTL_DIR_INFO D;
|
||||
} directory_info_buffer;
|
||||
|
||||
auto *directory_info = &directory_info_buffer.D;
|
||||
::ZeroMemory(directory_info, sizeof(*directory_info));
|
||||
directory_info->Size = static_cast<UINT16>(
|
||||
FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) +
|
||||
(std::min((size_t)MAX_PATH, display_name.size()) *
|
||||
sizeof(WCHAR)));
|
||||
auto *directory_info = &directory_info_buffer.D;
|
||||
::ZeroMemory(directory_info, sizeof(*directory_info));
|
||||
directory_info->Size = static_cast<UINT16>(
|
||||
FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) +
|
||||
(std::min((size_t)MAX_PATH, display_name.size()) *
|
||||
sizeof(WCHAR)));
|
||||
|
||||
if (not item["meta"].empty() ||
|
||||
((item_path != ".") && (item_path != ".."))) {
|
||||
populate_file_info(item, directory_info->FileInfo);
|
||||
}
|
||||
if (ret == STATUS_SUCCESS) {
|
||||
::wcscpy_s(&directory_info->FileNameBuf[0], MAX_PATH,
|
||||
&display_name[0]);
|
||||
|
||||
FspFileSystemFillDirectoryBuffer(directory_buffer,
|
||||
directory_info, &ret);
|
||||
if (ret != STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
if (not item["meta"].empty() ||
|
||||
((item_path != ".") && (item_path != ".."))) {
|
||||
populate_file_info(item, directory_info->FileInfo);
|
||||
}
|
||||
if (ret == STATUS_SUCCESS) {
|
||||
::wcscpy_s(&directory_info->FileNameBuf[0], MAX_PATH,
|
||||
&display_name[0]);
|
||||
|
||||
FspFileSystemFillDirectoryBuffer(directory_buffer, directory_info,
|
||||
&ret);
|
||||
if (ret != STATUS_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// }
|
||||
} else {
|
||||
item_found = display_name == std::wstring(marker);
|
||||
|
@ -81,7 +81,7 @@ auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/,
|
||||
(mount_location[1U] == ':');
|
||||
|
||||
auto ret = drive_letter ? STATUS_DEVICE_BUSY : STATUS_NOT_SUPPORTED;
|
||||
if ((drive_letter && not utils::file::is_directory(mount_location))) {
|
||||
if ((drive_letter && not utils::file::directory(mount_location).exists())) {
|
||||
auto unicode_mount_location = utils::string::from_utf8(mount_location);
|
||||
host_.SetFileSystemName(unicode_mount_location.data());
|
||||
if (config_.get_enable_mount_manager()) {
|
||||
|
@ -778,11 +778,6 @@ auto file_manager::rename_file(const std::string &from_api_path,
|
||||
return res;
|
||||
}
|
||||
|
||||
std::uint64_t file_size{};
|
||||
if (not utils::file::get_file_size(fsi.source_path, file_size)) {
|
||||
return api_error::os_error;
|
||||
}
|
||||
|
||||
res = remove_file(to_api_path);
|
||||
if ((res == api_error::success) || (res == api_error::item_not_found)) {
|
||||
if (not utils::file::retry_delete_file(fsi.source_path)) {
|
||||
@ -878,8 +873,9 @@ void file_manager::start() {
|
||||
auto res = provider_.get_filesystem_item(api_path, false, fsi);
|
||||
if (res == api_error::success) {
|
||||
if (source_path == fsi.source_path) {
|
||||
std::uint64_t file_size{};
|
||||
if (utils::file::get_file_size(fsi.source_path, file_size)) {
|
||||
auto opt_size = utils::file::file{fsi.source_path}.size();
|
||||
if (opt_size.has_value()) {
|
||||
auto file_size{opt_size.value()};
|
||||
if (file_size == fsi.size) {
|
||||
auto closeable_file = std::make_shared<open_file>(
|
||||
chunk_size,
|
||||
@ -1027,7 +1023,7 @@ void file_manager::upload_completed(const file_upload_completed &evt) {
|
||||
bool exists{};
|
||||
auto res = provider_.is_file(evt.get_api_path(), exists);
|
||||
if ((res == api_error::success && not exists) ||
|
||||
not utils::file::is_file(evt.get_source().get<std::string>())) {
|
||||
not utils::file::file(evt.get_source().get<std::string>()).exists()) {
|
||||
event_system::instance().raise<file_upload_not_found>(
|
||||
evt.get_api_path(), evt.get_source());
|
||||
remove_upload(evt.get_api_path(), true);
|
||||
|
@ -64,7 +64,7 @@ file_manager::ring_buffer_open_file::ring_buffer_open_file(
|
||||
ring_state_.set(0U, ring_state_.size(), true);
|
||||
|
||||
buffer_directory = utils::path::absolute(buffer_directory);
|
||||
if (not utils::file::create_directories(buffer_directory)) {
|
||||
if (not utils::file::directory(buffer_directory).create_directory()) {
|
||||
throw std::runtime_error("failed to create buffer directory|path|" +
|
||||
buffer_directory + "|err|" +
|
||||
std::to_string(utils::get_last_error_code()));
|
||||
|
@ -57,7 +57,7 @@ lock_data::~lock_data() {
|
||||
|
||||
auto lock_data::get_lock_data_file() -> std::string {
|
||||
const auto dir = get_state_directory();
|
||||
if (not utils::file::create_directories(dir)) {
|
||||
if (not utils::file::directory(dir).create_directory()) {
|
||||
throw startup_exception("failed to create directory|sp|" + dir + "|err|" +
|
||||
std::to_string(utils::get_last_error_code()));
|
||||
}
|
||||
@ -67,7 +67,7 @@ auto lock_data::get_lock_data_file() -> std::string {
|
||||
|
||||
auto lock_data::get_lock_file() -> std::string {
|
||||
const auto dir = get_state_directory();
|
||||
if (not utils::file::create_directories(dir)) {
|
||||
if (not utils::file::directory(dir).create_directory()) {
|
||||
throw startup_exception("failed to create directory|sp|" + dir + "|err|" +
|
||||
std::to_string(utils::get_last_error_code()));
|
||||
}
|
||||
|
@ -482,10 +482,10 @@ void base_provider::remove_deleted_files() {
|
||||
|
||||
for (const auto &item : removed_list) {
|
||||
if (not item.directory) {
|
||||
if (utils::file::is_file(item.source_path)) {
|
||||
if (utils::file::file(item.source_path).exists()) {
|
||||
const auto orphaned_directory =
|
||||
utils::path::combine(config_.get_data_directory(), {"orphaned"});
|
||||
if (utils::file::create_directories(orphaned_directory)) {
|
||||
if (utils::file::directory(orphaned_directory).create_directory()) {
|
||||
const auto parts = utils::string::split(item.api_path, '/', false);
|
||||
const auto orphaned_file = utils::path::combine(
|
||||
orphaned_directory,
|
||||
|
@ -195,7 +195,7 @@ auto encrypt_provider::do_fs_operation(
|
||||
: api_error::item_not_found;
|
||||
}
|
||||
|
||||
auto exists = utils::file::is_file(source_path);
|
||||
auto exists = utils::file::file(source_path).exists();
|
||||
if (exists && directory) {
|
||||
return api_error::item_exists;
|
||||
}
|
||||
@ -203,7 +203,7 @@ auto encrypt_provider::do_fs_operation(
|
||||
return api_error::item_not_found;
|
||||
}
|
||||
|
||||
exists = utils::file::is_directory(source_path);
|
||||
exists = utils::file::directory(source_path).exists();
|
||||
if (exists && not directory) {
|
||||
return api_error::item_exists;
|
||||
}
|
||||
@ -659,8 +659,9 @@ auto encrypt_provider::is_directory(const std::string &api_path,
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
exists = utils::file::is_directory(
|
||||
row->get_column("source_path").get_value<std::string>());
|
||||
exists = utils::file::directory(
|
||||
row->get_column("source_path").get_value<std::string>())
|
||||
.exists();
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
@ -677,8 +678,9 @@ auto encrypt_provider::is_file(const std::string &api_path,
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
exists = utils::file::is_file(
|
||||
row->get_column("source_path").get_value<std::string>());
|
||||
exists =
|
||||
utils::file::file(row->get_column("source_path").get_value<std::string>())
|
||||
.exists();
|
||||
return api_error::success;
|
||||
}
|
||||
|
||||
@ -872,11 +874,13 @@ auto encrypt_provider::read_file_bytes(const std::string &api_path,
|
||||
|
||||
auto file_data = row->get_column("data").get_value_as_json();
|
||||
|
||||
std::uint64_t file_size{};
|
||||
if (not utils::file::get_file_size(source_path, file_size)) {
|
||||
auto opt_size = utils::file::file{source_path}.size();
|
||||
if (opt_size.has_value()) {
|
||||
return api_error::os_error;
|
||||
}
|
||||
|
||||
auto file_size{opt_size.value()};
|
||||
|
||||
std::vector<
|
||||
std::array<unsigned char, crypto_aead_xchacha20poly1305_IETF_NPUBBYTES>>
|
||||
iv_list{};
|
||||
|
@ -869,12 +869,18 @@ void s3_provider::stop() {
|
||||
auto s3_provider::upload_file_impl(const std::string &api_path,
|
||||
const std::string &source_path,
|
||||
stop_type &stop_requested) -> api_error {
|
||||
std::uint64_t file_size{};
|
||||
if (utils::file::is_file(source_path) &&
|
||||
not utils::file::get_file_size(source_path, file_size)) {
|
||||
auto file = utils::file::file{source_path};
|
||||
if (file.exists()) {
|
||||
return api_error::comm_error;
|
||||
}
|
||||
|
||||
auto opt_size = file.size();
|
||||
if (opt_size.has_value()) {
|
||||
return api_error::comm_error;
|
||||
}
|
||||
|
||||
auto file_size{opt_size.value()};
|
||||
|
||||
const auto cfg = get_config().get_s3_config();
|
||||
const auto is_encrypted = not cfg.encryption_token.empty();
|
||||
|
||||
|
@ -106,7 +106,8 @@ void change_to_process_directory() {
|
||||
auto copy_file(std::string from_path, std::string to_path) -> bool {
|
||||
from_path = utils::path::absolute(from_path);
|
||||
to_path = utils::path::absolute(to_path);
|
||||
if (is_file(from_path) && not is_directory(to_path)) {
|
||||
if (utils::file::file(from_path).exists() &&
|
||||
not directory(to_path).exists()) {
|
||||
return std::filesystem::copy_file(from_path, to_path);
|
||||
}
|
||||
|
||||
@ -117,7 +118,7 @@ auto copy_directory_recursively(std::string from_path,
|
||||
std::string to_path) -> bool {
|
||||
from_path = utils::path::absolute(from_path);
|
||||
to_path = utils::path::absolute(to_path);
|
||||
auto ret = create_directories(to_path);
|
||||
auto ret = utils::file::directory(to_path).create_directory();
|
||||
if (ret) {
|
||||
#if defined(_WIN32)
|
||||
WIN32_FIND_DATA fd{};
|
||||
@ -405,7 +406,7 @@ auto move_file(std::string from, std::string to) -> bool {
|
||||
to = utils::path::absolute(to);
|
||||
|
||||
const auto directory = utils::path::get_parent_directory(to);
|
||||
if (not create_directories(directory)) {
|
||||
if (not utils::file::directory(directory).create_directory()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -420,7 +421,7 @@ auto move_file(std::string from, std::string to) -> bool {
|
||||
|
||||
auto read_file_lines(const std::string &path) -> std::vector<std::string> {
|
||||
std::vector<std::string> ret;
|
||||
if (is_file(path)) {
|
||||
if (utils::file::file(path).exists()) {
|
||||
std::ifstream fs(path);
|
||||
std::string current_line;
|
||||
while (not fs.eof() && std::getline(fs, current_line)) {
|
||||
|
Reference in New Issue
Block a user