Zig 0.17.0-dev (Split by item)

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 library itself.

posixGetUserInfo

TODO this reads /etc/passwd. But sometimes the user/id mapping is in something else like NIS, AD, etc. See man nss or look at an strace for id myuser.

process.posixGetUserInfo
pub fn posixGetUserInfo(io: Io, name: []const u8) !UserInfo

File

lib/std/process.zig:126

Code

pub fn posixGetUserInfo(io: Io, name: []const u8) !UserInfo {
    const file = try Io.Dir.openFileAbsolute(io, "/etc/passwd", .{});
    defer file.close(io);
    var buffer: [4096]u8 = undefined;
    var file_reader = file.reader(&buffer);
    return posixGetUserInfoPasswdStream(name, &file_reader.interface) catch |err| switch (err) {
        error.ReadFailed => return file_reader.err.?,
        error.EndOfStream => return error.UserNotFound,
        error.CorruptPasswordFile => |e| return e,
    };
}