@@ -3985,7 +3985,7 @@ pub const realpathC = @compileError("deprecated: renamed realpathZ");
3985
3985
/// This function is very host-specific and is not universally supported by all hosts.
3986
3986
/// For example, while it generally works on Linux, macOS or Windows, it is unsupported
3987
3987
/// on FreeBSD, or WASI.
3988
- fn fdPath (fd : fd_t , out_buffer : * [MAX_PATH_BYTES ]u8 ) RealPathError ! []u8 {
3988
+ fn getFdPath (fd : fd_t , out_buffer : * [MAX_PATH_BYTES ]u8 ) RealPathError ! []u8 {
3989
3989
switch (builtin .os .tag ) {
3990
3990
.windows = > {
3991
3991
var wide_buf : [windows .PATH_MAX_WIDE ]u16 = undefined ;
@@ -4037,7 +4037,7 @@ pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP
4037
4037
};
4038
4038
defer close (fd );
4039
4039
4040
- return fdPath (fd , out_buffer );
4040
+ return getFdPath (fd , out_buffer );
4041
4041
}
4042
4042
const result_path = std .c .realpath (pathname , out_buffer ) orelse switch (std .c ._errno ().* ) {
4043
4043
EINVAL = > unreachable ,
@@ -4069,14 +4069,19 @@ pub fn realpathW(pathname: [*:0]const u16, out_buffer: *[MAX_PATH_BYTES]u8) Real
4069
4069
);
4070
4070
defer windows .CloseHandle (h_file );
4071
4071
4072
- return fdPath (h_file , out_buffer );
4072
+ return getFdPath (h_file , out_buffer );
4073
4073
}
4074
4074
4075
- /// This function will depend differently on different hosts.
4076
- /// In WASI, it calls `realpathatWasi` which observes WASI capability-oriented
4077
- /// security model and returns `error.AccessDenied` if the `pathname` is absolute
4078
- /// or an attempt is made at escaping beyond the input `fd` file descriptor.
4079
- /// On all other hosts, this function is similar to `realpath`, however, returns
4075
+ /// This function will depend differently on different hosts. Since underneath it
4076
+ /// uses `getFdPath` (with the exception of WASI) to query the host for a true
4077
+ /// canonical path to handle `fd`, this function, much like `getFdPath` is not universally
4078
+ /// supported on all hosts.
4079
+ /// Currently, the supported hosts are: Linux, macOS, Windows, and WASI.
4080
+ /// In WASI, it does not issue any `getFdPath`-like calls. Instead, it canonicalizes
4081
+ /// the input path `pathname` upto the handle `fd` while observing WASI capability-oriented
4082
+ /// security model. If `pathname` is absolute, return `error.AbsolutePath`. See `realpathatWasi`
4083
+ /// for more information on how it works in WASI.
4084
+ /// On all other supported hosts, this function is similar to `realpath`, however, returns
4080
4085
/// the canonicalized absolute pathname of a `pathname` relative to a file descriptor
4081
4086
/// `fd`. If `pathname` is an absolute path, ignores `fd` and reverts to calling
4082
4087
/// `realpath` on the `pathname` argument. In particular, on Unix, if `fd` was
@@ -4119,7 +4124,7 @@ pub fn realpathatZ(fd: fd_t, pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYT
4119
4124
};
4120
4125
};
4121
4126
} else {
4122
- fd_path = try fdPath (fd , & buffer );
4127
+ fd_path = try getFdPath (fd , & buffer );
4123
4128
}
4124
4129
4125
4130
const total_len = fd_path .len + mem .lenZ (pathname ) + 1 ; // +1 to account for path separator
@@ -4145,7 +4150,7 @@ pub fn realpathatW(fd: fd_t, pathname: [*:0]const u16, out_buffer: *[MAX_PATH_BY
4145
4150
}
4146
4151
4147
4152
var buffer : [MAX_PATH_BYTES ]u8 = undefined ;
4148
- const fd_path = try fdPath (fd , & buffer );
4153
+ const fd_path = try getFdPath (fd , & buffer );
4149
4154
4150
4155
// Convert UTF16LE to UTF8
4151
4156
var pathname_u8 : [MAX_PATH_BYTES ]u8 = undefined ;
0 commit comments