Skip to content

Commit d92649d

Browse files
authored
Update Windows ReadFile and WriteFile to recognise Access Denied error when a read or write is attempted on a disconnected virtual com port
1 parent b16c094 commit d92649d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/std/os/windows.zig

+8
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,9 @@ pub const ReadFileError = error{
602602
OperationAborted,
603603
/// Unable to read file due to lock.
604604
LockViolation,
605+
/// Known to be possible when:
606+
/// - Unable to read from disconnected virtual com port (Windows)
607+
AccessDenied,
605608
Unexpected,
606609
};
607610

@@ -634,6 +637,7 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64) ReadFileError!usiz
634637
.HANDLE_EOF => return 0,
635638
.NETNAME_DELETED => return error.ConnectionResetByPeer,
636639
.LOCK_VIOLATION => return error.LockViolation,
640+
.ACCESS_DENIED => return error.AccessDenied,
637641
else => |err| return unexpectedError(err),
638642
}
639643
}
@@ -651,6 +655,9 @@ pub const WriteFileError = error{
651655
LockViolation,
652656
/// The specified network name is no longer available.
653657
ConnectionResetByPeer,
658+
/// Known to be possible when:
659+
/// - Unable to write to disconnected virtual com port (Windows)
660+
AccessDenied,
654661
Unexpected,
655662
};
656663

@@ -687,6 +694,7 @@ pub fn WriteFile(
687694
.INVALID_HANDLE => return error.NotOpenForWriting,
688695
.LOCK_VIOLATION => return error.LockViolation,
689696
.NETNAME_DELETED => return error.ConnectionResetByPeer,
697+
.ACCESS_DENIED => return error.AccessDenied,
690698
else => |err| return unexpectedError(err),
691699
}
692700
}

0 commit comments

Comments
 (0)