Add NetworkNotFound to ReadLinkError

This matches how other filesystem functions were made to handle BAD_NETWORK_PATH/BAD_NETWORK_NAME in https://github.com/ziglang/zig/pull/16568. ReadLink was the odd one out, but that is no longer the case.
This commit is contained in:
Ryan Liptak 2023-08-17 23:29:53 -07:00 committed by Andrew Kelley
parent 84b4b6bffa
commit e078324dbe
3 changed files with 6 additions and 3 deletions

View File

@ -2995,6 +2995,8 @@ pub const ReadLinkError = error{
/// Windows-only. This error may occur if the opened reparse point is
/// of unsupported type.
UnsupportedReparsePointType,
/// On Windows, `\\server` or `\\server\share` was not found.
NetworkNotFound,
} || UnexpectedError;
/// Read value of a symbolic link.

View File

@ -803,6 +803,7 @@ pub fn CreateSymbolicLink(
pub const ReadLinkError = error{
FileNotFound,
NetworkNotFound,
AccessDenied,
Unexpected,
NameTooLong,
@ -850,9 +851,8 @@ pub fn ReadLink(dir: ?HANDLE, sub_path_w: []const u16, out_buffer: []u8) ReadLin
.OBJECT_NAME_NOT_FOUND => return error.FileNotFound,
.OBJECT_PATH_NOT_FOUND => return error.FileNotFound,
.NO_MEDIA_IN_DEVICE => return error.FileNotFound,
// TODO: Should BAD_NETWORK_* be translated to a different error?
.BAD_NETWORK_PATH => return error.FileNotFound, // \\server was not found
.BAD_NETWORK_NAME => return error.FileNotFound, // \\server was found but \\server\share wasn't
.BAD_NETWORK_PATH => return error.NetworkNotFound, // \\server was not found
.BAD_NETWORK_NAME => return error.NetworkNotFound, // \\server was found but \\server\share wasn't
.INVALID_PARAMETER => unreachable,
.SHARING_VIOLATION => return error.AccessDenied,
.ACCESS_DENIED => return error.AccessDenied,

View File

@ -833,6 +833,7 @@ pub fn abiAndDynamicLinkerFromFile(
error.InvalidUtf8 => unreachable, // Windows only
error.BadPathName => unreachable, // Windows only
error.UnsupportedReparsePointType => unreachable, // Windows only
error.NetworkNotFound => unreachable, // Windows only
error.AccessDenied,
error.FileNotFound,