win32 fixes
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2024-08-10 12:24:37 -05:00
parent 3b19713111
commit 1e854aa368
2 changed files with 14 additions and 36 deletions

View File

@ -465,28 +465,14 @@ auto remote_server::fuse_read(
res = -1;
errno = ERANGE;
} else if ((res = has_compat_open_info(handle, EBADF)) == 0) {
res = -1;
errno = EBADF;
auto *os_handle =
reinterpret_cast<HANDLE>(_get_osfhandle(static_cast<int>(handle)));
if (os_handle != INVALID_HANDLE_VALUE) {
errno = EFAULT;
auto file = utils::file::file::attach_file(os_handle, true);
if (*file) {
auto file_size = file->size();
data.resize(utils::calculate_read_size(
file_size, static_cast<std::size_t>(read_size), read_offset));
if (data.empty()) {
res = 0;
errno = 0;
} else {
std::size_t bytes_read{};
if (file->read(data.data(), data.size(), read_offset, &bytes_read)) {
res = 0;
errno = 0;
}
}
res = lseek(handle, read_offset, SEEK_SET);
if (res != -1) {
data.resize(read_size);
res = read(handle, data.data(), data.size());
if (res == -1) {
data.resize(0U);
} else if (data.size() != res) {
data.resize(res);
}
}
}
@ -531,19 +517,11 @@ auto remote_server::fuse_write(
} else {
res = has_compat_open_info(handle, EBADF);
if (res == 0) {
res = -1;
errno = EBADF;
auto *os_handle =
reinterpret_cast<HANDLE>(_get_osfhandle(static_cast<int>(handle)));
if (os_handle != INVALID_HANDLE_VALUE) {
errno = EFAULT;
if ((write_size == 0) ||
utils::file::file::attach_file(os_handle)->write(
reinterpret_cast<const unsigned char *>(buffer),
static_cast<std::size_t>(write_size), write_offset,
&bytes_written)) {
res = 0;
errno = 0;
res = lseek(handle, write_offset, SEEK_SET);
if (res != -1) {
res = write(handle, buffer, write_size);
if (res >= -1) {
bytes_written = res;
}
}
}

View File

@ -534,7 +534,7 @@ read_and_write_base64_test(repertory::remote_fuse::remote_client &client) {
EXPECT_EQ(0, ret);
if (ret == 0) {
const auto data = macaron::Base64::Encode("1234567890");
EXPECT_EQ(10, client.fuse_write_base64(api_path.c_str(), &data[0],
EXPECT_EQ(10, client.fuse_write_base64(api_path.c_str(), data.data(),
data.size(), 0, handle));
data_buffer buffer(10);
EXPECT_EQ(10, client.fuse_read(api_path.c_str(),