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{...@@ -641,6 +641,9 @@ pub const ReadError = error{
641 ConnectionTimedOut,641 ConnectionTimedOut,
642 NotOpenForReading,642 NotOpenForReading,
643643
644 // Windows only
645 NetNameDeleted,
646
644 /// This error occurs when no global event loop is configured,647 /// This error occurs when no global event loop is configured,
645 /// and reading from the file descriptor would block.648 /// and reading from the file descriptor would block.
646 WouldBlock,649 WouldBlock,
lib/std/os/windows.zig+5-1
...@@ -435,8 +435,9 @@ pub fn FindClose(hFindFile: HANDLE) void {...@@ -435,8 +435,9 @@ pub fn FindClose(hFindFile: HANDLE) void {
435}435}
436436
437pub const ReadFileError = error{437pub const ReadFileError = error{
438 OperationAborted,
439 BrokenPipe,438 BrokenPipe,
439 NetNameDeleted,
440 OperationAborted,
440 Unexpected,441 Unexpected,
441};442};
442443
...@@ -475,6 +476,7 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64, io_mode: std.io.Mo...@@ -475,6 +476,7 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64, io_mode: std.io.Mo
475 .IO_PENDING => unreachable,476 .IO_PENDING => unreachable,
476 .OPERATION_ABORTED => return error.OperationAborted,477 .OPERATION_ABORTED => return error.OperationAborted,
477 .BROKEN_PIPE => return error.BrokenPipe,478 .BROKEN_PIPE => return error.BrokenPipe,
479 .NETNAME_DELETED => return error.NetNameDeleted,
478 .HANDLE_EOF => return @as(usize, bytes_transferred),480 .HANDLE_EOF => return @as(usize, bytes_transferred),
479 else => |err| return unexpectedError(err),481 else => |err| return unexpectedError(err),
480 }482 }
...@@ -506,9 +508,11 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64, io_mode: std.io.Mo...@@ -506,9 +508,11 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64, io_mode: std.io.Mo
506 } else null;508 } else null;
507 if (kernel32.ReadFile(in_hFile, buffer.ptr, want_read_count, &amt_read, overlapped) == 0) {509 if (kernel32.ReadFile(in_hFile, buffer.ptr, want_read_count, &amt_read, overlapped) == 0) {
508 switch (kernel32.GetLastError()) {510 switch (kernel32.GetLastError()) {
511 .IO_PENDING => unreachable,
509 .OPERATION_ABORTED => continue,512 .OPERATION_ABORTED => continue,
510 .BROKEN_PIPE => return 0,513 .BROKEN_PIPE => return 0,
511 .HANDLE_EOF => return 0,514 .HANDLE_EOF => return 0,
515 .NETNAME_DELETED => return error.NetNameDeleted,
512 else => |err| return unexpectedError(err),516 else => |err| return unexpectedError(err),
513 }517 }
514 }518 }
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 {...@@ -917,6 +917,7 @@ fn preadMin(file: fs.File, buf: []u8, offset: u64, min_read_len: usize) !usize {
917 error.Unseekable => return error.UnableToReadElfFile,917 error.Unseekable => return error.UnableToReadElfFile,
918 error.ConnectionResetByPeer => return error.UnableToReadElfFile,918 error.ConnectionResetByPeer => return error.UnableToReadElfFile,
919 error.ConnectionTimedOut => return error.UnableToReadElfFile,919 error.ConnectionTimedOut => return error.UnableToReadElfFile,
920 error.NetNameDeleted => return error.UnableToReadElfFile,
920 error.Unexpected => return error.Unexpected,921 error.Unexpected => return error.Unexpected,
921 error.InputOutput => return error.FileSystem,922 error.InputOutput => return error.FileSystem,
922 error.AccessDenied => return error.Unexpected,923 error.AccessDenied => return error.Unexpected,
src/link.zig+1
...@@ -489,6 +489,7 @@ pub const File = struct {...@@ -489,6 +489,7 @@ pub const File = struct {
489 NameTooLong,489 NameTooLong,
490 CurrentWorkingDirectoryUnlinked,490 CurrentWorkingDirectoryUnlinked,
491 LockViolation,491 LockViolation,
492 NetNameDeleted,
492 };493 };
493494
494 /// Called from within the CodeGen to lower a local variable instantion as an unnamed495 /// 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{...@@ -4482,6 +4482,7 @@ const FmtError = error{
4482 UnsupportedEncoding,4482 UnsupportedEncoding,
4483 ConnectionResetByPeer,4483 ConnectionResetByPeer,
4484 LockViolation,4484 LockViolation,
4485 NetNameDeleted,
4485} || fs.File.OpenError;4486} || fs.File.OpenError;
44864487
4487fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_path: []const u8) FmtError!void {4488fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_path: []const u8) FmtError!void {