authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-09-01 14:32:20 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-09-01 14:32:20 -07:00
logcc8fb7cb1654df835a48473d67c001a44d2a6ea9
tree7dc9b32a74d77f7301a5db1284fa76ef67d74c97
parentf6bf94af1328311e394c68c0eac61d5cca9f0e67

fix fd_realpath for 0.14


1 files changed, 6 insertions(+), 2 deletions(-)

src/lib.zig+6-2
...@@ -74,11 +74,11 @@ pub usingnamespace @import("./AnyReader.zig");...@@ -74,11 +74,11 @@ pub usingnamespace @import("./AnyReader.zig");
74pub usingnamespace @import("./sum.zig");74pub usingnamespace @import("./sum.zig");
75pub usingnamespace @import("./RingBuffer.zig");75pub usingnamespace @import("./RingBuffer.zig");
7676
77pub fn fd_realpath(fd: std.posix.fd_t) ![std.fs.MAX_PATH_BYTES:0]u8 {77pub fn fd_realpath(fd: std.posix.fd_t) ![std.fs.max_path_bytes:0]u8 {
78 switch (builtin.os.tag) {78 switch (builtin.os.tag) {
79 .linux => {79 .linux => {
80 var buf = std.mem.zeroes([64]u8);80 var buf = std.mem.zeroes([64]u8);
81 var res = std.mem.zeroes([std.fs.MAX_PATH_BYTES:0]u8);81 var res = std.mem.zeroes([std.fs.max_path_bytes:0]u8);
82 const str = try std.fmt.bufPrint(&buf, "/proc/self/fd/{d}", .{fd});82 const str = try std.fmt.bufPrint(&buf, "/proc/self/fd/{d}", .{fd});
83 _ = try std.posix.readlink(str, &res);83 _ = try std.posix.readlink(str, &res);
84 return res;84 return res;
...@@ -86,6 +86,10 @@ pub fn fd_realpath(fd: std.posix.fd_t) ![std.fs.MAX_PATH_BYTES:0]u8 {...@@ -86,6 +86,10 @@ pub fn fd_realpath(fd: std.posix.fd_t) ![std.fs.MAX_PATH_BYTES:0]u8 {
86 else => @compileError("not implemented!"),86 else => @compileError("not implemented!"),
87 }87 }
88}88}
89test {
90 if (builtin.os.tag != .linux) return;
91 _ = &fd_realpath;
92}
8993
90pub usingnamespace @import("./rawInt.zig");94pub usingnamespace @import("./rawInt.zig");
91pub usingnamespace @import("./expectSimilarType.zig");95pub usingnamespace @import("./expectSimilarType.zig");