feature. See also
. The project being documented here (as the example) is the Zig library itself.
FindProgram.checkCandidate
fn checkCandidate(
maker: *Maker,
step: *Step,
found_path: Configuration.GeneratedFileIndex,
err_msg: *std.ArrayList(u8),
full_path: []const u8,
) !bool
File
Code
fn checkCandidate(
maker: *Maker,
step: *Step,
found_path: Configuration.GeneratedFileIndex,
err_msg: *std.ArrayList(u8),
full_path: []const u8,
) !bool {
const graph = maker.graph;
const arena = graph.arena;
const io = graph.io;
if (Io.Dir.cwd().access(io, full_path, .{ .execute = true })) |_| {
maker.generatedPath(found_path).* = .initCwd(full_path);
return true;
} else |err| switch (err) {
error.Canceled => |e| return e,
error.FileNotFound, error.AccessDenied, error.PermissionDenied => |e| {
try err_msg.print(arena, "{t} {s}\n", .{ e, full_path });
},
else => |e| return step.fail(maker, "failed accessing {s}: {t}", .{ full_path, e }),
}
if (builtin.os.tag == .windows) {
if (graph.environ_map.get("PATHEXT")) |PATHEXT| {
var it = std.mem.tokenizeScalar(u8, PATHEXT, Io.Dir.path.delimiter);
while (it.next()) |ext| {
if (!supportedWindowsProgramExtension(ext)) continue;
const extended_path = try std.mem.concat(arena, u8, &.{ full_path, ext });
if (Io.Dir.cwd().access(io, extended_path, .{ .execute = true })) |_| {
maker.generatedPath(found_path).* = .initCwd(extended_path);
return true;
} else |err| switch (err) {
error.Canceled => |e| return e,
error.FileNotFound, error.AccessDenied, error.PermissionDenied => |e| {
try err_msg.print(arena, "{t} {s}\n", .{ e, extended_path });
},
else => |e| return step.fail(maker, "failed accessing {s}: {t}", .{ extended_path, e }),
}
}
}
}
return false;
}