| ... | ... | @@ -2312,11 +2312,7 @@ pub fn chdir(dir_path: []const u8) ChangeCurDirError!void { |
| 2312 | 2312 | var utf16_dir_path: [windows.PATH_MAX_WIDE]u16 = undefined; |
| 2313 | 2313 | const len = try std.unicode.utf8ToUtf16Le(utf16_dir_path[0..], dir_path); |
| 2314 | 2314 | if (len > utf16_dir_path.len) return error.NameTooLong; |
| 2315 | | |
| 2316 | | windows.SetCurrentDirectory(utf16_dir_path[0..len]) catch |err| switch (err) { |
| 2317 | | error.NoDevice => return error.FileSystem, |
| 2318 | | else => |e| return e, |
| 2319 | | }; |
| 2315 | return chdirW(utf16_dir_path[0..len]); |
| 2320 | 2316 | } else { |
| 2321 | 2317 | const dir_path_c = try toPosixPath(dir_path); |
| 2322 | 2318 | return chdirZ(&dir_path_c); |
| ... | ... | @@ -2328,7 +2324,10 @@ pub const chdirC = @compileError("deprecated: renamed to chdirZ"); |
| 2328 | 2324 | /// Same as `chdir` except the parameter is null-terminated. |
| 2329 | 2325 | pub fn chdirZ(dir_path: [*:0]const u8) ChangeCurDirError!void { |
| 2330 | 2326 | if (builtin.os.tag == .windows) { |
| 2331 | | return chdir(mem.spanZ(dir_path)); |
| 2327 | var utf16_dir_path: [windows.PATH_MAX_WIDE]u16 = undefined; |
| 2328 | const len = try std.unicode.utf8ToUtf16Le(utf16_dir_path[0..], dir_path); |
| 2329 | if (len > utf16_dir_path.len) return error.NameTooLong; |
| 2330 | return chdirW(utf16_dir_path[0..len]); |
| 2332 | 2331 | } |
| 2333 | 2332 | switch (errno(system.chdir(dir_path))) { |
| 2334 | 2333 | 0 => return, |
| ... | ... | @@ -2344,6 +2343,14 @@ pub fn chdirZ(dir_path: [*:0]const u8) ChangeCurDirError!void { |
| 2344 | 2343 | } |
| 2345 | 2344 | } |
| 2346 | 2345 | |
| 2346 | /// Windows-only. Same as `chdir` except the paramter is WTF16 encoded. |
| 2347 | pub fn chdirW(dir_path: []const u16) ChangeCurDirError!void { |
| 2348 | windows.SetCurrentDirectory(dir_path) catch |err| switch (err) { |
| 2349 | error.NoDevice => return error.FileSystem, |
| 2350 | else => |e| return e, |
| 2351 | }; |
| 2352 | } |
| 2353 | |
| 2347 | 2354 | pub const FchdirError = error{ |
| 2348 | 2355 | AccessDenied, |
| 2349 | 2356 | NotDir, |