Skip to content

Commit d16a9b0

Browse files
authored
std.os.windows: Map PIPE_NOT_AVAILABLE from OpenFile() to error.NoDevice (#21938)
1 parent 1a99c99 commit d16a9b0

File tree

6 files changed

+8
-0
lines changed

6 files changed

+8
-0
lines changed

lib/std/fs/File.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ pub const OpenError = error{
3939
FileNotFound,
4040
AccessDenied,
4141
PipeBusy,
42+
NoDevice,
4243
NameTooLong,
4344
/// WASI-only; file paths must be valid UTF-8.
4445
InvalidUtf8,

lib/std/os/windows.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ pub fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!HAN
132132
.SHARING_VIOLATION => return error.AccessDenied,
133133
.ACCESS_DENIED => return error.AccessDenied,
134134
.PIPE_BUSY => return error.PipeBusy,
135+
.PIPE_NOT_AVAILABLE => return error.NoDevice,
135136
.OBJECT_PATH_SYNTAX_BAD => unreachable,
136137
.OBJECT_NAME_COLLISION => return error.PathAlreadyExists,
137138
.FILE_IS_A_DIRECTORY => return error.IsDir,
@@ -801,6 +802,7 @@ pub fn CreateSymbolicLink(
801802
error.NotDir => return error.Unexpected,
802803
error.WouldBlock => return error.Unexpected,
803804
error.PipeBusy => return error.Unexpected,
805+
error.NoDevice => return error.Unexpected,
804806
error.AntivirusInterference => return error.Unexpected,
805807
else => |e| return e,
806808
};

lib/std/posix.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,6 +2946,7 @@ pub fn mkdiratW(dir_fd: fd_t, sub_path_w: []const u16, mode: u32) MakeDirError!v
29462946
}) catch |err| switch (err) {
29472947
error.IsDir => return error.Unexpected,
29482948
error.PipeBusy => return error.Unexpected,
2949+
error.NoDevice => return error.Unexpected,
29492950
error.WouldBlock => return error.Unexpected,
29502951
error.AntivirusInterference => return error.Unexpected,
29512952
else => |e| return e,
@@ -3040,6 +3041,7 @@ pub fn mkdirW(dir_path_w: []const u16, mode: u32) MakeDirError!void {
30403041
}) catch |err| switch (err) {
30413042
error.IsDir => return error.Unexpected,
30423043
error.PipeBusy => return error.Unexpected,
3044+
error.NoDevice => return error.Unexpected,
30433045
error.WouldBlock => return error.Unexpected,
30443046
error.AntivirusInterference => return error.Unexpected,
30453047
else => |e| return e,

lib/std/process/Child.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ fn spawnWindows(self: *ChildProcess) SpawnError!void {
743743
}) catch |err| switch (err) {
744744
error.PathAlreadyExists => return error.Unexpected, // not possible for "NUL"
745745
error.PipeBusy => return error.Unexpected, // not possible for "NUL"
746+
error.NoDevice => return error.Unexpected, // not possible for "NUL"
746747
error.FileNotFound => return error.Unexpected, // not possible for "NUL"
747748
error.AccessDenied => return error.Unexpected, // not possible for "NUL"
748749
error.NameTooLong => return error.Unexpected, // not possible for "NUL"

src/Builtin.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ pub fn populateFile(comp: *Compilation, mod: *Module, file: *File) !void {
250250
error.BadPathName => unreachable, // it's always "builtin.zig"
251251
error.NameTooLong => unreachable, // it's always "builtin.zig"
252252
error.PipeBusy => unreachable, // it's not a pipe
253+
error.NoDevice => unreachable, // it's not a pipe
253254
error.WouldBlock => unreachable, // not asking for non-blocking I/O
254255

255256
error.FileNotFound => try writeFile(file, mod),

src/Zcu/PerThread.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ pub fn astGenFile(
133133
error.BadPathName => unreachable, // it's a hex encoded name
134134
error.NameTooLong => unreachable, // it's a fixed size name
135135
error.PipeBusy => unreachable, // it's not a pipe
136+
error.NoDevice => unreachable, // it's not a pipe
136137
error.WouldBlock => unreachable, // not asking for non-blocking I/O
137138
// There are no dir components, so you would think that this was
138139
// unreachable, however we have observed on macOS two processes racing

0 commit comments

Comments
 (0)