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 standard library.
std › os › plan9 › openat Public Function openat Doc Source Public Function std.os.plan9.openat
pub fn openat (dirfd : i32 , path : [*:0 ]const u8 , flags : u32 , _ : mode_t ) usize Params dirfd : i32 path : [*:0 ]const u8 flags : u32 _ : mode_t File os/plan9.zig: 288
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304 pub fn openat (dirfd : i32 , path : [*:0 ]const u8 , flags : u32 , _ : mode_t ) usize {
// we skip perms because only create supports perms
if (dirfd == AT .FDCWD ) { // openat(AT_FDCWD, ...) == open(...)
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 ; // the allocation shouldn't fail because it should not exceed max_path_bytes
fba .reset ();
const total_path_z = alloc .dupeSentinel (u8 , total_path , 0 ) catch unreachable ; // should not exceed max_path_bytes + 1
return open (total_path_z .ptr , flags );
}