zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 3ee4d23ebdd149e734ca33904a4786d5bd3fa8aa (tree)
parent eae9634ac959bdb32c95f2acdcadde59beec23d5
Author: Andrew Kelley <superjoe30@gmail.com>
Date:   Sat, 16 Jun 2018 19:54:16 -0400

posix read can return error.IsDir

Diffstat:
Mstd/debug/index.zig | 1+
Mstd/os/file.zig | 11+++++++++--
2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/std/debug/index.zig b/std/debug/index.zig @@ -639,6 +639,7 @@ const ParseFormValueError = error{ Unexpected, InvalidDebugInfo, EndOfFile, + IsDir, OutOfMemory, }; diff --git a/std/os/file.zig b/std/os/file.zig @@ -311,9 +311,15 @@ pub const File = struct { } } - pub const ReadError = error{}; + pub const ReadError = error{ + BadFd, + Io, + IsDir, + + Unexpected, + }; - pub fn read(self: *File, buffer: []u8) !usize { + 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), } }