authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-06-16 19:54:16-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-06-16 19:54:16-04:00
log3ee4d23ebdd149e734ca33904a4786d5bd3fa8aa
tree4166a7346f30b3b8bfd027289dc657afdb771eee
parenteae9634ac959bdb32c95f2acdcadde59beec23d5

posix read can return error.IsDir


2 files changed, 10 insertions(+), 2 deletions(-)

std/debug/index.zig+1
...@@ -639,6 +639,7 @@ const ParseFormValueError = error{...@@ -639,6 +639,7 @@ const ParseFormValueError = error{
639 Unexpected,639 Unexpected,
640 InvalidDebugInfo,640 InvalidDebugInfo,
641 EndOfFile,641 EndOfFile,
642 IsDir,
642 OutOfMemory,643 OutOfMemory,
643};644};
644645
std/os/file.zig+9-2
...@@ -311,9 +311,15 @@ pub const File = struct {...@@ -311,9 +311,15 @@ pub const File = struct {
311 }311 }
312 }312 }
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 {
317 if (is_posix) {323 if (is_posix) {
318 var index: usize = 0;324 var index: usize = 0;
319 while (index < buffer.len) {325 while (index < buffer.len) {
...@@ -326,6 +332,7 @@ pub const File = struct {...@@ -326,6 +332,7 @@ pub const File = struct {
326 posix.EFAULT => unreachable,332 posix.EFAULT => unreachable,
327 posix.EBADF => return error.BadFd,333 posix.EBADF => return error.BadFd,
328 posix.EIO => return error.Io,334 posix.EIO => return error.Io,
335 posix.EISDIR => return error.IsDir,
329 else => return os.unexpectedErrorPosix(read_err),336 else => return os.unexpectedErrorPosix(read_err),
330 }337 }
331 }338 }