diff --git a/mod.zig b/mod.zig index 3e8b278968addfac172e8bf62c1f64860c5f818c..a4ede5e927662e4067611919118e9a7275f23f2c 100644 --- a/mod.zig +++ b/mod.zig @@ -2234,6 +2234,10 @@ pub const libc = struct { /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/remainderl.html pub extern fn remainderl(x: c_longdouble, y: c_longdouble) c_longdouble; + /// int renameat(int oldfd, const char *old, int newfd, const char *new); + /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/renameat.html + pub extern fn renameat(oldfd: c_int, old: [*:0]const u8, newfd: c_int, new: [*:0]const u8) c_int; + /// double rint(double x); /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/rint.html pub extern fn rint(x: f64) f64; @@ -3208,3 +3212,8 @@ pub fn getdents(dirfd: c_int, buf: []u8) errno.Error!usize { std.debug.assert(rc >= 0); return @intCast(rc); } +pub fn renameat(oldfd: c_int, old: [*:0]const u8, newfd: c_int, new: [*:0]const u8) !void { + const rc = libc.renameat(oldfd, old, newfd, new); + if (rc == -1) return errno.fromInt(errno.fromLibC()); + std.debug.assert(rc == 0); +} diff --git a/test.zig b/test.zig index 8457737a32330e84179f577738807d69d921978b..2ac21bd3525e9efd282cf3caf15f3733217f2eb0 100644 --- a/test.zig +++ b/test.zig @@ -35,4 +35,5 @@ test { _ = &linux.getsockname; _ = &linux.sendfile; _ = &linux.getdents; + _ = &linux.renameat; }