authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-07 14:50:25-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-01-07 17:33:07-08:00
logbe0a4dc299c71dd916817ab6c181b8a441f22ddd
tree6246d7e8444e691cf944c280f5c84fd0aada7429
parent829afe98d16d72a9a3af3ae30622ce6576c8b27f

goodbye posix.fstatat

see #6600

1 files changed, 0 insertions(+), 48 deletions(-)

lib/std/posix.zig-48
...@@ -792,54 +792,6 @@ pub fn fstat(fd: fd_t) FStatError!Stat {...@@ -792,54 +792,6 @@ pub fn fstat(fd: fd_t) FStatError!Stat {
792 }792 }
793}793}
794794
795pub const FStatAtError = FStatError || error{
796 NameTooLong,
797 FileNotFound,
798 SymLinkLoop,
799 BadPathName,
800};
801
802/// Similar to `fstat`, but returns stat of a resource pointed to by `pathname`
803/// which is relative to `dirfd` handle.
804/// On WASI, `pathname` should be encoded as valid UTF-8.
805/// On other platforms, `pathname` is an opaque sequence of bytes with no particular encoding.
806/// See also `fstatatZ`.
807pub fn fstatat(dirfd: fd_t, pathname: []const u8, flags: u32) FStatAtError!Stat {
808 if (native_os == .wasi and !builtin.link_libc) {
809 @compileError("use std.Io instead");
810 } else if (native_os == .windows) {
811 @compileError("fstatat is not yet implemented on Windows");
812 } else {
813 const pathname_c = try toPosixPath(pathname);
814 return fstatatZ(dirfd, &pathname_c, flags);
815 }
816}
817
818/// Same as `fstatat` but `pathname` is null-terminated.
819/// See also `fstatat`.
820pub fn fstatatZ(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!Stat {
821 if (native_os == .wasi and !builtin.link_libc) {
822 @compileError("use std.Io instead");
823 }
824
825 var stat = mem.zeroes(Stat);
826 switch (errno(system.fstatat(dirfd, pathname, &stat, flags))) {
827 .SUCCESS => return stat,
828 .INVAL => unreachable,
829 .BADF => unreachable, // Always a race condition.
830 .NOMEM => return error.SystemResources,
831 .ACCES => return error.AccessDenied,
832 .PERM => return error.PermissionDenied,
833 .FAULT => unreachable,
834 .NAMETOOLONG => return error.NameTooLong,
835 .LOOP => return error.SymLinkLoop,
836 .NOENT => return error.FileNotFound,
837 .NOTDIR => return error.FileNotFound,
838 .ILSEQ => return error.BadPathName,
839 else => |err| return unexpectedErrno(err),
840 }
841}
842
843pub const KQueueError = error{795pub const KQueueError = error{
844 /// The per-process limit on the number of open file descriptors has been reached.796 /// The per-process limit on the number of open file descriptors has been reached.
845 ProcessFdQuotaExceeded,797 ProcessFdQuotaExceeded,