diff options
| author | Jan Philipp Hafer <jan.hafer@rwth-aachen.de> | 2022-12-06 22:21:23 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-01-23 02:07:12 -0500 |
| commit | 55e879d2eda0a73b73778923dd4bbc6904aa107c (patch) | |
| tree | 56082547c86fdc20a6abcf1cc666821fda6958da | |
| parent | 3cb1ab0e055320702a96398959e13761cb2bfc5a (diff) | |
| download | zig-55e879d2eda0a73b73778923dd4bbc6904aa107c.tar.gz zig-55e879d2eda0a73b73778923dd4bbc6904aa107c.zip | |
std.os.windows: add possible error NETNAME_DELETED of ReadFile
Closes #13631
| -rw-r--r-- | lib/std/os.zig | 3 | ||||
| -rw-r--r-- | lib/std/os/windows.zig | 6 | ||||
| -rw-r--r-- | lib/std/zig/system/NativeTargetInfo.zig | 1 | ||||
| -rw-r--r-- | src/link.zig | 1 | ||||
| -rw-r--r-- | src/main.zig | 1 |
5 files changed, 11 insertions, 1 deletions
diff --git a/lib/std/os.zig b/lib/std/os.zig index 99bd9848ee..c10fe61aea 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -641,6 +641,9 @@ pub const ReadError = error{ ConnectionTimedOut, NotOpenForReading, + // Windows only + NetNameDeleted, + /// This error occurs when no global event loop is configured, /// and reading from the file descriptor would block. WouldBlock, diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig index a5be06166e..f838721370 100644 --- a/lib/std/os/windows.zig +++ b/lib/std/os/windows.zig @@ -435,8 +435,9 @@ pub fn FindClose(hFindFile: HANDLE) void { } pub const ReadFileError = error{ - OperationAborted, BrokenPipe, + NetNameDeleted, + OperationAborted, Unexpected, }; @@ -475,6 +476,7 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64, io_mode: std.io.Mo .IO_PENDING => unreachable, .OPERATION_ABORTED => return error.OperationAborted, .BROKEN_PIPE => return error.BrokenPipe, + .NETNAME_DELETED => return error.NetNameDeleted, .HANDLE_EOF => return @as(usize, bytes_transferred), else => |err| return unexpectedError(err), } @@ -506,9 +508,11 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64, io_mode: std.io.Mo } else null; if (kernel32.ReadFile(in_hFile, buffer.ptr, want_read_count, &amt_read, overlapped) == 0) { switch (kernel32.GetLastError()) { + .IO_PENDING => unreachable, .OPERATION_ABORTED => continue, .BROKEN_PIPE => return 0, .HANDLE_EOF => return 0, + .NETNAME_DELETED => return error.NetNameDeleted, else => |err| return unexpectedError(err), } } diff --git a/lib/std/zig/system/NativeTargetInfo.zig b/lib/std/zig/system/NativeTargetInfo.zig index 0232797387..0648bb82ff 100644 --- a/lib/std/zig/system/NativeTargetInfo.zig +++ b/lib/std/zig/system/NativeTargetInfo.zig @@ -917,6 +917,7 @@ fn preadMin(file: fs.File, buf: []u8, offset: u64, min_read_len: usize) !usize { error.Unseekable => return error.UnableToReadElfFile, error.ConnectionResetByPeer => return error.UnableToReadElfFile, error.ConnectionTimedOut => return error.UnableToReadElfFile, + error.NetNameDeleted => return error.UnableToReadElfFile, error.Unexpected => return error.Unexpected, error.InputOutput => return error.FileSystem, error.AccessDenied => return error.Unexpected, diff --git a/src/link.zig b/src/link.zig index 2317525827..976debb72b 100644 --- a/src/link.zig +++ b/src/link.zig @@ -489,6 +489,7 @@ pub const File = struct { NameTooLong, CurrentWorkingDirectoryUnlinked, LockViolation, + NetNameDeleted, }; /// Called from within the CodeGen to lower a local variable instantion as an unnamed diff --git a/src/main.zig b/src/main.zig index 9455bc328a..a012a51300 100644 --- a/src/main.zig +++ b/src/main.zig @@ -4482,6 +4482,7 @@ const FmtError = error{ UnsupportedEncoding, ConnectionResetByPeer, LockViolation, + NetNameDeleted, } || fs.File.OpenError; fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_path: []const u8) FmtError!void { |
