| ... | ... | @@ -311,9 +311,15 @@ pub const File = struct { |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | | pub const ReadError = error{}; |
| 314 | pub const ReadError = error{ |
| 315 | BadFd, |
| 316 | Io, |
| 317 | IsDir, |
| 318 | |
| 319 | Unexpected, |
| 320 | }; |
| 315 | 321 | |
| 316 | | pub fn read(self: *File, buffer: []u8) !usize { |
| 322 | pub fn read(self: *File, buffer: []u8) ReadError!usize { |
| 317 | 323 | if (is_posix) { |
| 318 | 324 | var index: usize = 0; |
| 319 | 325 | while (index < buffer.len) { |
| ... | ... | @@ -326,6 +332,7 @@ pub const File = struct { |
| 326 | 332 | posix.EFAULT => unreachable, |
| 327 | 333 | posix.EBADF => return error.BadFd, |
| 328 | 334 | posix.EIO => return error.Io, |
| 335 | posix.EISDIR => return error.IsDir, |
| 329 | 336 | else => return os.unexpectedErrorPosix(read_err), |
| 330 | 337 | } |
| 331 | 338 | } |