std.fs.Dir.statFile: use fstatat

This avoids extra syscalls.
This commit is contained in:
Philippe Pittoli
2022-05-06 01:03:03 +02:00
committed by Andrew Kelley
parent 4af305b30a
commit f65cdef7c8
3 changed files with 80 additions and 12 deletions

View File

@@ -4137,14 +4137,19 @@ pub fn populateBuiltinFile(mod: *Module) !void {
};
}
} else |err| switch (err) {
error.BadPathName => unreachable, // it's always "builtin.zig"
error.NameTooLong => unreachable, // it's always "builtin.zig"
error.PipeBusy => unreachable, // it's not a pipe
error.WouldBlock => unreachable, // not asking for non-blocking I/O
error.FileNotFound => try writeBuiltinFile(file, builtin_pkg),
else => |e| return e,
else => |e| {
if (builtin.os.tag == .windows) {
switch (e) {
error.BadPathName => unreachable, // it's always "builtin.zig"
error.PipeBusy => unreachable, // it's not a pipe
error.WouldBlock => unreachable, // not asking for non-blocking I/O
else => return e,
}
}
return e;
},
}
file.tree = try std.zig.parse(gpa, file.source);