mirror of
https://github.com/ziglang/zig.git
synced 2026-02-17 06:49:23 +00:00
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.
This commit is contained in:
parent
539808239e
commit
d680b9e9b2
@ -139,6 +139,8 @@ pub const OpenError = error{
|
||||
/// kernel (e.g., for module/firmware loading), and write access was
|
||||
/// requested.
|
||||
FileBusy,
|
||||
/// Non-blocking was requested and the operation cannot return immediately.
|
||||
WouldBlock,
|
||||
} || Io.Dir.PathNameError || Io.Cancelable || Io.UnexpectedError;
|
||||
|
||||
pub fn close(file: File, io: Io) void {
|
||||
|
||||
@ -1039,7 +1039,7 @@ fn dirCreateFilePosix(
|
||||
.EXIST => return error.PathAlreadyExists,
|
||||
.BUSY => return error.DeviceBusy,
|
||||
.OPNOTSUPP => return error.FileLocksNotSupported,
|
||||
//.AGAIN => return error.WouldBlock,
|
||||
.AGAIN => return error.WouldBlock,
|
||||
.TXTBSY => return error.FileBusy,
|
||||
.NXIO => return error.NoDevice,
|
||||
.ILSEQ => return error.BadPathName,
|
||||
@ -1064,7 +1064,7 @@ fn dirCreateFilePosix(
|
||||
.BADF => |err| return errnoBug(err),
|
||||
.INVAL => |err| return errnoBug(err), // invalid parameters
|
||||
.NOLCK => return error.SystemResources,
|
||||
//.AGAIN => return error.WouldBlock,
|
||||
.AGAIN => return error.WouldBlock,
|
||||
.OPNOTSUPP => return error.FileLocksNotSupported,
|
||||
else => |err| return posix.unexpectedErrno(err),
|
||||
}
|
||||
@ -1168,7 +1168,7 @@ fn dirOpenFile(
|
||||
.EXIST => return error.PathAlreadyExists,
|
||||
.BUSY => return error.DeviceBusy,
|
||||
.OPNOTSUPP => return error.FileLocksNotSupported,
|
||||
//.AGAIN => return error.WouldBlock,
|
||||
.AGAIN => return error.WouldBlock,
|
||||
.TXTBSY => return error.FileBusy,
|
||||
.NXIO => return error.NoDevice,
|
||||
.ILSEQ => return error.BadPathName,
|
||||
@ -1193,7 +1193,7 @@ fn dirOpenFile(
|
||||
.BADF => |err| return errnoBug(err),
|
||||
.INVAL => |err| return errnoBug(err), // invalid parameters
|
||||
.NOLCK => return error.SystemResources,
|
||||
//.AGAIN => return error.WouldBlock,
|
||||
.AGAIN => return error.WouldBlock,
|
||||
.OPNOTSUPP => return error.FileLocksNotSupported,
|
||||
else => |err| return posix.unexpectedErrno(err),
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user