commit 55e879d2eda0a73b73778923dd4bbc6904aa107c (tree)
parent 3cb1ab0e055320702a96398959e13761cb2bfc5a
Author: Jan Philipp Hafer <jan.hafer@rwth-aachen.de>
Date: Tue, 6 Dec 2022 22:21:23 +0100
std.os.windows: add possible error NETNAME_DELETED of ReadFile
Closes #13631
Diffstat:
5 files changed, 11 insertions(+), 1 deletion(-)
diff --git 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
@@ -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
@@ -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
@@ -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
@@ -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 {