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)) {
|
||||
|
@@ -80,7 +80,7 @@ mount(std::vector<const char *> args, std::string data_directory,
|
||||
std::cout << "Generated " << app_config::get_provider_display_name(prov)
|
||||
<< " Configuration" << std::endl;
|
||||
std::cout << config.get_config_file_path() << std::endl;
|
||||
ret = utils::file::is_file(config.get_config_file_path())
|
||||
ret = utils::file::file(config.get_config_file_path()).exists()
|
||||
? exit_code::success
|
||||
: exit_code::file_creation_failed;
|
||||
} else {
|
||||
|
@@ -68,10 +68,10 @@ protected:
|
||||
ASSERT_TRUE(utils::file::remove_directory(test_directory, true));
|
||||
|
||||
mount_location = utils::path::combine(test_directory, {"mount"});
|
||||
ASSERT_TRUE(utils::file::create_directories(mount_location));
|
||||
ASSERT_TRUE(utils::file::directory(mount_location).create_directory());
|
||||
|
||||
cfg_directory = utils::path::combine(test_directory, {"cfg"});
|
||||
ASSERT_TRUE(utils::file::create_directories(cfg_directory));
|
||||
ASSERT_TRUE(utils::file::directory(cfg_directory).create_directory());
|
||||
|
||||
config = std::make_unique<app_config>(provider_t::type, cfg_directory);
|
||||
|
||||
@@ -153,12 +153,12 @@ public:
|
||||
open(file_path.c_str(), O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP);
|
||||
EXPECT_LE(1, fd);
|
||||
|
||||
EXPECT_TRUE(utils::file::is_file(file_path));
|
||||
EXPECT_FALSE(utils::file::is_directory(file_path));
|
||||
EXPECT_TRUE(utils::file::file(file_path).exists());
|
||||
EXPECT_FALSE(utils::file::directory(file_path).exists());
|
||||
|
||||
std::uint64_t file_size{};
|
||||
EXPECT_TRUE(utils::file::get_file_size(file_path, file_size));
|
||||
EXPECT_EQ(0U, file_size);
|
||||
auto opt_size = utils::file::file{file_path}.size();
|
||||
EXPECT_TRUE(opt_size.has_value());
|
||||
EXPECT_EQ(0U, opt_size.value());
|
||||
|
||||
EXPECT_EQ(0, close(fd));
|
||||
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||
@@ -197,8 +197,8 @@ public:
|
||||
EXPECT_EQ(0, ret);
|
||||
|
||||
std::this_thread::sleep_for(SLEEP_SECONDS);
|
||||
EXPECT_FALSE(utils::file::is_directory(file_path));
|
||||
EXPECT_FALSE(utils::file::is_file(file_path));
|
||||
EXPECT_FALSE(utils::file::directory(file_path).exists());
|
||||
EXPECT_FALSE(utils::file::file(file_path).exists());
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -135,11 +135,11 @@ public:
|
||||
if (not utils::file::retry_delete_file(to_file_path)) {
|
||||
return -1;
|
||||
}
|
||||
} else if (utils::file::is_directory(to_file_path) ||
|
||||
utils::file::is_file(to_file_path)) {
|
||||
errno = EEXIST;
|
||||
return -1;
|
||||
}
|
||||
} else if (utils::file::directory(to_file_path).exists()) ||
|
||||
utils::file::file(to_file_path).exists()) {
|
||||
errno = EEXIST;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return rename(from_file_path.c_str(), to_file_path.c_str());
|
||||
}
|
||||
|
@@ -138,7 +138,7 @@ public:
|
||||
auto populate_file_info(const std::string &api_path,
|
||||
remote::file_info &file_info) -> api_error override {
|
||||
const auto file_path = utils::path::combine(mount_location_, {api_path});
|
||||
const auto directory = utils::file::is_directory(file_path);
|
||||
const auto directory = utils::file::directory(file_path).exists();
|
||||
const auto attributes =
|
||||
FILE_FLAG_BACKUP_SEMANTICS |
|
||||
(directory ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_NORMAL);
|
||||
@@ -148,8 +148,14 @@ public:
|
||||
FILE_BASIC_INFO fi{};
|
||||
::GetFileInformationByHandleEx(handle, FileBasicInfo, &fi, sizeof(fi));
|
||||
if (not directory) {
|
||||
utils::file::get_file_size(file_path, file_info.FileSize);
|
||||
auto opt_size = utils::file::file{file_path}.size();
|
||||
if (not opt_size.has_value()) {
|
||||
return api_error::os_error;
|
||||
}
|
||||
|
||||
file_info.FileSize = opt_size.value();
|
||||
}
|
||||
|
||||
file_info.AllocationSize =
|
||||
directory ? 0
|
||||
: utils::divide_with_ceiling(file_info.FileSize,
|
||||
|
@@ -165,10 +165,12 @@ TEST_F(config_test, sia_default_settings) {
|
||||
json data;
|
||||
EXPECT_TRUE(utils::file::read_json_file(config_file, data));
|
||||
EXPECT_STREQ(DEFAULT_SIA_CONFIG.c_str(), data.dump(2).c_str());
|
||||
EXPECT_TRUE(utils::file::is_directory(
|
||||
utils::path::combine(sia_directory, {"cache"})));
|
||||
EXPECT_TRUE(utils::file::is_directory(
|
||||
utils::path::combine(sia_directory, {"logs"})));
|
||||
EXPECT_TRUE(
|
||||
utils::file::directory(utils::path::combine(sia_directory, {"cache"}))
|
||||
.exists());
|
||||
EXPECT_TRUE(
|
||||
utils::file::directory(utils::path::combine(sia_directory, {"logs"}))
|
||||
.exists());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,10 +184,12 @@ TEST_F(config_test, s3_default_settings) {
|
||||
json data;
|
||||
EXPECT_TRUE(utils::file::read_json_file(config_file, data));
|
||||
EXPECT_STREQ(DEFAULT_S3_CONFIG.c_str(), data.dump(2).c_str());
|
||||
EXPECT_TRUE(utils::file::is_directory(
|
||||
utils::path::combine(s3_directory, {"cache"})));
|
||||
EXPECT_TRUE(utils::file::is_directory(
|
||||
utils::path::combine(s3_directory, {"logs"})));
|
||||
EXPECT_TRUE(
|
||||
utils::file::directory(utils::path::combine(s3_directory, {"cache"}))
|
||||
.exists());
|
||||
EXPECT_TRUE(
|
||||
utils::file::directory(utils::path::combine(s3_directory, {"logs"}))
|
||||
.exists());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -128,7 +128,7 @@ TEST(open_file, will_not_change_source_path_for_0_byte_file) {
|
||||
o.close();
|
||||
EXPECT_EQ(api_error::success, o.get_api_error());
|
||||
EXPECT_STREQ(source_path.c_str(), o.get_source_path().c_str());
|
||||
EXPECT_TRUE(utils::file::is_file(fsi.source_path));
|
||||
EXPECT_TRUE(utils::file::file(fsi.source_path).exists());
|
||||
}
|
||||
|
||||
TEST(open_file, will_change_source_path_if_file_size_is_greater_than_0) {
|
||||
@@ -166,7 +166,7 @@ TEST(open_file, will_change_source_path_if_file_size_is_greater_than_0) {
|
||||
o.close();
|
||||
EXPECT_EQ(api_error::download_stopped, o.get_api_error());
|
||||
EXPECT_STRNE(source_path.c_str(), o.get_source_path().c_str());
|
||||
EXPECT_FALSE(utils::file::is_file(source_path));
|
||||
EXPECT_FALSE(utils::file::file(source_path).exists());
|
||||
}
|
||||
|
||||
TEST(open_file,
|
||||
@@ -192,7 +192,7 @@ TEST(open_file,
|
||||
o.close();
|
||||
EXPECT_EQ(api_error::success, o.get_api_error());
|
||||
EXPECT_STREQ(source_path.c_str(), o.get_source_path().c_str());
|
||||
EXPECT_TRUE(utils::file::is_file(source_path));
|
||||
EXPECT_TRUE(utils::file::file(source_path).exists());
|
||||
}
|
||||
|
||||
TEST(open_file, write_with_incomplete_download) {
|
||||
@@ -280,7 +280,7 @@ TEST(open_file, write_with_incomplete_download) {
|
||||
|
||||
EXPECT_EQ(api_error::download_incomplete, o.get_api_error());
|
||||
|
||||
EXPECT_TRUE(utils::file::is_file(fsi.source_path));
|
||||
EXPECT_TRUE(utils::file::file(fsi.source_path).exists());
|
||||
}
|
||||
|
||||
TEST(open_file, write_new_file) {
|
||||
@@ -353,7 +353,7 @@ TEST(open_file, write_new_file) {
|
||||
|
||||
EXPECT_EQ(api_error::success, o.get_api_error());
|
||||
|
||||
EXPECT_TRUE(utils::file::is_file(fsi.source_path));
|
||||
EXPECT_TRUE(utils::file::file(fsi.source_path).exists());
|
||||
}
|
||||
|
||||
TEST(open_file, write_new_file_multiple_chunks) {
|
||||
@@ -445,7 +445,7 @@ TEST(open_file, write_new_file_multiple_chunks) {
|
||||
|
||||
EXPECT_EQ(api_error::success, o.get_api_error());
|
||||
|
||||
EXPECT_TRUE(utils::file::is_file(fsi.source_path));
|
||||
EXPECT_TRUE(utils::file::file(fsi.source_path).exists());
|
||||
}
|
||||
|
||||
TEST(open_file, resize_file_to_0_bytes) {
|
||||
|
@@ -730,9 +730,9 @@ TEST(file_manager, can_evict_file) {
|
||||
std::size_t bytes_written{};
|
||||
EXPECT_EQ(api_error::success, f->write(0U, data, bytes_written));
|
||||
|
||||
std::uint64_t file_size{};
|
||||
EXPECT_TRUE(utils::file::get_file_size(source_path, file_size));
|
||||
EXPECT_EQ(static_cast<std::uint64_t>(data.size()), file_size);
|
||||
auto opt_size = utils::file::file{source_path}.size();
|
||||
EXPECT_TRUE(opt_size.has_value());
|
||||
EXPECT_EQ(static_cast<std::uint64_t>(data.size()), opt_size.value());
|
||||
}
|
||||
|
||||
fm.close(handle);
|
||||
@@ -759,7 +759,7 @@ TEST(file_manager, can_evict_file) {
|
||||
return api_error::success;
|
||||
});
|
||||
EXPECT_TRUE(fm.evict_file("/test_evict.txt"));
|
||||
EXPECT_FALSE(utils::file::is_file(source_path));
|
||||
EXPECT_FALSE(utils::file::file(source_path).exists());
|
||||
|
||||
fm.stop();
|
||||
}
|
||||
@@ -1003,9 +1003,10 @@ TEST(file_manager, evict_file_fails_if_file_is_uploading) {
|
||||
std::size_t bytes_written{};
|
||||
EXPECT_EQ(api_error::success, f->write(0U, data, bytes_written));
|
||||
|
||||
std::uint64_t file_size{};
|
||||
EXPECT_TRUE(utils::file::get_file_size(source_path, file_size));
|
||||
EXPECT_EQ(static_cast<std::uint64_t>(data.size()), file_size);
|
||||
auto opt_size = utils::file::file{source_path}.size();
|
||||
EXPECT_TRUE(opt_size.has_value());
|
||||
EXPECT_EQ(static_cast<std::uint64_t>(data.size()), opt_size.value());
|
||||
|
||||
fm.close(handle);
|
||||
|
||||
EXPECT_TRUE(utils::retryable_action(
|
||||
@@ -1015,7 +1016,7 @@ TEST(file_manager, evict_file_fails_if_file_is_uploading) {
|
||||
|
||||
capture.wait_for_empty();
|
||||
|
||||
EXPECT_TRUE(utils::file::is_file(source_path));
|
||||
EXPECT_TRUE(utils::file::file(source_path).exists());
|
||||
|
||||
fm.stop();
|
||||
}
|
||||
@@ -1600,7 +1601,7 @@ TEST(file_manager, can_remove_file) {
|
||||
auto file = utils::file::file::open_or_create_file("./test_remove.txt");
|
||||
EXPECT_TRUE(*file);
|
||||
}
|
||||
EXPECT_TRUE(utils::file::is_file("./test_remove.txt"));
|
||||
EXPECT_TRUE(utils::file::file("./test_remove.txt").exists());
|
||||
|
||||
EXPECT_CALL(mp, get_filesystem_item)
|
||||
.WillOnce([](const std::string &api_path, bool directory,
|
||||
@@ -1619,7 +1620,7 @@ TEST(file_manager, can_remove_file) {
|
||||
|
||||
EXPECT_EQ(api_error::success, fm.remove_file("/test_remove.txt"));
|
||||
|
||||
EXPECT_FALSE(utils::file::is_file("./test_remove.txt"));
|
||||
EXPECT_FALSE(utils::file::file("./test_remove.txt").exists());
|
||||
}
|
||||
|
||||
EXPECT_TRUE(utils::file::remove_directory(file_manager_dir, true));
|
||||
|
@@ -289,9 +289,9 @@ static void ftruncate_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_EQ(0, client.fuse_ftruncate(api_path.c_str(), 100, handle));
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
|
||||
std::uint64_t file_size;
|
||||
EXPECT_TRUE(utils::file::get_file_size(test_file, file_size));
|
||||
EXPECT_EQ(100u, file_size);
|
||||
auto opt_size = utils::file::file{test_file}.size();
|
||||
EXPECT_TRUE(opt_size.has_value());
|
||||
EXPECT_EQ(100U, opt_size.value());
|
||||
}
|
||||
|
||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
||||
@@ -441,7 +441,7 @@ static void mkdir_test(repertory::remote_fuse::remote_client &client) {
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU));
|
||||
#endif
|
||||
EXPECT_TRUE(utils::file::is_directory(test_directory));
|
||||
EXPECT_TRUE(utils::file::directory(test_directory).exists());
|
||||
|
||||
EXPECT_TRUE(utils::file::remove_directory(test_directory));
|
||||
}
|
||||
@@ -486,7 +486,7 @@ opendir_and_releasedir_test(repertory::remote_fuse::remote_client &client) {
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU));
|
||||
#endif
|
||||
EXPECT_TRUE(utils::file::is_directory(test_directory));
|
||||
EXPECT_TRUE(utils::file::directory(test_directory).exists());
|
||||
|
||||
remote::file_handle handle = 0;
|
||||
EXPECT_EQ(0, client.fuse_opendir(api_path.c_str(), handle));
|
||||
@@ -558,7 +558,7 @@ static void readdir_test(repertory::remote_fuse::remote_client &client) {
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU));
|
||||
#endif
|
||||
EXPECT_TRUE(utils::file::is_directory(test_directory));
|
||||
EXPECT_TRUE(utils::file::directory(test_directory).exists());
|
||||
|
||||
remote::file_handle handle = 0;
|
||||
EXPECT_EQ(0, client.fuse_opendir(api_path.c_str(), handle));
|
||||
@@ -621,8 +621,8 @@ static void rename_test(repertory::remote_fuse::remote_client &client) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
EXPECT_EQ(0,
|
||||
client.fuse_rename(api_path.c_str(), renamed_api_path.c_str()));
|
||||
EXPECT_FALSE(utils::file::is_file(test_file));
|
||||
EXPECT_TRUE(utils::file::is_file(renamed_test_file));
|
||||
EXPECT_FALSE(utils::file::file(test_file).exists());
|
||||
EXPECT_TRUE(utils::file::file(renamed_test_file).exists());
|
||||
}
|
||||
|
||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
||||
@@ -640,10 +640,10 @@ static void rmdir_test(repertory::remote_fuse::remote_client &client) {
|
||||
#else
|
||||
EXPECT_EQ(0, client.fuse_mkdir(api_path.c_str(), S_IRWXU));
|
||||
#endif
|
||||
EXPECT_TRUE(utils::file::is_directory(test_directory));
|
||||
EXPECT_TRUE(utils::file::directory(test_directory).exists());
|
||||
|
||||
EXPECT_EQ(0, client.fuse_rmdir(api_path.c_str()));
|
||||
EXPECT_FALSE(utils::file::is_directory(test_directory));
|
||||
EXPECT_FALSE(utils::file::directory(test_directory).exists());
|
||||
|
||||
EXPECT_TRUE(utils::file::remove_directory(test_directory));
|
||||
}
|
||||
@@ -871,9 +871,9 @@ static void truncate_test(repertory::remote_fuse::remote_client &client) {
|
||||
|
||||
EXPECT_EQ(0, client.fuse_truncate(api_path.c_str(), 100));
|
||||
|
||||
std::uint64_t file_size;
|
||||
EXPECT_TRUE(utils::file::get_file_size(test_file, file_size));
|
||||
EXPECT_EQ(100u, file_size);
|
||||
auto opt_size = utils::file::file{test_file}.size();
|
||||
EXPECT_TRUE(opt_size.has_value());
|
||||
EXPECT_EQ(100U, opt_size.value());
|
||||
}
|
||||
|
||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
||||
@@ -892,7 +892,7 @@ static void unlink_test(repertory::remote_fuse::remote_client &client) {
|
||||
if (ret == 0) {
|
||||
EXPECT_EQ(0, client.fuse_release(api_path.c_str(), handle));
|
||||
EXPECT_EQ(0, client.fuse_unlink(api_path.c_str()));
|
||||
EXPECT_FALSE(utils::file::is_file(test_file));
|
||||
EXPECT_FALSE(utils::file::file(test_file).exists());
|
||||
}
|
||||
|
||||
EXPECT_TRUE(utils::file::retry_delete_file(test_file));
|
||||
|
@@ -278,7 +278,7 @@ static void create_and_read_directory_test(remote_client &client) {
|
||||
FILE_ATTRIBUTE_DIRECTORY, 0, &file_desc, &fi, normalized_name, exists);
|
||||
EXPECT_EQ(STATUS_SUCCESS, ret);
|
||||
|
||||
EXPECT_TRUE(utils::file::is_directory(test_directory));
|
||||
EXPECT_TRUE(utils::file::directory(test_directory).exists());
|
||||
|
||||
json list;
|
||||
ret = client.winfsp_read_directory(file_desc, nullptr, nullptr, list);
|
||||
@@ -308,7 +308,7 @@ static void open_and_read_directory_test(remote_client &client) {
|
||||
|
||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||
|
||||
EXPECT_TRUE(utils::file::is_directory(test_directory));
|
||||
EXPECT_TRUE(utils::file::directory(test_directory).exists());
|
||||
|
||||
file_desc = reinterpret_cast<PVOID>(REPERTORY_INVALID_HANDLE);
|
||||
ret = client.winfsp_open(&api_path[0], FILE_DIRECTORY_FILE,
|
||||
@@ -389,8 +389,8 @@ static void rename_test(remote_client &client) {
|
||||
|
||||
ret = client.winfsp_rename(file_desc, &api_path[0], &api_path2[0], 0);
|
||||
EXPECT_EQ(STATUS_SUCCESS, ret);
|
||||
EXPECT_TRUE(utils::file::is_file(test_file2));
|
||||
EXPECT_FALSE(utils::file::is_file(test_file));
|
||||
EXPECT_TRUE(utils::file::file(test_file2).exists());
|
||||
EXPECT_FALSE(utils::file::file(test_file).exists());
|
||||
|
||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||
|
||||
@@ -472,9 +472,9 @@ static void set_file_size_test(remote_client &client) {
|
||||
client.winfsp_set_file_size(file_desc, new_file_size,
|
||||
set_allocation_size, &fi));
|
||||
|
||||
std::uint64_t file_size = 0u;
|
||||
EXPECT_TRUE(utils::file::get_file_size(test_file, file_size));
|
||||
EXPECT_EQ(34u, file_size);
|
||||
auto opt_size = utils::file::file{test_file}.size();
|
||||
EXPECT_TRUE(opt_size.has_value());
|
||||
EXPECT_EQ(34U, opt_size.value());
|
||||
|
||||
EXPECT_EQ(STATUS_SUCCESS, client.winfsp_close(file_desc));
|
||||
|
||||
|
@@ -69,12 +69,12 @@ static void execute_mount(winfsp_test *test,
|
||||
|
||||
static void unmount(winfsp_test *test, const std::string &mount_point) {
|
||||
test->drive->shutdown();
|
||||
auto mounted = utils::file::is_directory(mount_point);
|
||||
auto mounted = utils::file::directory(mount_point).exists();
|
||||
for (auto i = 0; mounted && (i < 50); i++) {
|
||||
std::this_thread::sleep_for(100ms);
|
||||
mounted = utils::file::is_directory(mount_point);
|
||||
mounted = utils::file::directory(mount_point).exists();
|
||||
}
|
||||
EXPECT_FALSE(utils::file::is_directory(mount_point));
|
||||
EXPECT_FALSE(utils::file::directory(mount_point).exists());
|
||||
}
|
||||
|
||||
static void root_creation_test(const std::string &mount_point) {
|
||||
@@ -96,11 +96,11 @@ static auto create_test(winfsp_test *test, const std::string &mount_point) {
|
||||
EXPECT_NE(INVALID_HANDLE_VALUE, handle);
|
||||
EXPECT_TRUE(::CloseHandle(handle));
|
||||
|
||||
EXPECT_TRUE(utils::file::is_file(file));
|
||||
EXPECT_TRUE(utils::file::file(file).exists());
|
||||
|
||||
std::uint64_t file_size;
|
||||
EXPECT_TRUE(utils::file::get_file_size(file, file_size));
|
||||
EXPECT_EQ(0, file_size);
|
||||
auto opt_size = utils::file::file(file).size();
|
||||
EXPECT_TRUE(opt_size.has_value());
|
||||
EXPECT_EQ(0, opt_size.value());
|
||||
|
||||
std::string attr;
|
||||
EXPECT_EQ(api_error::success, test->provider->get_item_meta(
|
||||
@@ -114,7 +114,7 @@ static void delete_file_test(const std::string &file) {
|
||||
TEST_HEADER(__FUNCTION__);
|
||||
event_capture ec({"file_removed"});
|
||||
EXPECT_TRUE(utils::file::retry_delete_file(file));
|
||||
EXPECT_FALSE(utils::file::is_file(file));
|
||||
EXPECT_FALSE(utils::file::file(file).exists());
|
||||
}
|
||||
|
||||
static void create_directory_test(const std::string &directory) {
|
||||
@@ -149,11 +149,11 @@ static void write_file_test(const std::string &mount_point) {
|
||||
EXPECT_EQ(10, bytes_written);
|
||||
EXPECT_TRUE(::CloseHandle(handle));
|
||||
|
||||
EXPECT_TRUE(utils::file::is_file(file));
|
||||
EXPECT_TRUE(utils::file::file(file).exists());
|
||||
|
||||
std::uint64_t file_size;
|
||||
EXPECT_TRUE(utils::file::get_file_size(file, file_size));
|
||||
EXPECT_EQ(10, file_size);
|
||||
auto opt_size = utils::file::file(file).size();
|
||||
EXPECT_TRUE(opt_size.has_value());
|
||||
EXPECT_EQ(10U, opt_size.value());
|
||||
}
|
||||
|
||||
static void read_file_test(const std::string &mount_point) {
|
||||
@@ -199,8 +199,8 @@ static void rename_file_test(winfsp_test *test,
|
||||
const auto file2 = utils::path::combine(mount_point, {"rename_file2.txt"});
|
||||
EXPECT_TRUE(::MoveFile(&file[0], &file2[0]));
|
||||
|
||||
EXPECT_TRUE(utils::file::is_file(file2));
|
||||
EXPECT_FALSE(utils::file::is_file(file));
|
||||
EXPECT_TRUE(utils::file::file(file2).exists());
|
||||
EXPECT_FALSE(utils::file::file(file).exists());
|
||||
|
||||
api_meta_map meta2{};
|
||||
EXPECT_EQ(api_error::success,
|
||||
|
Reference in New Issue
Block a user