add missing error code handling on Windows
This commit is contained in:
parent
413f9a5cfc
commit
034ccb4e4e
@ -841,6 +841,7 @@ pub const Dir = struct {
|
|||||||
w.STATUS.ACCESS_DENIED => return error.AccessDenied,
|
w.STATUS.ACCESS_DENIED => return error.AccessDenied,
|
||||||
w.STATUS.PIPE_BUSY => return error.PipeBusy,
|
w.STATUS.PIPE_BUSY => return error.PipeBusy,
|
||||||
w.STATUS.OBJECT_PATH_SYNTAX_BAD => unreachable,
|
w.STATUS.OBJECT_PATH_SYNTAX_BAD => unreachable,
|
||||||
|
w.STATUS.OBJECT_NAME_COLLISION => return error.PathAlreadyExists,
|
||||||
else => return w.unexpectedStatus(rc),
|
else => return w.unexpectedStatus(rc),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,6 +228,7 @@ pub const File = struct {
|
|||||||
windows.STATUS.SUCCESS => {},
|
windows.STATUS.SUCCESS => {},
|
||||||
windows.STATUS.BUFFER_OVERFLOW => {},
|
windows.STATUS.BUFFER_OVERFLOW => {},
|
||||||
windows.STATUS.INVALID_PARAMETER => unreachable,
|
windows.STATUS.INVALID_PARAMETER => unreachable,
|
||||||
|
windows.STATUS.ACCESS_DENIED => return error.AccessDenied,
|
||||||
else => return windows.unexpectedStatus(rc),
|
else => return windows.unexpectedStatus(rc),
|
||||||
}
|
}
|
||||||
return Stat{
|
return Stat{
|
||||||
|
@ -634,7 +634,7 @@ test "File seek ops" {
|
|||||||
|
|
||||||
test "updateTimes" {
|
test "updateTimes" {
|
||||||
const tmp_file_name = "just_a_temporary_file.txt";
|
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 {
|
defer {
|
||||||
file.close();
|
file.close();
|
||||||
std.fs.cwd().deleteFile(tmp_file_name) catch {};
|
std.fs.cwd().deleteFile(tmp_file_name) catch {};
|
||||||
|
@ -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 {
|
pub fn fstat(fd: fd_t) FStatError!Stat {
|
||||||
var stat: Stat = undefined;
|
var stat: Stat = undefined;
|
||||||
@ -2038,6 +2041,7 @@ pub fn fstat(fd: fd_t) FStatError!Stat {
|
|||||||
EINVAL => unreachable,
|
EINVAL => unreachable,
|
||||||
EBADF => unreachable, // Always a race condition.
|
EBADF => unreachable, // Always a race condition.
|
||||||
ENOMEM => return error.SystemResources,
|
ENOMEM => return error.SystemResources,
|
||||||
|
EACCES => return error.AccessDenied,
|
||||||
else => |err| return unexpectedErrno(err),
|
else => |err| return unexpectedErrno(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2047,6 +2051,7 @@ pub fn fstat(fd: fd_t) FStatError!Stat {
|
|||||||
EINVAL => unreachable,
|
EINVAL => unreachable,
|
||||||
EBADF => unreachable, // Always a race condition.
|
EBADF => unreachable, // Always a race condition.
|
||||||
ENOMEM => return error.SystemResources,
|
ENOMEM => return error.SystemResources,
|
||||||
|
EACCES => return error.AccessDenied,
|
||||||
else => |err| return unexpectedErrno(err),
|
else => |err| return unexpectedErrno(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user