| author | |
| committer | |
| log | 00a3123fbe79d9bb74b2c877130579299d2ba5ba |
| tree | d4a5b531f5d255abe903e3e0c7cb565a0a2245c0 |
| parent | ab003cd0545e54e66410b8e67136d4ef079b3198 |
3 files changed, 22 insertions(+), 16 deletions(-)
lib/std/Io/Threaded.zig+9-10| ... | @@ -211,7 +211,6 @@ pub fn io(t: *Threaded) Io { | ... | @@ -211,7 +211,6 @@ pub fn io(t: *Threaded) Io { |
| 211 | else => dirOpenFilePosix, | 211 | else => dirOpenFilePosix, |
| 212 | }, | 212 | }, |
| 213 | .dirOpenDir = switch (builtin.os.tag) { | 213 | .dirOpenDir = switch (builtin.os.tag) { |
| 214 | .windows => dirOpenDirWindows, | ||
| 215 | .wasi => dirOpenDirWasi, | 214 | .wasi => dirOpenDirWasi, |
| 216 | .haiku => dirOpenDirHaiku, | 215 | .haiku => dirOpenDirHaiku, |
| 217 | else => dirOpenDirPosix, | 216 | else => dirOpenDirPosix, |
| ... | @@ -2035,6 +2034,11 @@ fn dirOpenDirPosix( | ... | @@ -2035,6 +2034,11 @@ fn dirOpenDirPosix( |
| 2035 | ) Io.Dir.OpenError!Io.Dir { | 2034 | ) Io.Dir.OpenError!Io.Dir { |
| 2036 | const t: *Threaded = @ptrCast(@alignCast(userdata)); | 2035 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 2037 | 2036 | ||
| 2037 | if (is_windows) { | ||
| 2038 | const sub_path_w = try windows.sliceToPrefixedFileW(dir.handle, sub_path); | ||
| 2039 | return dirOpenDirWindows(t, dir, sub_path_w.span(), options); | ||
| 2040 | } | ||
| 2041 | |||
| 2038 | var path_buffer: [posix.PATH_MAX]u8 = undefined; | 2042 | var path_buffer: [posix.PATH_MAX]u8 = undefined; |
| 2039 | const sub_path_posix = try pathToPosix(sub_path, &path_buffer); | 2043 | const sub_path_posix = try pathToPosix(sub_path, &path_buffer); |
| 2040 | 2044 | ||
| ... | @@ -2123,19 +2127,13 @@ fn dirOpenDirHaiku( | ... | @@ -2123,19 +2127,13 @@ fn dirOpenDirHaiku( |
| 2123 | } | 2127 | } |
| 2124 | } | 2128 | } |
| 2125 | 2129 | ||
| 2126 | fn dirOpenDirWindows( | 2130 | pub fn dirOpenDirWindows( |
| 2127 | userdata: ?*anyopaque, | 2131 | t: *Io.Threaded, |
| 2128 | dir: Io.Dir, | 2132 | dir: Io.Dir, |
| 2129 | sub_path: []const u8, | 2133 | sub_path_w: [:0]const u16, |
| 2130 | options: Io.Dir.OpenOptions, | 2134 | options: Io.Dir.OpenOptions, |
| 2131 | ) Io.Dir.OpenError!Io.Dir { | 2135 | ) Io.Dir.OpenError!Io.Dir { |
| 2132 | const t: *Threaded = @ptrCast(@alignCast(userdata)); | ||
| 2133 | try t.checkCancel(); | ||
| 2134 | |||
| 2135 | const w = windows; | 2136 | const w = windows; |
| 2136 | const sub_path_w_array = try w.sliceToPrefixedFileW(dir.handle, sub_path); | ||
| 2137 | const sub_path_w = sub_path_w_array.span(); | ||
| 2138 | |||
| 2139 | // TODO remove some of these flags if options.access_sub_paths is false | 2137 | // TODO remove some of these flags if options.access_sub_paths is false |
| 2140 | const base_flags = w.STANDARD_RIGHTS_READ | w.FILE_READ_ATTRIBUTES | w.FILE_READ_EA | | 2138 | const base_flags = w.STANDARD_RIGHTS_READ | w.FILE_READ_ATTRIBUTES | w.FILE_READ_EA | |
| 2141 | w.SYNCHRONIZE | w.FILE_TRAVERSE; | 2139 | w.SYNCHRONIZE | w.FILE_TRAVERSE; |
| ... | @@ -2158,6 +2156,7 @@ fn dirOpenDirWindows( | ... | @@ -2158,6 +2156,7 @@ fn dirOpenDirWindows( |
| 2158 | const open_reparse_point: w.DWORD = if (!options.follow_symlinks) w.FILE_OPEN_REPARSE_POINT else 0x0; | 2156 | const open_reparse_point: w.DWORD = if (!options.follow_symlinks) w.FILE_OPEN_REPARSE_POINT else 0x0; |
| 2159 | var io_status_block: w.IO_STATUS_BLOCK = undefined; | 2157 | var io_status_block: w.IO_STATUS_BLOCK = undefined; |
| 2160 | var result: Io.Dir = .{ .handle = undefined }; | 2158 | var result: Io.Dir = .{ .handle = undefined }; |
| 2159 | try t.checkCancel(); | ||
| 2161 | const rc = w.ntdll.NtCreateFile( | 2160 | const rc = w.ntdll.NtCreateFile( |
| 2162 | &result.handle, | 2161 | &result.handle, |
| 2163 | access_mask, | 2162 | access_mask, |
lib/std/posix.zig+1-2| ... | @@ -3769,7 +3769,6 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne | ... | @@ -3769,7 +3769,6 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne |
| 3769 | .SUCCESS => return, | 3769 | .SUCCESS => return, |
| 3770 | .ACCES => return error.AccessDenied, | 3770 | .ACCES => return error.AccessDenied, |
| 3771 | .PERM => return error.PermissionDenied, | 3771 | .PERM => return error.PermissionDenied, |
| 3772 | .ADDRINUSE => return error.AddressInUse, | ||
| 3773 | .ADDRNOTAVAIL => return error.AddressUnavailable, | 3772 | .ADDRNOTAVAIL => return error.AddressUnavailable, |
| 3774 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, | 3773 | .AFNOSUPPORT => return error.AddressFamilyUnsupported, |
| 3775 | .AGAIN, .INPROGRESS => return error.WouldBlock, | 3774 | .AGAIN, .INPROGRESS => return error.WouldBlock, |
| ... | @@ -3779,7 +3778,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne | ... | @@ -3779,7 +3778,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne |
| 3779 | .CONNRESET => return error.ConnectionResetByPeer, | 3778 | .CONNRESET => return error.ConnectionResetByPeer, |
| 3780 | .FAULT => unreachable, // The socket structure address is outside the user's address space. | 3779 | .FAULT => unreachable, // The socket structure address is outside the user's address space. |
| 3781 | .INTR => continue, | 3780 | .INTR => continue, |
| 3782 | .ISCONN => return error.AlreadyConnected, // The socket is already connected. | 3781 | .ISCONN => @panic("AlreadyConnected"), // The socket is already connected. |
| 3783 | .HOSTUNREACH => return error.NetworkUnreachable, | 3782 | .HOSTUNREACH => return error.NetworkUnreachable, |
| 3784 | .NETUNREACH => return error.NetworkUnreachable, | 3783 | .NETUNREACH => return error.NetworkUnreachable, |
| 3785 | .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. | 3784 | .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. |
lib/std/process/Child.zig+12-4| ... | @@ -1084,16 +1084,24 @@ fn windowsCreateProcessPathExt( | ... | @@ -1084,16 +1084,24 @@ fn windowsCreateProcessPathExt( |
| 1084 | // or a version with a supported PATHEXT appended. We then try calling CreateProcessW | 1084 | // or a version with a supported PATHEXT appended. We then try calling CreateProcessW |
| 1085 | // with the found versions in the appropriate order. | 1085 | // with the found versions in the appropriate order. |
| 1086 | 1086 | ||
| 1087 | // In the future, child process execution needs to move to Io implementation. | ||
| 1088 | // Under those conditions, here we will have access to lower level directory | ||
| 1089 | // opening function knowing which implementation we are in. Here, we imitate | ||
| 1090 | // that scenario. | ||
| 1091 | var threaded: std.Io.Threaded = .init_single_threaded; | ||
| 1092 | const io = threaded.io(); | ||
| 1093 | |||
| 1087 | var dir = dir: { | 1094 | var dir = dir: { |
| 1088 | // needs to be null-terminated | 1095 | // needs to be null-terminated |
| 1089 | try dir_buf.append(allocator, 0); | 1096 | try dir_buf.append(allocator, 0); |
| 1090 | defer dir_buf.shrinkRetainingCapacity(dir_path_len); | 1097 | defer dir_buf.shrinkRetainingCapacity(dir_path_len); |
| 1091 | const dir_path_z = dir_buf.items[0 .. dir_buf.items.len - 1 :0]; | 1098 | const dir_path_z = dir_buf.items[0 .. dir_buf.items.len - 1 :0]; |
| 1092 | const prefixed_path = try windows.wToPrefixedFileW(null, dir_path_z); | 1099 | const prefixed_path = try windows.wToPrefixedFileW(null, dir_path_z); |
| 1093 | break :dir fs.cwd().openDirW(prefixed_path.span().ptr, .{ .iterate = true }) catch | 1100 | break :dir threaded.dirOpenDirWindows(.cwd(), prefixed_path.span(), .{ |
| 1094 | return error.FileNotFound; | 1101 | .iterate = true, |
| 1102 | }) catch return error.FileNotFound; | ||
| 1095 | }; | 1103 | }; |
| 1096 | defer dir.close(); | 1104 | defer dir.close(io); |
| 1097 | 1105 | ||
| 1098 | // Add wildcard and null-terminator | 1106 | // Add wildcard and null-terminator |
| 1099 | try app_buf.append(allocator, '*'); | 1107 | try app_buf.append(allocator, '*'); |
| ... | @@ -1127,7 +1135,7 @@ fn windowsCreateProcessPathExt( | ... | @@ -1127,7 +1135,7 @@ fn windowsCreateProcessPathExt( |
| 1127 | .Buffer = @constCast(app_name_wildcard.ptr), | 1135 | .Buffer = @constCast(app_name_wildcard.ptr), |
| 1128 | }; | 1136 | }; |
| 1129 | const rc = windows.ntdll.NtQueryDirectoryFile( | 1137 | const rc = windows.ntdll.NtQueryDirectoryFile( |
| 1130 | dir.fd, | 1138 | dir.handle, |
| 1131 | null, | 1139 | null, |
| 1132 | null, | 1140 | null, |
| 1133 | null, | 1141 | null, |