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 › Dispatch › dirCreateDirPath Private Function dirCreateDirPath Doc Source Private Function std.Io.Dispatch.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/Dispatch.zig: 2294
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324 fn dirCreateDirPath (
userdata : ?*anyopaque ,
dir : Dir ,
sub_path : []const u8 ,
permissions : Dir .Permissions ,
) Dir .CreateDirPathError !Dir .CreatePathStatus {
const ev : *Evented = @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 (ev , 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 fstat = try dirStatFile (ev , dir , component .path , .{});
if (fstat .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 ;
}
}