Skip to content

Commit a82d7c2

Browse files
committed
std: add missing error to windows.WriteFile
I encountered this error today when testing the self-hosted compiler on Windows.
1 parent 44a6172 commit a82d7c2

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

lib/std/os.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,10 @@ pub const WriteError = error{
953953
OperationAborted,
954954
NotOpenForWriting,
955955

956+
/// The process cannot access the file because another process has locked
957+
/// a portion of the file. Windows-only.
958+
LockViolation,
959+
956960
/// This error occurs when no global event loop is configured,
957961
/// and reading from the file descriptor would block.
958962
WouldBlock,

lib/std/os/windows.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,9 @@ pub const WriteFileError = error{
517517
OperationAborted,
518518
BrokenPipe,
519519
NotOpenForWriting,
520+
/// The process cannot access the file because another process has locked
521+
/// a portion of the file.
522+
LockViolation,
520523
Unexpected,
521524
};
522525

@@ -597,6 +600,7 @@ pub fn WriteFile(
597600
.IO_PENDING => unreachable,
598601
.BROKEN_PIPE => return error.BrokenPipe,
599602
.INVALID_HANDLE => return error.NotOpenForWriting,
603+
.LOCK_VIOLATION => return error.LockViolation,
600604
else => |err| return unexpectedError(err),
601605
}
602606
}

src/link.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ pub const File = struct {
435435
EmitFail,
436436
NameTooLong,
437437
CurrentWorkingDirectoryUnlinked,
438+
LockViolation,
438439
};
439440

440441
/// Called from within the CodeGen to lower a local variable instantion as an unnamed

src/main.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4227,6 +4227,7 @@ const FmtError = error{
42274227
NotOpenForWriting,
42284228
UnsupportedEncoding,
42294229
ConnectionResetByPeer,
4230+
LockViolation,
42304231
} || fs.File.OpenError;
42314232

42324233
fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool, dir: fs.Dir, sub_path: []const u8) FmtError!void {

0 commit comments

Comments
 (0)