diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-11-30 16:58:32 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-11-30 16:58:32 -0500 |
| commit | 034ccb4e4e64dda2626535d46a4bc0367bcc1ad2 (patch) | |
| tree | 494d551fc7864bbf9f750a24d1f22b593a2ec9db /lib | |
| parent | 413f9a5cfc9e867e3bc69b47b38c62b52a52d5e9 (diff) | |
| download | zig-034ccb4e4e64dda2626535d46a4bc0367bcc1ad2.tar.gz zig-034ccb4e4e64dda2626535d46a4bc0367bcc1ad2.zip | |
add missing error code handling on Windows
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/fs.zig | 1 | ||||
| -rw-r--r-- | lib/std/fs/file.zig | 1 | ||||
| -rw-r--r-- | lib/std/io/test.zig | 2 | ||||
| -rw-r--r-- | lib/std/os.zig | 7 |
4 files changed, 9 insertions, 2 deletions
diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 0f8da873a6..89a045a652 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -841,6 +841,7 @@ pub const Dir = struct { w.STATUS.ACCESS_DENIED => return error.AccessDenied, w.STATUS.PIPE_BUSY => return error.PipeBusy, w.STATUS.OBJECT_PATH_SYNTAX_BAD => unreachable, + w.STATUS.OBJECT_NAME_COLLISION => return error.PathAlreadyExists, else => return w.unexpectedStatus(rc), } } diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig index 7a12c7b937..540f7d395e 100644 --- a/lib/std/fs/file.zig +++ b/lib/std/fs/file.zig @@ -228,6 +228,7 @@ pub const File = struct { windows.STATUS.SUCCESS => {}, windows.STATUS.BUFFER_OVERFLOW => {}, windows.STATUS.INVALID_PARAMETER => unreachable, + windows.STATUS.ACCESS_DENIED => return error.AccessDenied, else => return windows.unexpectedStatus(rc), } return Stat{ diff --git a/lib/std/io/test.zig b/lib/std/io/test.zig index 2857252bb5..912a871863 100644 --- a/lib/std/io/test.zig +++ b/lib/std/io/test.zig @@ -634,7 +634,7 @@ test "File seek ops" { test "updateTimes" { const tmp_file_name = "just_a_temporary_file.txt"; - var file = try fs.cwd().createFile(tmp_file_name, .{}); + var file = try fs.cwd().createFile(tmp_file_name, .{ .read = true }); defer { file.close(); std.fs.cwd().deleteFile(tmp_file_name) catch {}; diff --git a/lib/std/os.zig b/lib/std/os.zig index 6572d37305..622aaaf3bd 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -2028,7 +2028,10 @@ pub fn waitpid(pid: i32, flags: u32) u32 { } } -pub const FStatError = error{SystemResources} || UnexpectedError; +pub const FStatError = error{ + SystemResources, + AccessDenied, +} || UnexpectedError; pub fn fstat(fd: fd_t) FStatError!Stat { var stat: Stat = undefined; @@ -2038,6 +2041,7 @@ pub fn fstat(fd: fd_t) FStatError!Stat { EINVAL => unreachable, EBADF => unreachable, // Always a race condition. ENOMEM => return error.SystemResources, + EACCES => return error.AccessDenied, else => |err| return unexpectedErrno(err), } } @@ -2047,6 +2051,7 @@ pub fn fstat(fd: fd_t) FStatError!Stat { EINVAL => unreachable, EBADF => unreachable, // Always a race condition. ENOMEM => return error.SystemResources, + EACCES => return error.AccessDenied, else => |err| return unexpectedErrno(err), } } |
