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.
Zig › std/ › os/ › plan9.zig › openat
openat
plan9.openat
pub fn openat (dirfd : i32 , path : [*:0 ]const u8 , flags : u32 , _ : mode_t ) usize
File
Code
pub fn openat (dirfd : i32 , path : [*:0 ]const u8 , flags : u32 , _ : mode_t ) usize {
if (dirfd == AT .FDCWD ) {
return open (path , flags );
}
var dir_path_buf : [std .fs .max_path_bytes ]u8 = undefined ;
var total_path_buf : [std .fs .max_path_bytes + 1 ]u8 = undefined ;
const rc = fd2path (dirfd , &dir_path_buf , std .fs .max_path_bytes );
if (rc != 0 ) return rc ;
var fba = std .heap .FixedBufferAllocator .init (&total_path_buf );
var alloc = fba .allocator ();
const dir_path = std .mem .span (@as ([*:0 ]u8 , @ptrCast (&dir_path_buf )));
const total_path = std .fs .path .join (alloc , &.{ dir_path , std .mem .span (path ) }) catch unreachable ;
fba .reset ();
const total_path_z = alloc .dupeSentinel (u8 , total_path , 0 ) catch unreachable ;
return open (total_path_z .ptr , flags );
}