Commit 3ee4d23ebd

Andrew Kelley <superjoe30@gmail.com>
2018-06-17 01:54:16
posix read can return error.IsDir
1 parent eae9634
Changed files (2)
std
std/debug/index.zig
@@ -639,6 +639,7 @@ const ParseFormValueError = error{
     Unexpected,
     InvalidDebugInfo,
     EndOfFile,
+    IsDir,
     OutOfMemory,
 };
 
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),
                     }
                 }