| author | |
| committer | |
| log | 9a3adeea6ef0eb30e75e732148e0a2b93d0d0c99 |
| tree | 0b4c647651ff5e8881d29ec60242e4ba35340e4c |
| parent | 0f21d3d4d1a5cbb5254dbf55304347f4d5c3e9c5 |
When calling NtCreateFile with a UNC path, if either `\\server` or `\\server\share` are not found, then the statuses `BAD_NETWORK_PATH` or `BAD_NETWORK_NAME` are returned (respectively).
These statuses are not translated into `error.FileNotFound` because they convey more information than the typical FileNotFound error. For example, if you were trying to call `Dir.makePath` with an absolute UNC path like `\\MyServer\MyShare\a\b\c\d`, then knowing that `\\MyServer\MyShare` was not found allows for returning after trying to create the first directory instead of then trying to create `a\b\c`, `a\b`, etc. when it's already known that they will all fail in the same way.6 files changed, 48 insertions(+), 0 deletions(-)
lib/std/child_process.zig+2| ... | @@ -508,6 +508,7 @@ pub const ChildProcess = struct { | ... | @@ -508,6 +508,7 @@ pub const ChildProcess = struct { |
| 508 | error.BadPathName => unreachable, // Windows-only | 508 | error.BadPathName => unreachable, // Windows-only |
| 509 | error.InvalidHandle => unreachable, // WASI-only | 509 | error.InvalidHandle => unreachable, // WASI-only |
| 510 | error.WouldBlock => unreachable, | 510 | error.WouldBlock => unreachable, |
| 511 | error.NetworkNotFound => unreachable, // Windows-only | ||
| 511 | else => |e| return e, | 512 | else => |e| return e, |
| 512 | } | 513 | } |
| 513 | else | 514 | else |
| ... | @@ -659,6 +660,7 @@ pub const ChildProcess = struct { | ... | @@ -659,6 +660,7 @@ pub const ChildProcess = struct { |
| 659 | error.AccessDenied => unreachable, // not possible for "NUL" | 660 | error.AccessDenied => unreachable, // not possible for "NUL" |
| 660 | error.NameTooLong => unreachable, // not possible for "NUL" | 661 | error.NameTooLong => unreachable, // not possible for "NUL" |
| 661 | error.WouldBlock => unreachable, // not possible for "NUL" | 662 | error.WouldBlock => unreachable, // not possible for "NUL" |
| 663 | error.NetworkNotFound => unreachable, // not possible for "NUL" | ||
| 662 | else => |e| return e, | 664 | else => |e| return e, |
| 663 | } | 665 | } |
| 664 | else | 666 | else |
lib/std/fs.zig+15| ... | @@ -1099,6 +1099,8 @@ pub const Dir = struct { | ... | @@ -1099,6 +1099,8 @@ pub const Dir = struct { |
| 1099 | InvalidUtf8, | 1099 | InvalidUtf8, |
| 1100 | BadPathName, | 1100 | BadPathName, |
| 1101 | DeviceBusy, | 1101 | DeviceBusy, |
| 1102 | /// On Windows, `\\server` or `\\server\share` was not found. | ||
| 1103 | NetworkNotFound, | ||
| 1102 | } || os.UnexpectedError; | 1104 | } || os.UnexpectedError; |
| 1103 | 1105 | ||
| 1104 | pub fn close(self: *Dir) void { | 1106 | pub fn close(self: *Dir) void { |
| ... | @@ -1890,6 +1892,8 @@ pub const Dir = struct { | ... | @@ -1890,6 +1892,8 @@ pub const Dir = struct { |
| 1890 | ReadOnlyFileSystem, | 1892 | ReadOnlyFileSystem, |
| 1891 | InvalidUtf8, | 1893 | InvalidUtf8, |
| 1892 | BadPathName, | 1894 | BadPathName, |
| 1895 | /// On Windows, `\\server` or `\\server\share` was not found. | ||
| 1896 | NetworkNotFound, | ||
| 1893 | Unexpected, | 1897 | Unexpected, |
| 1894 | }; | 1898 | }; |
| 1895 | 1899 | ||
| ... | @@ -2112,6 +2116,9 @@ pub const Dir = struct { | ... | @@ -2112,6 +2116,9 @@ pub const Dir = struct { |
| 2112 | /// On Windows, file paths cannot contain these characters: | 2116 | /// On Windows, file paths cannot contain these characters: |
| 2113 | /// '/', '*', '?', '"', '<', '>', '|' | 2117 | /// '/', '*', '?', '"', '<', '>', '|' |
| 2114 | BadPathName, | 2118 | BadPathName, |
| 2119 | |||
| 2120 | /// On Windows, `\\server` or `\\server\share` was not found. | ||
| 2121 | NetworkNotFound, | ||
| 2115 | } || os.UnexpectedError; | 2122 | } || os.UnexpectedError; |
| 2116 | 2123 | ||
| 2117 | /// Whether `full_path` describes a symlink, file, or directory, this function | 2124 | /// Whether `full_path` describes a symlink, file, or directory, this function |
| ... | @@ -2168,6 +2175,7 @@ pub const Dir = struct { | ... | @@ -2168,6 +2175,7 @@ pub const Dir = struct { |
| 2168 | error.Unexpected, | 2175 | error.Unexpected, |
| 2169 | error.InvalidUtf8, | 2176 | error.InvalidUtf8, |
| 2170 | error.BadPathName, | 2177 | error.BadPathName, |
| 2178 | error.NetworkNotFound, | ||
| 2171 | error.DeviceBusy, | 2179 | error.DeviceBusy, |
| 2172 | => |e| return e, | 2180 | => |e| return e, |
| 2173 | }; | 2181 | }; |
| ... | @@ -2204,6 +2212,7 @@ pub const Dir = struct { | ... | @@ -2204,6 +2212,7 @@ pub const Dir = struct { |
| 2204 | error.FileSystem, | 2212 | error.FileSystem, |
| 2205 | error.FileBusy, | 2213 | error.FileBusy, |
| 2206 | error.BadPathName, | 2214 | error.BadPathName, |
| 2215 | error.NetworkNotFound, | ||
| 2207 | error.Unexpected, | 2216 | error.Unexpected, |
| 2208 | => |e| return e, | 2217 | => |e| return e, |
| 2209 | } | 2218 | } |
| ... | @@ -2257,6 +2266,7 @@ pub const Dir = struct { | ... | @@ -2257,6 +2266,7 @@ pub const Dir = struct { |
| 2257 | error.Unexpected, | 2266 | error.Unexpected, |
| 2258 | error.InvalidUtf8, | 2267 | error.InvalidUtf8, |
| 2259 | error.BadPathName, | 2268 | error.BadPathName, |
| 2269 | error.NetworkNotFound, | ||
| 2260 | error.DeviceBusy, | 2270 | error.DeviceBusy, |
| 2261 | => |e| return e, | 2271 | => |e| return e, |
| 2262 | }; | 2272 | }; |
| ... | @@ -2283,6 +2293,7 @@ pub const Dir = struct { | ... | @@ -2283,6 +2293,7 @@ pub const Dir = struct { |
| 2283 | error.FileSystem, | 2293 | error.FileSystem, |
| 2284 | error.FileBusy, | 2294 | error.FileBusy, |
| 2285 | error.BadPathName, | 2295 | error.BadPathName, |
| 2296 | error.NetworkNotFound, | ||
| 2286 | error.Unexpected, | 2297 | error.Unexpected, |
| 2287 | => |e| return e, | 2298 | => |e| return e, |
| 2288 | } | 2299 | } |
| ... | @@ -2353,6 +2364,7 @@ pub const Dir = struct { | ... | @@ -2353,6 +2364,7 @@ pub const Dir = struct { |
| 2353 | error.Unexpected, | 2364 | error.Unexpected, |
| 2354 | error.InvalidUtf8, | 2365 | error.InvalidUtf8, |
| 2355 | error.BadPathName, | 2366 | error.BadPathName, |
| 2367 | error.NetworkNotFound, | ||
| 2356 | error.DeviceBusy, | 2368 | error.DeviceBusy, |
| 2357 | => |e| return e, | 2369 | => |e| return e, |
| 2358 | }; | 2370 | }; |
| ... | @@ -2386,6 +2398,7 @@ pub const Dir = struct { | ... | @@ -2386,6 +2398,7 @@ pub const Dir = struct { |
| 2386 | error.FileSystem, | 2398 | error.FileSystem, |
| 2387 | error.FileBusy, | 2399 | error.FileBusy, |
| 2388 | error.BadPathName, | 2400 | error.BadPathName, |
| 2401 | error.NetworkNotFound, | ||
| 2389 | error.Unexpected, | 2402 | error.Unexpected, |
| 2390 | => |e| return e, | 2403 | => |e| return e, |
| 2391 | } | 2404 | } |
| ... | @@ -2446,6 +2459,7 @@ pub const Dir = struct { | ... | @@ -2446,6 +2459,7 @@ pub const Dir = struct { |
| 2446 | error.InvalidUtf8, | 2459 | error.InvalidUtf8, |
| 2447 | error.BadPathName, | 2460 | error.BadPathName, |
| 2448 | error.DeviceBusy, | 2461 | error.DeviceBusy, |
| 2462 | error.NetworkNotFound, | ||
| 2449 | => |e| return e, | 2463 | => |e| return e, |
| 2450 | }; | 2464 | }; |
| 2451 | } else { | 2465 | } else { |
| ... | @@ -2469,6 +2483,7 @@ pub const Dir = struct { | ... | @@ -2469,6 +2483,7 @@ pub const Dir = struct { |
| 2469 | error.FileSystem, | 2483 | error.FileSystem, |
| 2470 | error.FileBusy, | 2484 | error.FileBusy, |
| 2471 | error.BadPathName, | 2485 | error.BadPathName, |
| 2486 | error.NetworkNotFound, | ||
| 2472 | error.Unexpected, | 2487 | error.Unexpected, |
| 2473 | => |e| return e, | 2488 | => |e| return e, |
| 2474 | } | 2489 | } |
lib/std/fs/file.zig+2| ... | @@ -73,6 +73,8 @@ pub const File = struct { | ... | @@ -73,6 +73,8 @@ pub const File = struct { |
| 73 | /// '/', '*', '?', '"', '<', '>', '|' | 73 | /// '/', '*', '?', '"', '<', '>', '|' |
| 74 | BadPathName, | 74 | BadPathName, |
| 75 | Unexpected, | 75 | Unexpected, |
| 76 | /// On Windows, `\\server` or `\\server\share` was not found. | ||
| 77 | NetworkNotFound, | ||
| 76 | } || os.OpenError || os.FlockError; | 78 | } || os.OpenError || os.FlockError; |
| 77 | 79 | ||
| 78 | pub const OpenMode = enum { | 80 | pub const OpenMode = enum { |
lib/std/os.zig+15| ... | @@ -1463,6 +1463,9 @@ pub const OpenError = error{ | ... | @@ -1463,6 +1463,9 @@ pub const OpenError = error{ |
| 1463 | BadPathName, | 1463 | BadPathName, |
| 1464 | InvalidUtf8, | 1464 | InvalidUtf8, |
| 1465 | 1465 | ||
| 1466 | /// On Windows, `\\server` or `\\server\share` was not found. | ||
| 1467 | NetworkNotFound, | ||
| 1468 | |||
| 1466 | /// One of these three things: | 1469 | /// One of these three things: |
| 1467 | /// * pathname refers to an executable image which is currently being | 1470 | /// * pathname refers to an executable image which is currently being |
| 1468 | /// executed and write access was requested. | 1471 | /// executed and write access was requested. |
| ... | @@ -2307,6 +2310,9 @@ pub const UnlinkError = error{ | ... | @@ -2307,6 +2310,9 @@ pub const UnlinkError = error{ |
| 2307 | /// On Windows, file paths cannot contain these characters: | 2310 | /// On Windows, file paths cannot contain these characters: |
| 2308 | /// '/', '*', '?', '"', '<', '>', '|' | 2311 | /// '/', '*', '?', '"', '<', '>', '|' |
| 2309 | BadPathName, | 2312 | BadPathName, |
| 2313 | |||
| 2314 | /// On Windows, `\\server` or `\\server\share` was not found. | ||
| 2315 | NetworkNotFound, | ||
| 2310 | } || UnexpectedError; | 2316 | } || UnexpectedError; |
| 2311 | 2317 | ||
| 2312 | /// Delete a name and possibly the file it refers to. | 2318 | /// Delete a name and possibly the file it refers to. |
| ... | @@ -2472,6 +2478,8 @@ pub const RenameError = error{ | ... | @@ -2472,6 +2478,8 @@ pub const RenameError = error{ |
| 2472 | NoDevice, | 2478 | NoDevice, |
| 2473 | SharingViolation, | 2479 | SharingViolation, |
| 2474 | PipeBusy, | 2480 | PipeBusy, |
| 2481 | /// On Windows, `\\server` or `\\server\share` was not found. | ||
| 2482 | NetworkNotFound, | ||
| 2475 | } || UnexpectedError; | 2483 | } || UnexpectedError; |
| 2476 | 2484 | ||
| 2477 | /// Change the name or location of a file. | 2485 | /// Change the name or location of a file. |
| ... | @@ -2777,6 +2785,8 @@ pub const MakeDirError = error{ | ... | @@ -2777,6 +2785,8 @@ pub const MakeDirError = error{ |
| 2777 | InvalidUtf8, | 2785 | InvalidUtf8, |
| 2778 | BadPathName, | 2786 | BadPathName, |
| 2779 | NoDevice, | 2787 | NoDevice, |
| 2788 | /// On Windows, `\\server` or `\\server\share` was not found. | ||
| 2789 | NetworkNotFound, | ||
| 2780 | } || UnexpectedError; | 2790 | } || UnexpectedError; |
| 2781 | 2791 | ||
| 2782 | /// Create a directory. | 2792 | /// Create a directory. |
| ... | @@ -2850,6 +2860,8 @@ pub const DeleteDirError = error{ | ... | @@ -2850,6 +2860,8 @@ pub const DeleteDirError = error{ |
| 2850 | ReadOnlyFileSystem, | 2860 | ReadOnlyFileSystem, |
| 2851 | InvalidUtf8, | 2861 | InvalidUtf8, |
| 2852 | BadPathName, | 2862 | BadPathName, |
| 2863 | /// On Windows, `\\server` or `\\server\share` was not found. | ||
| 2864 | NetworkNotFound, | ||
| 2853 | } || UnexpectedError; | 2865 | } || UnexpectedError; |
| 2854 | 2866 | ||
| 2855 | /// Deletes an empty directory. | 2867 | /// Deletes an empty directory. |
| ... | @@ -5067,6 +5079,9 @@ pub const RealPathError = error{ | ... | @@ -5067,6 +5079,9 @@ pub const RealPathError = error{ |
| 5067 | /// On Windows, file paths must be valid Unicode. | 5079 | /// On Windows, file paths must be valid Unicode. |
| 5068 | InvalidUtf8, | 5080 | InvalidUtf8, |
| 5069 | 5081 | ||
| 5082 | /// On Windows, `\\server` or `\\server\share` was not found. | ||
| 5083 | NetworkNotFound, | ||
| 5084 | |||
| 5070 | PathAlreadyExists, | 5085 | PathAlreadyExists, |
| 5071 | } || UnexpectedError; | 5086 | } || UnexpectedError; |
| 5072 | 5087 |
lib/std/os/windows.zig+11| ... | @@ -46,6 +46,7 @@ pub const OpenError = error{ | ... | @@ -46,6 +46,7 @@ pub const OpenError = error{ |
| 46 | Unexpected, | 46 | Unexpected, |
| 47 | NameTooLong, | 47 | NameTooLong, |
| 48 | WouldBlock, | 48 | WouldBlock, |
| 49 | NetworkNotFound, | ||
| 49 | }; | 50 | }; |
| 50 | 51 | ||
| 51 | pub const OpenFileOptions = struct { | 52 | pub const OpenFileOptions = struct { |
| ... | @@ -130,6 +131,8 @@ pub fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!HAN | ... | @@ -130,6 +131,8 @@ pub fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!HAN |
| 130 | .OBJECT_NAME_INVALID => unreachable, | 131 | .OBJECT_NAME_INVALID => unreachable, |
| 131 | .OBJECT_NAME_NOT_FOUND => return error.FileNotFound, | 132 | .OBJECT_NAME_NOT_FOUND => return error.FileNotFound, |
| 132 | .OBJECT_PATH_NOT_FOUND => return error.FileNotFound, | 133 | .OBJECT_PATH_NOT_FOUND => return error.FileNotFound, |
| 134 | .BAD_NETWORK_PATH => return error.NetworkNotFound, // \\server was not found | ||
| 135 | .BAD_NETWORK_NAME => return error.NetworkNotFound, // \\server was found but \\server\share wasn't | ||
| 133 | .NO_MEDIA_IN_DEVICE => return error.NoDevice, | 136 | .NO_MEDIA_IN_DEVICE => return error.NoDevice, |
| 134 | .INVALID_PARAMETER => unreachable, | 137 | .INVALID_PARAMETER => unreachable, |
| 135 | .SHARING_VIOLATION => return error.AccessDenied, | 138 | .SHARING_VIOLATION => return error.AccessDenied, |
| ... | @@ -700,6 +703,7 @@ pub const CreateSymbolicLinkError = error{ | ... | @@ -700,6 +703,7 @@ pub const CreateSymbolicLinkError = error{ |
| 700 | FileNotFound, | 703 | FileNotFound, |
| 701 | NameTooLong, | 704 | NameTooLong, |
| 702 | NoDevice, | 705 | NoDevice, |
| 706 | NetworkNotFound, | ||
| 703 | Unexpected, | 707 | Unexpected, |
| 704 | }; | 708 | }; |
| 705 | 709 | ||
| ... | @@ -812,6 +816,9 @@ pub fn ReadLink(dir: ?HANDLE, sub_path_w: []const u16, out_buffer: []u8) ReadLin | ... | @@ -812,6 +816,9 @@ pub fn ReadLink(dir: ?HANDLE, sub_path_w: []const u16, out_buffer: []u8) ReadLin |
| 812 | .OBJECT_NAME_NOT_FOUND => return error.FileNotFound, | 816 | .OBJECT_NAME_NOT_FOUND => return error.FileNotFound, |
| 813 | .OBJECT_PATH_NOT_FOUND => return error.FileNotFound, | 817 | .OBJECT_PATH_NOT_FOUND => return error.FileNotFound, |
| 814 | .NO_MEDIA_IN_DEVICE => return error.FileNotFound, | 818 | .NO_MEDIA_IN_DEVICE => return error.FileNotFound, |
| 819 | // TODO: Should BAD_NETWORK_* be translated to a different error? | ||
| 820 | .BAD_NETWORK_PATH => return error.FileNotFound, // \\server was not found | ||
| 821 | .BAD_NETWORK_NAME => return error.FileNotFound, // \\server was found but \\server\share wasn't | ||
| 815 | .INVALID_PARAMETER => unreachable, | 822 | .INVALID_PARAMETER => unreachable, |
| 816 | .SHARING_VIOLATION => return error.AccessDenied, | 823 | .SHARING_VIOLATION => return error.AccessDenied, |
| 817 | .ACCESS_DENIED => return error.AccessDenied, | 824 | .ACCESS_DENIED => return error.AccessDenied, |
| ... | @@ -873,6 +880,7 @@ pub const DeleteFileError = error{ | ... | @@ -873,6 +880,7 @@ pub const DeleteFileError = error{ |
| 873 | NotDir, | 880 | NotDir, |
| 874 | IsDir, | 881 | IsDir, |
| 875 | DirNotEmpty, | 882 | DirNotEmpty, |
| 883 | NetworkNotFound, | ||
| 876 | }; | 884 | }; |
| 877 | 885 | ||
| 878 | pub const DeleteFileOptions = struct { | 886 | pub const DeleteFileOptions = struct { |
| ... | @@ -931,6 +939,8 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil | ... | @@ -931,6 +939,8 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil |
| 931 | .OBJECT_NAME_INVALID => unreachable, | 939 | .OBJECT_NAME_INVALID => unreachable, |
| 932 | .OBJECT_NAME_NOT_FOUND => return error.FileNotFound, | 940 | .OBJECT_NAME_NOT_FOUND => return error.FileNotFound, |
| 933 | .OBJECT_PATH_NOT_FOUND => return error.FileNotFound, | 941 | .OBJECT_PATH_NOT_FOUND => return error.FileNotFound, |
| 942 | .BAD_NETWORK_PATH => return error.NetworkNotFound, // \\server was not found | ||
| 943 | .BAD_NETWORK_NAME => return error.NetworkNotFound, // \\server was found but \\server\share wasn't | ||
| 934 | .INVALID_PARAMETER => unreachable, | 944 | .INVALID_PARAMETER => unreachable, |
| 935 | .FILE_IS_A_DIRECTORY => return error.IsDir, | 945 | .FILE_IS_A_DIRECTORY => return error.IsDir, |
| 936 | .NOT_A_DIRECTORY => return error.NotDir, | 946 | .NOT_A_DIRECTORY => return error.NotDir, |
| ... | @@ -1207,6 +1217,7 @@ pub fn GetFinalPathNameByHandle( | ... | @@ -1207,6 +1217,7 @@ pub fn GetFinalPathNameByHandle( |
| 1207 | error.PipeBusy => unreachable, | 1217 | error.PipeBusy => unreachable, |
| 1208 | error.PathAlreadyExists => unreachable, | 1218 | error.PathAlreadyExists => unreachable, |
| 1209 | error.WouldBlock => unreachable, | 1219 | error.WouldBlock => unreachable, |
| 1220 | error.NetworkNotFound => unreachable, | ||
| 1210 | else => |e| return e, | 1221 | else => |e| return e, |
| 1211 | }; | 1222 | }; |
| 1212 | defer CloseHandle(mgmt_handle); | 1223 | defer CloseHandle(mgmt_handle); |
lib/std/zig/system/NativeTargetInfo.zig+3| ... | @@ -338,6 +338,7 @@ fn detectAbiAndDynamicLinker( | ... | @@ -338,6 +338,7 @@ fn detectAbiAndDynamicLinker( |
| 338 | error.AccessDenied, | 338 | error.AccessDenied, |
| 339 | error.NoDevice, | 339 | error.NoDevice, |
| 340 | error.FileNotFound, | 340 | error.FileNotFound, |
| 341 | error.NetworkNotFound, | ||
| 341 | error.FileTooBig, | 342 | error.FileTooBig, |
| 342 | error.Unexpected, | 343 | error.Unexpected, |
| 343 | => |e| { | 344 | => |e| { |
| ... | @@ -401,6 +402,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion { | ... | @@ -401,6 +402,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion { |
| 401 | error.InvalidUtf8 => unreachable, | 402 | error.InvalidUtf8 => unreachable, |
| 402 | error.BadPathName => unreachable, | 403 | error.BadPathName => unreachable, |
| 403 | error.DeviceBusy => unreachable, | 404 | error.DeviceBusy => unreachable, |
| 405 | error.NetworkNotFound => unreachable, // Windows-only | ||
| 404 | 406 | ||
| 405 | error.FileNotFound, | 407 | error.FileNotFound, |
| 406 | error.NotDir, | 408 | error.NotDir, |
| ... | @@ -432,6 +434,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion { | ... | @@ -432,6 +434,7 @@ fn glibcVerFromRPath(rpath: []const u8) !std.SemanticVersion { |
| 432 | error.BadPathName => unreachable, // Windows only | 434 | error.BadPathName => unreachable, // Windows only |
| 433 | error.PipeBusy => unreachable, // Windows-only | 435 | error.PipeBusy => unreachable, // Windows-only |
| 434 | error.SharingViolation => unreachable, // Windows-only | 436 | error.SharingViolation => unreachable, // Windows-only |
| 437 | error.NetworkNotFound => unreachable, // Windows-only | ||
| 435 | error.FileLocksNotSupported => unreachable, // No lock requested. | 438 | error.FileLocksNotSupported => unreachable, // No lock requested. |
| 436 | error.NoSpaceLeft => unreachable, // read-only | 439 | error.NoSpaceLeft => unreachable, // read-only |
| 437 | error.PathAlreadyExists => unreachable, // read-only | 440 | error.PathAlreadyExists => unreachable, // read-only |