mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.process.Child: update for std.Io changes
This commit is contained in:
parent
ab003cd054
commit
00a3123fbe
3 changed files with 22 additions and 16 deletions
|
|
@ -211,7 +211,6 @@ pub fn io(t: *Threaded) Io {
|
|||
else => dirOpenFilePosix,
|
||||
},
|
||||
.dirOpenDir = switch (builtin.os.tag) {
|
||||
.windows => dirOpenDirWindows,
|
||||
.wasi => dirOpenDirWasi,
|
||||
.haiku => dirOpenDirHaiku,
|
||||
else => dirOpenDirPosix,
|
||||
|
|
@ -2035,6 +2034,11 @@ fn dirOpenDirPosix(
|
|||
) Io.Dir.OpenError!Io.Dir {
|
||||
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
||||
|
||||
if (is_windows) {
|
||||
const sub_path_w = try windows.sliceToPrefixedFileW(dir.handle, sub_path);
|
||||
return dirOpenDirWindows(t, dir, sub_path_w.span(), options);
|
||||
}
|
||||
|
||||
var path_buffer: [posix.PATH_MAX]u8 = undefined;
|
||||
const sub_path_posix = try pathToPosix(sub_path, &path_buffer);
|
||||
|
||||
|
|
@ -2123,19 +2127,13 @@ fn dirOpenDirHaiku(
|
|||
}
|
||||
}
|
||||
|
||||
fn dirOpenDirWindows(
|
||||
userdata: ?*anyopaque,
|
||||
pub fn dirOpenDirWindows(
|
||||
t: *Io.Threaded,
|
||||
dir: Io.Dir,
|
||||
sub_path: []const u8,
|
||||
sub_path_w: [:0]const u16,
|
||||
options: Io.Dir.OpenOptions,
|
||||
) Io.Dir.OpenError!Io.Dir {
|
||||
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
||||
try t.checkCancel();
|
||||
|
||||
const w = windows;
|
||||
const sub_path_w_array = try w.sliceToPrefixedFileW(dir.handle, sub_path);
|
||||
const sub_path_w = sub_path_w_array.span();
|
||||
|
||||
// TODO remove some of these flags if options.access_sub_paths is false
|
||||
const base_flags = w.STANDARD_RIGHTS_READ | w.FILE_READ_ATTRIBUTES | w.FILE_READ_EA |
|
||||
w.SYNCHRONIZE | w.FILE_TRAVERSE;
|
||||
|
|
@ -2158,6 +2156,7 @@ fn dirOpenDirWindows(
|
|||
const open_reparse_point: w.DWORD = if (!options.follow_symlinks) w.FILE_OPEN_REPARSE_POINT else 0x0;
|
||||
var io_status_block: w.IO_STATUS_BLOCK = undefined;
|
||||
var result: Io.Dir = .{ .handle = undefined };
|
||||
try t.checkCancel();
|
||||
const rc = w.ntdll.NtCreateFile(
|
||||
&result.handle,
|
||||
access_mask,
|
||||
|
|
|
|||
|
|
@ -3769,7 +3769,6 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne
|
|||
.SUCCESS => return,
|
||||
.ACCES => return error.AccessDenied,
|
||||
.PERM => return error.PermissionDenied,
|
||||
.ADDRINUSE => return error.AddressInUse,
|
||||
.ADDRNOTAVAIL => return error.AddressUnavailable,
|
||||
.AFNOSUPPORT => return error.AddressFamilyUnsupported,
|
||||
.AGAIN, .INPROGRESS => return error.WouldBlock,
|
||||
|
|
@ -3779,7 +3778,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne
|
|||
.CONNRESET => return error.ConnectionResetByPeer,
|
||||
.FAULT => unreachable, // The socket structure address is outside the user's address space.
|
||||
.INTR => continue,
|
||||
.ISCONN => return error.AlreadyConnected, // The socket is already connected.
|
||||
.ISCONN => @panic("AlreadyConnected"), // The socket is already connected.
|
||||
.HOSTUNREACH => return error.NetworkUnreachable,
|
||||
.NETUNREACH => return error.NetworkUnreachable,
|
||||
.NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.
|
||||
|
|
|
|||
|
|
@ -1084,16 +1084,24 @@ fn windowsCreateProcessPathExt(
|
|||
// or a version with a supported PATHEXT appended. We then try calling CreateProcessW
|
||||
// with the found versions in the appropriate order.
|
||||
|
||||
// In the future, child process execution needs to move to Io implementation.
|
||||
// Under those conditions, here we will have access to lower level directory
|
||||
// opening function knowing which implementation we are in. Here, we imitate
|
||||
// that scenario.
|
||||
var threaded: std.Io.Threaded = .init_single_threaded;
|
||||
const io = threaded.io();
|
||||
|
||||
var dir = dir: {
|
||||
// needs to be null-terminated
|
||||
try dir_buf.append(allocator, 0);
|
||||
defer dir_buf.shrinkRetainingCapacity(dir_path_len);
|
||||
const dir_path_z = dir_buf.items[0 .. dir_buf.items.len - 1 :0];
|
||||
const prefixed_path = try windows.wToPrefixedFileW(null, dir_path_z);
|
||||
break :dir fs.cwd().openDirW(prefixed_path.span().ptr, .{ .iterate = true }) catch
|
||||
return error.FileNotFound;
|
||||
break :dir threaded.dirOpenDirWindows(.cwd(), prefixed_path.span(), .{
|
||||
.iterate = true,
|
||||
}) catch return error.FileNotFound;
|
||||
};
|
||||
defer dir.close();
|
||||
defer dir.close(io);
|
||||
|
||||
// Add wildcard and null-terminator
|
||||
try app_buf.append(allocator, '*');
|
||||
|
|
@ -1127,7 +1135,7 @@ fn windowsCreateProcessPathExt(
|
|||
.Buffer = @constCast(app_name_wildcard.ptr),
|
||||
};
|
||||
const rc = windows.ntdll.NtQueryDirectoryFile(
|
||||
dir.fd,
|
||||
dir.handle,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue