Commit 46a0f60e4c

Marcio Giaxa <i@mgxm.me>
2018-12-20 23:57:58
freebsd: use realpath() to resolve symbolic links
1 parent ac1b2a3
Changed files (1)
std
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)),
     }
 }