| author | |
| committer | |
| log | bfc569bc9877a4f305080bc6cde0e42fed7433e0 |
| tree | 63016c5c1469db9aa9f45edefe0685a639741d54 |
| parent | 627618a38d291d9cc76c8e30e33cad60dc26cf11 |
| signature |
2 files changed, 24 insertions(+), 0 deletions(-)
lib/std/c.zig+1| ... | @@ -75,6 +75,7 @@ pub extern "c" fn isatty(fd: fd_t) c_int; | ... | @@ -75,6 +75,7 @@ pub extern "c" fn isatty(fd: fd_t) c_int; |
| 75 | pub extern "c" fn close(fd: fd_t) c_int; | 75 | pub extern "c" fn close(fd: fd_t) c_int; |
| 76 | pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; | 76 | pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int; |
| 77 | pub extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int; | 77 | pub extern "c" fn @"fstat$INODE64"(fd: fd_t, buf: *Stat) c_int; |
| 78 | pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int; | ||
| 78 | pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: c_int) off_t; | 79 | pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: c_int) off_t; |
| 79 | pub extern "c" fn open(path: [*:0]const u8, oflag: c_uint, ...) c_int; | 80 | pub extern "c" fn open(path: [*:0]const u8, oflag: c_uint, ...) c_int; |
| 80 | pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: c_uint, ...) c_int; | 81 | pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: c_uint, ...) c_int; |
lib/std/os.zig+23| ... | @@ -2371,6 +2371,29 @@ pub fn fstat(fd: fd_t) FStatError!Stat { | ... | @@ -2371,6 +2371,29 @@ pub fn fstat(fd: fd_t) FStatError!Stat { |
| 2371 | } | 2371 | } |
| 2372 | } | 2372 | } |
| 2373 | 2373 | ||
| 2374 | const FStatAtError = FStatError || error{NameTooLong}; | ||
| 2375 | |||
| 2376 | pub fn fstatat(dirfd: fd_t, pathname: []const u8, flags: u32) FStatAtError![]Stat { | ||
| 2377 | const pathname_c = try toPosixPath(pathname); | ||
| 2378 | return fstatatC(dirfd, &pathname_c, flags); | ||
| 2379 | } | ||
| 2380 | |||
| 2381 | pub fn fstatatC(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!Stat { | ||
| 2382 | var stat: Stat = undefined; | ||
| 2383 | switch (errno(system.fstatat(dirfd, pathname, &stat, flags))) { | ||
| 2384 | 0 => return stat, | ||
| 2385 | EINVAL => unreachable, | ||
| 2386 | EBADF => unreachable, // Always a race condition. | ||
| 2387 | ENOMEM => return error.SystemResources, | ||
| 2388 | EACCES => return error.AccessDenied, | ||
| 2389 | EFAULT => unreachable, | ||
| 2390 | ENAMETOOLONG => return error.NameTooLong, | ||
| 2391 | ENOENT => return error.FileNotFound, | ||
| 2392 | ENOTDIR => return error.FileNotFound, | ||
| 2393 | else => |err| return unexpectedErrno(err), | ||
| 2394 | } | ||
| 2395 | } | ||
| 2396 | |||
| 2374 | pub const KQueueError = error{ | 2397 | pub const KQueueError = error{ |
| 2375 | /// The per-process limit on the number of open file descriptors has been reached. | 2398 | /// The per-process limit on the number of open file descriptors has been reached. |
| 2376 | ProcessFdQuotaExceeded, | 2399 | ProcessFdQuotaExceeded, |