Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

get

Public Function
std.process.Preopens.get
pub fn get(p: *const Preopens, name: []const u8) ?Resource

Params

File

process/Preopens.zig:28
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
pub fn get(p: *const Preopens, name: []const u8) ?Resource {
    switch (native_os) {
        .wasi => {
            const index = p.map.getIndex(name) orelse return null;
            if (index <= 2) return .{ .file = .{
                .handle = @intCast(index),
                .flags = .{ .nonblocking = false },
            } };
            return .{ .dir = .{ .handle = @intCast(index) } };
        },
        else => {
            if (std.mem.eql(u8, name, "stdin")) return .{ .file = .stdin() };
            if (std.mem.eql(u8, name, "stdout")) return .{ .file = .stdout() };
            if (std.mem.eql(u8, name, "stderr")) return .{ .file = .stderr() };
            return null;
        },
    }
}