From 46a0f60e4c0c91f840982cb98066d60301624548 Mon Sep 17 00:00:00 2001 From: Marcio Giaxa Date: Thu, 20 Dec 2018 20:57:58 -0200 Subject: [PATCH] freebsd: use realpath() to resolve symbolic links --- std/os/path.zig | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/std/os/path.zig b/std/os/path.zig index af767b0dca..ff70bc039e 100644 --- a/std/os/path.zig +++ b/std/os/path.zig @@ -1161,7 +1161,7 @@ pub fn realC(out_buffer: *[os.MAX_PATH_BYTES]u8, pathname: [*]const u8) RealErro const pathname_w = try windows_util.cStrToPrefixedFileW(pathname); return realW(out_buffer, pathname_w); }, - Os.macosx, Os.ios => { + Os.freebsd, Os.macosx, Os.ios => { // TODO instead of calling the libc function here, port the implementation to Zig const err = posix.getErrno(posix.realpath(pathname, out_buffer)); switch (err) { @@ -1188,15 +1188,6 @@ pub fn realC(out_buffer: *[os.MAX_PATH_BYTES]u8, pathname: [*]const u8) RealErro return os.readLinkC(out_buffer, proc_path.ptr); }, - Os.freebsd => { // XXX requires fdescfs - const fd = try os.posixOpenC(pathname, posix.O_PATH | posix.O_NONBLOCK | posix.O_CLOEXEC, 0); - defer os.close(fd); - - var buf: ["/dev/fd/-2147483648\x00".len]u8 = undefined; - const proc_path = fmt.bufPrint(buf[0..], "/dev/fd/{}\x00", fd) catch unreachable; - - return os.readLinkC(out_buffer, proc_path.ptr); - }, else => @compileError("TODO implement os.path.real for " ++ @tagName(builtin.os)), } }