mirror of
https://github.com/ziglang/zig.git
synced 2026-01-06 21:43:25 +00:00
posix read can return error.IsDir
This commit is contained in:
parent
eae9634ac9
commit
3ee4d23ebd
@ -639,6 +639,7 @@ const ParseFormValueError = error{
|
||||
Unexpected,
|
||||
InvalidDebugInfo,
|
||||
EndOfFile,
|
||||
IsDir,
|
||||
OutOfMemory,
|
||||
};
|
||||
|
||||
|
||||
@ -311,9 +311,15 @@ pub const File = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub const ReadError = error{};
|
||||
pub const ReadError = error{
|
||||
BadFd,
|
||||
Io,
|
||||
IsDir,
|
||||
|
||||
pub fn read(self: *File, buffer: []u8) !usize {
|
||||
Unexpected,
|
||||
};
|
||||
|
||||
pub fn read(self: *File, buffer: []u8) ReadError!usize {
|
||||
if (is_posix) {
|
||||
var index: usize = 0;
|
||||
while (index < buffer.len) {
|
||||
@ -326,6 +332,7 @@ pub const File = struct {
|
||||
posix.EFAULT => unreachable,
|
||||
posix.EBADF => return error.BadFd,
|
||||
posix.EIO => return error.Io,
|
||||
posix.EISDIR => return error.IsDir,
|
||||
else => return os.unexpectedErrorPosix(read_err),
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user