Takes ownership of resolved_path on success.
fn findPrefixResolved(cache: *const Cache, resolved_path: []u8) !PrefixedPath
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,
};
}