| ... | ... | @@ -562,28 +562,25 @@ pub const SetCurrentDirectoryError = error{ |
| 562 | 562 | NotDir, |
| 563 | 563 | AccessDenied, |
| 564 | 564 | NoDevice, |
| 565 | BadPathName, |
| 565 | 566 | Unexpected, |
| 566 | 567 | }; |
| 567 | 568 | |
| 568 | | pub fn SetCurrentDirectory(path_name: []const u8) SetCurrentDirectoryError!void { |
| 569 | | var path_space: PathSpace = undefined; |
| 570 | | path_space.len = try std.unicode.utf8ToUtf16Le(path_space.data[0..], path_name); |
| 571 | | if (path_space.len > path_space.data.len) return error.NameTooLong; |
| 572 | | |
| 573 | | const path_len_bytes = math.cast(u16, path_space.len * 2) catch |err| switch (err) { |
| 569 | pub fn SetCurrentDirectory(path_name: []const u16) SetCurrentDirectoryError!void { |
| 570 | const path_len_bytes = math.cast(u16, path_name.len * 2) catch |err| switch (err) { |
| 574 | 571 | error.Overflow => return error.NameTooLong, |
| 575 | 572 | }; |
| 576 | 573 | |
| 577 | 574 | var nt_name = UNICODE_STRING{ |
| 578 | 575 | .Length = path_len_bytes, |
| 579 | 576 | .MaximumLength = path_len_bytes, |
| 580 | | .Buffer = @intToPtr([*]u16, @ptrToInt(&path_space.data)), |
| 577 | .Buffer = @intToPtr([*]u16, @ptrToInt(path_name.ptr)), |
| 581 | 578 | }; |
| 582 | 579 | |
| 583 | 580 | const rc = ntdll.RtlSetCurrentDirectory_U(&nt_name); |
| 584 | 581 | switch (rc) { |
| 585 | 582 | .SUCCESS => {}, |
| 586 | | .OBJECT_NAME_INVALID => unreachable, |
| 583 | .OBJECT_NAME_INVALID => return error.BadPathName, |
| 587 | 584 | .OBJECT_NAME_NOT_FOUND => return error.FileNotFound, |
| 588 | 585 | .OBJECT_PATH_NOT_FOUND => return error.FileNotFound, |
| 589 | 586 | .NO_MEDIA_IN_DEVICE => return error.NoDevice, |