authorgravatar for i@mgxm.meMarcio Giaxa <i@mgxm.me> 2018-12-20 20:57:58-02:00
committergravatar for i@mgxm.meMarcio Giaxa <i@mgxm.me> 2018-12-20 20:57:58-02:00
log46a0f60e4c0c91f840982cb98066d60301624548
treed732cea118c8d1f3b90f00565d36661473ca9080
parentac1b2a3c7319b099211acdca91c644a8533d0970
signature Commit is signed but in an unrecognized format.

freebsd: use realpath() to resolve symbolic links


1 files changed, 1 insertions(+), 10 deletions(-)

std/os/path.zig+1-10
...@@ -1161,7 +1161,7 @@ pub fn realC(out_buffer: *[os.MAX_PATH_BYTES]u8, pathname: [*]const u8) RealErro...@@ -1161,7 +1161,7 @@ pub fn realC(out_buffer: *[os.MAX_PATH_BYTES]u8, pathname: [*]const u8) RealErro
1161 const pathname_w = try windows_util.cStrToPrefixedFileW(pathname);1161 const pathname_w = try windows_util.cStrToPrefixedFileW(pathname);
1162 return realW(out_buffer, pathname_w);1162 return realW(out_buffer, pathname_w);
1163 },1163 },
1164 Os.macosx, Os.ios => {1164 Os.freebsd, Os.macosx, Os.ios => {
1165 // TODO instead of calling the libc function here, port the implementation to Zig1165 // TODO instead of calling the libc function here, port the implementation to Zig
1166 const err = posix.getErrno(posix.realpath(pathname, out_buffer));1166 const err = posix.getErrno(posix.realpath(pathname, out_buffer));
1167 switch (err) {1167 switch (err) {
...@@ -1188,15 +1188,6 @@ pub fn realC(out_buffer: *[os.MAX_PATH_BYTES]u8, pathname: [*]const u8) RealErro...@@ -1188,15 +1188,6 @@ pub fn realC(out_buffer: *[os.MAX_PATH_BYTES]u8, pathname: [*]const u8) RealErro
11881188
1189 return os.readLinkC(out_buffer, proc_path.ptr);1189 return os.readLinkC(out_buffer, proc_path.ptr);
1190 },1190 },
1191 Os.freebsd => { // XXX requires fdescfs
1192 const fd = try os.posixOpenC(pathname, posix.O_PATH | posix.O_NONBLOCK | posix.O_CLOEXEC, 0);
1193 defer os.close(fd);
1194
1195 var buf: ["/dev/fd/-2147483648\x00".len]u8 = undefined;
1196 const proc_path = fmt.bufPrint(buf[0..], "/dev/fd/{}\x00", fd) catch unreachable;
1197
1198 return os.readLinkC(out_buffer, proc_path.ptr);
1199 },
1200 else => @compileError("TODO implement os.path.real for " ++ @tagName(builtin.os)),1191 else => @compileError("TODO implement os.path.real for " ++ @tagName(builtin.os)),
1201 }1192 }
1202}1193}