authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-30 01:50:58 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-30 01:50:58 -07:00
log53f9178eb7e42cd15d20fb57d190ddd8760ed55f
tree675115f8e5f2bd143ecee4df180491b1b4ef616c
parentcb4ce969e68724779bb34e0a662ea8c7becd155d
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

add getcwd


2 files changed, 10 insertions(+), 0 deletions(-)

mod.zig+9
......@@ -1503,6 +1503,10 @@ pub const libc = struct {
15031503 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getchar_unlocked.html
15041504 pub extern fn getchar_unlocked() c_int;
15051505
1506 /// char *getcwd(char *buf, size_t size);
1507 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getcwd.html
1508 pub extern fn getcwd(buf: [*]u8, size: usize) ?[*:0]u8;
1509
15061510 /// gid_t getegid(void);
15071511 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/getegid.html
15081512 pub extern fn getegid() gid_t;
......@@ -3713,3 +3717,8 @@ pub fn lseek(fd: c_int, offset: off_t, whence: c_int) !void {
37133717 if (rc == -1) return errno.fromInt(errno.fromLibC());
37143718 std.debug.assert(rc >= 0);
37153719}
3720pub fn getcwd(buf: []u8) ![*:0]u8 {
3721 const rc = libc.getcwd(buf.ptr, buf.len);
3722 if (rc == null) return errno.fromInt(errno.fromLibC());
3723 return rc.?;
3724}
test.zig+1
......@@ -80,4 +80,5 @@ test {
8080 _ = &linux.waitpid;
8181 _ = &linux.unlinkat;
8282 _ = &linux.lseek;
83 _ = &linux.getcwd;
8384}