authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-01 23:04:32-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-02 17:02:24-07:00
log309c53295f26999065e4dc76cef4d90f8d85fb38
tree09a0abc2ad1e0252e12ae27d81853b129040ad5d
parenta4352982b3ad4370543e0d4486347b58a958ed6b

std.fs: give readLink an explicit error set


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

lib/std/fs.zig+3-1
...@@ -2003,10 +2003,12 @@ pub const Dir = struct {...@@ -2003,10 +2003,12 @@ pub const Dir = struct {
2003 return os.windows.CreateSymbolicLink(self.fd, sym_link_path_w, target_path_w, flags.is_directory);2003 return os.windows.CreateSymbolicLink(self.fd, sym_link_path_w, target_path_w, flags.is_directory);
2004 }2004 }
20052005
2006 pub const ReadLinkError = os.ReadLinkError;
2007
2006 /// Read value of a symbolic link.2008 /// Read value of a symbolic link.
2007 /// The return value is a slice of `buffer`, from index `0`.2009 /// The return value is a slice of `buffer`, from index `0`.
2008 /// Asserts that the path parameter has no null bytes.2010 /// Asserts that the path parameter has no null bytes.
2009 pub fn readLink(self: Dir, sub_path: []const u8, buffer: []u8) ![]u8 {2011 pub fn readLink(self: Dir, sub_path: []const u8, buffer: []u8) ReadLinkError![]u8 {
2010 if (builtin.os.tag == .wasi and !builtin.link_libc) {2012 if (builtin.os.tag == .wasi and !builtin.link_libc) {
2011 return self.readLinkWasi(sub_path, buffer);2013 return self.readLinkWasi(sub_path, buffer);
2012 }2014 }