mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 03:04:52 +01:00
This branch regressed the child process "run" mechanism because it didn't pass the correct stdin, stdout, stderr values to process.spawn Fixed now.
35 lines
1.2 KiB
Zig
35 lines
1.2 KiB
Zig
const std = @import("std");
|
|
|
|
/// Checks the existence of files relative to cwd.
|
|
/// A path starting with ! should not exist.
|
|
pub fn main(init: std.process.Init) !void {
|
|
const arena = init.arena.allocator();
|
|
const io = init.io;
|
|
|
|
var arg_it = try init.minimal.args.iterateAllocator(arena);
|
|
_ = arg_it.next();
|
|
|
|
const cwd = std.Io.Dir.cwd();
|
|
const cwd_realpath = try cwd.realPathFileAlloc(io, ".", arena);
|
|
|
|
while (arg_it.next()) |file_path| {
|
|
if (file_path.len > 0 and file_path[0] == '!') {
|
|
errdefer std.log.err(
|
|
"exclusive file check '{s}{c}{s}' failed",
|
|
.{ cwd_realpath, std.fs.path.sep, file_path[1..] },
|
|
);
|
|
if (cwd.statFile(io, file_path[1..], .{})) |_| {
|
|
return error.FileFound;
|
|
} else |err| switch (err) {
|
|
error.FileNotFound => {},
|
|
else => return err,
|
|
}
|
|
} else {
|
|
errdefer std.log.err(
|
|
"inclusive file check '{s}{c}{s}' failed",
|
|
.{ cwd_realpath, std.fs.path.sep, file_path },
|
|
);
|
|
_ = try cwd.statFile(io, file_path, .{});
|
|
}
|
|
}
|
|
}
|