authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-13 19:04:02-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-29 06:20:49-07:00
logd680b9e9b2320612a4e988763f5090c4ae8f9a8f
tree27fa5132572250a2c2093f2b3ea3772290721d44
parent539808239ecae050e383dd11f395a363b4404e21

std.Io.File: add WouldBlock to the error set

Even in an asynchronous world, the concept of a non-blocking flag is useful because it determines under what conditions the operation completes.

2 files changed, 6 insertions(+), 4 deletions(-)

lib/std/Io/File.zig+2
......@@ -139,6 +139,8 @@ pub const OpenError = error{
139139 /// kernel (e.g., for module/firmware loading), and write access was
140140 /// requested.
141141 FileBusy,
142 /// Non-blocking was requested and the operation cannot return immediately.
143 WouldBlock,
142144} || Io.Dir.PathNameError || Io.Cancelable || Io.UnexpectedError;
143145
144146pub fn close(file: File, io: Io) void {
lib/std/Io/Threaded.zig+4-4
......@@ -1039,7 +1039,7 @@ fn dirCreateFilePosix(
10391039 .EXIST => return error.PathAlreadyExists,
10401040 .BUSY => return error.DeviceBusy,
10411041 .OPNOTSUPP => return error.FileLocksNotSupported,
1042 //.AGAIN => return error.WouldBlock,
1042 .AGAIN => return error.WouldBlock,
10431043 .TXTBSY => return error.FileBusy,
10441044 .NXIO => return error.NoDevice,
10451045 .ILSEQ => return error.BadPathName,
......@@ -1064,7 +1064,7 @@ fn dirCreateFilePosix(
10641064 .BADF => |err| return errnoBug(err),
10651065 .INVAL => |err| return errnoBug(err), // invalid parameters
10661066 .NOLCK => return error.SystemResources,
1067 //.AGAIN => return error.WouldBlock,
1067 .AGAIN => return error.WouldBlock,
10681068 .OPNOTSUPP => return error.FileLocksNotSupported,
10691069 else => |err| return posix.unexpectedErrno(err),
10701070 }
......@@ -1168,7 +1168,7 @@ fn dirOpenFile(
11681168 .EXIST => return error.PathAlreadyExists,
11691169 .BUSY => return error.DeviceBusy,
11701170 .OPNOTSUPP => return error.FileLocksNotSupported,
1171 //.AGAIN => return error.WouldBlock,
1171 .AGAIN => return error.WouldBlock,
11721172 .TXTBSY => return error.FileBusy,
11731173 .NXIO => return error.NoDevice,
11741174 .ILSEQ => return error.BadPathName,
......@@ -1193,7 +1193,7 @@ fn dirOpenFile(
11931193 .BADF => |err| return errnoBug(err),
11941194 .INVAL => |err| return errnoBug(err), // invalid parameters
11951195 .NOLCK => return error.SystemResources,
1196 //.AGAIN => return error.WouldBlock,
1196 .AGAIN => return error.WouldBlock,
11971197 .OPNOTSUPP => return error.FileLocksNotSupported,
11981198 else => |err| return posix.unexpectedErrno(err),
11991199 }