| ... | ... | @@ -792,54 +792,6 @@ pub fn fstat(fd: fd_t) FStatError!Stat { |
| 792 | 792 | } |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | | pub 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`. |
| 807 | | pub 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`. |
| 820 | | pub 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 | | |
| 843 | 795 | pub const KQueueError = error{ |
| 844 | 796 | /// The per-process limit on the number of open file descriptors has been reached. |
| 845 | 797 | ProcessFdQuotaExceeded, |