This commit is contained in:
Scott E. Graves 2024-10-26 21:11:20 -05:00
parent 468aba1399
commit 7cb78cab40

View File

@ -1099,9 +1099,8 @@ auto winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc,
std::shared_ptr<i_open_file> file;
if (fm_->get_open_file(handle, true, file)) {
api_path = file->get_api_path();
i_open_file::native_operation_callback allocator;
if (set_allocation_size != 0U) {
allocator = [&](native_handle cur_handle) -> api_error {
const auto allocator = [&](native_handle cur_handle) -> api_error {
std::string meta_allocation_size;
utils::calculate_allocation_size(false, 0, new_size,
meta_allocation_size);
@ -1116,9 +1115,9 @@ auto winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc,
: api_error::os_error;
};
new_size = file->get_file_size();
error = file->native_operation(allocator);
} else {
allocator = [&](native_handle cur_handle) -> api_error {
const auto allocator = [&](native_handle cur_handle) -> api_error {
FILE_END_OF_FILE_INFO end_of_file_info{};
end_of_file_info.EndOfFile.QuadPart = static_cast<LONGLONG>(new_size);
return ::SetFileInformationByHandle(cur_handle, FileEndOfFileInfo,
@ -1127,9 +1126,9 @@ auto winfsp_drive::SetFileSize(PVOID /*file_node*/, PVOID file_desc,
? api_error::success
: api_error::os_error;
};
error = file->native_operation(new_size, allocator);
}
error = file->native_operation(new_size, allocator);
if (file_info != nullptr) {
// Populate file information
api_meta_map meta;