authorgravatar for 178673413+psbob@users.noreply.github.compsbob <178673413+psbob@users.noreply.github.com> 2025-04-27 15:42:15+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-04-27 14:42:15+00:00
logd92649da80a526f2e2b2f220c05b81becf4fa627
tree36620fa425c5dbb0071b451df8c191f27849b495
parentb16c094926cf659e144cbcbed6c69cd820c5ff9f
signaturebadge-check Signed by PGP key B5690EEEBB952194

Update Windows ReadFile and WriteFile to recognise Access Denied error when a read or write is attempted on a disconnected virtual com port


1 files changed, 8 insertions(+), 0 deletions(-)

lib/std/os/windows.zig+8
......@@ -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 }