Skip to content

Commit 3ee4d23

Browse files
committed
posix read can return error.IsDir
1 parent eae9634 commit 3ee4d23

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

std/debug/index.zig

+1
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ const ParseFormValueError = error{
639639
Unexpected,
640640
InvalidDebugInfo,
641641
EndOfFile,
642+
IsDir,
642643
OutOfMemory,
643644
};
644645

std/os/file.zig

+9-2
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,15 @@ pub const File = struct {
311311
}
312312
}
313313

314-
pub const ReadError = error{};
314+
pub const ReadError = error{
315+
BadFd,
316+
Io,
317+
IsDir,
318+
319+
Unexpected,
320+
};
315321

316-
pub fn read(self: *File, buffer: []u8) !usize {
322+
pub fn read(self: *File, buffer: []u8) ReadError!usize {
317323
if (is_posix) {
318324
var index: usize = 0;
319325
while (index < buffer.len) {
@@ -326,6 +332,7 @@ pub const File = struct {
326332
posix.EFAULT => unreachable,
327333
posix.EBADF => return error.BadFd,
328334
posix.EIO => return error.Io,
335+
posix.EISDIR => return error.IsDir,
329336
else => return os.unexpectedErrorPosix(read_err),
330337
}
331338
}

0 commit comments

Comments
 (0)