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 › Build › tryFindProgram Private Function tryFindProgram Doc Source Private Function std.Build.tryFindProgram
fn tryFindProgram (b : *Build , full_path : []const u8 ) ?[]const u8 Params b : *Build full_path : []const u8 File Build.zig: 1658
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698 fn tryFindProgram (b : *Build , full_path : []const u8 ) ?[]const u8 {
const graph = b .graph ;
const io = graph .io ;
const arena = graph .arena ;
if (Io .Dir .cwd ().access (io , full_path , .{ .execute = true })) |_ | {
return full_path ;
} else |err | switch (err ) {
error .FileNotFound , error .AccessDenied , error .PermissionDenied => |e | {
if (graph .verbose ) log .info ("searched: {t} {s}" , .{ e , full_path });
},
else => |e | return panic ("failed accessing {s}: {t}" , .{ full_path , e }),
}
if (builtin .os .tag == .windows ) {
if (b .graph .environ_map .get ("PATHEXT" )) |PATHEXT | {
var it = mem .tokenizeScalar (u8 , PATHEXT , fs .path .delimiter );
const extended_path_buf = arena .alloc (u8 , full_path .len + 1 + std .process .WindowsExtension .max_len ) catch @panic ("OOM" );
@memcpy (extended_path_buf [0 ..full_path .len ], full_path );
while (it .next ()) |ext | {
if (!supportedWindowsProgramExtension (ext )) continue ;
@memcpy (extended_path_buf [full_path .len ..][0 ..ext .len ], ext );
const extended_path = extended_path_buf [0 .. full_path .len + ext .len ];
if (Io .Dir .cwd ().access (io , extended_path , .{ .execute = true })) |_ | {
return extended_path ;
} else |err | switch (err ) {
error .FileNotFound , error .AccessDenied , error .PermissionDenied => |e | {
if (graph .verbose ) log .info ("searched: {t} {s}" , .{ e , extended_path });
},
else => |e | return panic ("failed accessing {s}: {t}" , .{ extended_path , e }),
}
}
}
}
return null ;
}