Skip to content

Commit

Permalink
same for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl authored and ihnorton committed Feb 1, 2025
1 parent c04280b commit 097babf
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions tiledb/sm/filesystem/win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,19 @@ Status Win::read(
0) {
auto gle = GetLastError();
CloseHandle(file_h);

std::string err_msg;
if (gle != 0) {
err_msg = get_last_error_msg(gle, "ReadFile");
} else {
err_msg = "num_bytes_read " + std::to_string(num_bytes_read) +
" != nbytes " + std::to_string(nbytes)
}

return LOG_STATUS(Status_IOError(
"Cannot read from file '" + path + "'; File read error " +
(gle != 0 ? get_last_error_msg(gle, "ReadFile") :
"num_bytes_read " + std::to_string(num_bytes_read) +
" != nbyes " + std::to_string(nbytes))));
"Cannot read from file '" + path + "'; File read error '" + err_msg +
"' offset " + std::string(offset) + " nbytes " +
std::string(nbytes)));
}
byte_buffer += num_bytes_read;
offset += num_bytes_read;
Expand Down Expand Up @@ -548,8 +556,9 @@ Status Win::write(
uint64_t file_offset = file_size_lg_int.QuadPart;
if (!write_at(file_h, file_offset, buffer, buffer_size).ok()) {
CloseHandle(file_h);
return LOG_STATUS(
Status_IOError(std::string("Cannot write to file '") + path));
return LOG_STATUS(Status_IOError(
std::string("Cannot write to file '") + path + "'" + " file_offset " +
std::string(file_offset) + " buffer_size " + std::string(buffer_size)));
}
// Always close the handle.
if (CloseHandle(file_h) == 0) {
Expand Down Expand Up @@ -588,9 +597,11 @@ Status Win::write_at(
bytes_to_write,
&bytes_written,
&ov) == 0) {
// There's no guarantee that the bytes_written outarg was updated, when
// the write failed -- so let's not log it.
return LOG_STATUS(Status_IOError(std::string(
"Cannot write to file; File writing error: " +
get_last_error_msg("WriteFile"))));
get_last_error_msg("WriteFile") + " bytes_to_write " +
std::string(bytes_to_write))));
}
remaining_bytes_to_write -= bytes_written;
byte_idx += bytes_written;
Expand Down

0 comments on commit 097babf

Please sign in to comment.