std.fs.Dir.statFile rework

* revert changes to Module because the error set is consistent across
   operating systems.
 * remove duplicated Stat.fromSystem code and use a less redundant name.
 * make fs.Dir.statFile follow symlinks, and avoid pointless control
   flow through the posix layer.
This commit is contained in:
Andrew Kelley
2022-09-09 09:55:09 -07:00
parent f65cdef7c8
commit a62c8d36d5
3 changed files with 51 additions and 94 deletions

View File

@@ -4137,19 +4137,14 @@ 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| {
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;
},
else => |e| return e,
}
file.tree = try std.zig.parse(gpa, file.source);