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.

findPrefixResolved

Takes ownership of resolved_path on success.

Cache.findPrefixResolved
fn findPrefixResolved(cache: *const Cache, resolved_path: []u8) !PrefixedPath

File

lib/std/Build/Cache.zig:90

Code

fn findPrefixResolved(cache: *const Cache, resolved_path: []u8) !PrefixedPath {
    const gpa = cache.gpa;
    const cwd = cache.cwd;
    for (cache.prefixes(), 0..) |prefix, i| {
        const p = prefix.path orelse continue;
        const sub_path = getPrefixSubpath(gpa, cwd, p, resolved_path) catch |err| switch (err) {
            error.NotASubPath => continue,
            else => |e| return e,
        };
        // Free the resolved path since we're not going to return it
        gpa.free(resolved_path);
        return .{
            .prefix = @intCast(i),
            .sub_path = sub_path,
        };
    }

    return .{
        .prefix = 0,
        .sub_path = resolved_path,
    };
}