Function realpathAlloc [src]

realpath, except caller must free the returned memory. On Windows, the result is encoded as WTF-8. On other platforms, the result is an opaque sequence of bytes with no particular encoding. See also Dir.realpath.

Prototype

pub fn realpathAlloc(allocator: Allocator, pathname: []const u8) ![]u8

Parameters

allocator: Allocatorpathname: []const u8

Source

pub fn realpathAlloc(allocator: Allocator, pathname: []const u8) ![]u8 { // Use of max_path_bytes here is valid as the realpath function does not // have a variant that takes an arbitrary-size buffer. // TODO(#4812): Consider reimplementing realpath or using the POSIX.1-2008 // NULL out parameter (GNU's canonicalize_file_name) to handle overelong // paths. musl supports passing NULL but restricts the output to PATH_MAX // anyway. var buf: [max_path_bytes]u8 = undefined; return allocator.dupe(u8, try posix.realpath(pathname, &buf)); }