authorgravatar for jan.hafer@rwth-aachen.deJan Philipp Hafer <jan.hafer@rwth-aachen.de> 2022-12-06 22:21:23+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-23 02:07:12-05:00
log55e879d2eda0a73b73778923dd4bbc6904aa107c
tree56082547c86fdc20a6abcf1cc666821fda6958da
parent3cb1ab0e055320702a96398959e13761cb2bfc5a

std.os.windows: add possible error NETNAME_DELETED of ReadFile

Closes #13631

5 files changed, 11 insertions(+), 1 deletions(-)

lib/std/os.zig+3
......@@ -641,6 +641,9 @@ pub const ReadError = error{
641641 ConnectionTimedOut,
642642 NotOpenForReading,
643643
644 // Windows only
645 NetNameDeleted,
646
644647 /// This error occurs when no global event loop is configured,
645648 /// and reading from the file descriptor would block.
646649 WouldBlock,
lib/std/os/windows.zig+5-1
......@@ -435,8 +435,9 @@ pub fn FindClose(hFindFile: HANDLE) void {
435435}
436436
437437pub const ReadFileError = error{
438 OperationAborted,
439438 BrokenPipe,
439 NetNameDeleted,
440 OperationAborted,
440441 Unexpected,
441442};
442443
......@@ -475,6 +476,7 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64, io_mode: std.io.Mo
475476 .IO_PENDING => unreachable,
476477 .OPERATION_ABORTED => return error.OperationAborted,
477478 .BROKEN_PIPE => return error.BrokenPipe,
479 .NETNAME_DELETED => return error.NetNameDeleted,
478480 .HANDLE_EOF => return @as(usize, bytes_transferred),
479481 else => |err| return unexpectedError(err),
480482 }
......@@ -506,9 +508,11 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64, io_mode: std.io.Mo
506508 } else null;
507509 if (kernel32.ReadFile(in_hFile, buffer.ptr, want_read_count, &amt_read, overlapped) == 0) {
508510 switch (kernel32.GetLastError()) {
511 .IO_PENDING => unreachable,
509512 .OPERATION_ABORTED => continue,
510513 .BROKEN_PIPE => return 0,
511514 .HANDLE_EOF => return 0,
515 .NETNAME_DELETED => return error.NetNameDeleted,
512516 else => |err| return unexpectedError(err),
513517 }
514518 }
lib/std/zig/system/NativeTargetInfo.zig+1
......@@ -917,6 +917,7 @@ fn preadMin(file: fs.File, buf: []u8, offset: u64, min_read_len: usize) !usize {
917917 error.Unseekable => return error.UnableToReadElfFile,
918918 error.ConnectionResetByPeer => return error.UnableToReadElfFile,
919919 error.ConnectionTimedOut => return error.UnableToReadElfFile,
920 error.NetNameDeleted => return error.UnableToReadElfFile,
920921 error.Unexpected => return error.Unexpected,
921922 error.InputOutput => return error.FileSystem,
922923 error.AccessDenied => return error.Unexpected,
src/link.zig+1
......@@ -489,6 +489,7 @@ pub const File = struct {
489489 NameTooLong,
490490 CurrentWorkingDirectoryUnlinked,
491491 LockViolation,
492 NetNameDeleted,
492493 };
493494
494495 /// Called from within the CodeGen to lower a local variable instantion as an unnamed
src/main.zig+1
......@@ -4482,6 +4482,7 @@ const FmtError = error{
44824482 UnsupportedEncoding,
44834483 ConnectionResetByPeer,
44844484 LockViolation,
4485 NetNameDeleted,
44854486} || fs.File.OpenError;
44864487
44874488fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_path: []const u8) FmtError!void {