From be0a4dc299c71dd916817ab6c181b8a441f22ddd Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 7 Jan 2026 14:50:25 -0800 Subject: [PATCH] goodbye posix.fstatat see #6600 --- lib/std/posix.zig | 48 ----------------------------------------------- 1 file changed, 48 deletions(-) diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 03bf830a4781ac9d79ca5a100d283b23143318be..331fa3b1e2aade5bf3b56c58009f8014c1e0b04f 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -792,54 +792,6 @@ pub fn fstat(fd: fd_t) FStatError!Stat { } } -pub const FStatAtError = FStatError || error{ - NameTooLong, - FileNotFound, - SymLinkLoop, - BadPathName, -}; - -/// Similar to `fstat`, but returns stat of a resource pointed to by `pathname` -/// which is relative to `dirfd` handle. -/// On WASI, `pathname` should be encoded as valid UTF-8. -/// On other platforms, `pathname` is an opaque sequence of bytes with no particular encoding. -/// See also `fstatatZ`. -pub fn fstatat(dirfd: fd_t, pathname: []const u8, flags: u32) FStatAtError!Stat { - if (native_os == .wasi and !builtin.link_libc) { - @compileError("use std.Io instead"); - } else if (native_os == .windows) { - @compileError("fstatat is not yet implemented on Windows"); - } else { - const pathname_c = try toPosixPath(pathname); - return fstatatZ(dirfd, &pathname_c, flags); - } -} - -/// Same as `fstatat` but `pathname` is null-terminated. -/// See also `fstatat`. -pub fn fstatatZ(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!Stat { - if (native_os == .wasi and !builtin.link_libc) { - @compileError("use std.Io instead"); - } - - var stat = mem.zeroes(Stat); - switch (errno(system.fstatat(dirfd, pathname, &stat, flags))) { - .SUCCESS => return stat, - .INVAL => unreachable, - .BADF => unreachable, // Always a race condition. - .NOMEM => return error.SystemResources, - .ACCES => return error.AccessDenied, - .PERM => return error.PermissionDenied, - .FAULT => unreachable, - .NAMETOOLONG => return error.NameTooLong, - .LOOP => return error.SymLinkLoop, - .NOENT => return error.FileNotFound, - .NOTDIR => return error.FileNotFound, - .ILSEQ => return error.BadPathName, - else => |err| return unexpectedErrno(err), - } -} - pub const KQueueError = error{ /// The per-process limit on the number of open file descriptors has been reached. ProcessFdQuotaExceeded, -- 2.54.0