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 › Io › Threaded › dirCreateDirPath Private Function dirCreateDirPath Doc Source Private Function std.Io.Threaded.dirCreateDirPath
fn dirCreateDirPath (
userdata : ?*anyopaque ,
dir : Dir ,
sub_path : []const u8 ,
permissions : Dir .Permissions ,
) Dir .CreateDirPathError !Dir .CreatePathStatus Params userdata : ?*anyopaque dir : Dir sub_path : []const u8 permissions : Dir .Permissions File Io/Threaded.zig: 3518
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548 fn dirCreateDirPath (
userdata : ?*anyopaque ,
dir : Dir ,
sub_path : []const u8 ,
permissions : Dir .Permissions ,
) Dir .CreateDirPathError !Dir .CreatePathStatus {
const t : *Threaded = @ptrCast (@alignCast (userdata ));
var it = Dir .path .componentIterator (sub_path );
var status : Dir .CreatePathStatus = .existed ;
var component = it .last () orelse return error .BadPathName ;
while (true ) {
if (dirCreateDir (t , dir , component .path , permissions )) |_ | {
status = .created ;
} else |err | switch (err ) {
error .PathAlreadyExists => {
// It is important to return an error if it's not a directory
// because otherwise a dangling symlink could cause an infinite
// loop.
const kind = try filePathKind (t , dir , component .path );
if (kind != .directory ) return error .NotDir ;
},
error .FileNotFound => |e | {
component = it .previous () orelse return e ;
continue ;
},
else => |e | return e ,
}
component = it .next () orelse return status ;
}
}