-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add assumptions for resolveWindows
, resolvePosix
and realpath
#10988
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1438,7 +1438,7 @@ var wasi_cwd = if (builtin.os.tag == .wasi and !builtin.link_libc) struct { | |
/// Note that `cwd_init` corresponds to a Preopen directory, not necessarily | ||
/// a POSIX path. For example, "." matches a Preopen provided with `--dir=.` | ||
/// | ||
/// This must be called before using any relative or absolute paths with `std.os` | ||
/// This must be called before using any relative or absolute paths with `std.os` | ||
/// functions, if you are on WASI without linking libc. | ||
/// | ||
/// `alloc` must not be a temporary or leak-detecting allocator, since `std.os` | ||
|
@@ -1472,7 +1472,7 @@ pub fn initPreopensWasi(alloc: Allocator, cwd_init: ?[]const u8) !void { | |
|
||
/// Resolve a relative or absolute path to an handle (`fd_t`) and a relative subpath. | ||
/// | ||
/// For absolute paths, this automatically searches among available Preopens to find | ||
/// For absolute paths, this automatically searches among available Preopens to find | ||
/// a match. For relative paths, it uses the "emulated" CWD. | ||
pub fn resolvePathWasi(path: []const u8, out_buffer: *[MAX_PATH_BYTES]u8) !RelativePathWasi { | ||
// Note: Due to WASI's "sandboxed" file handles, operations with this RelativePathWasi | ||
|
@@ -5091,6 +5091,10 @@ pub const RealPathError = error{ | |
/// extra `/` characters in `pathname`. | ||
/// The return value is a slice of `out_buffer`, but not necessarily from the beginning. | ||
/// See also `realpathZ` and `realpathW`. | ||
/// Note: All /-separated components of the supplied path must resolve to a | ||
/// directory, or a symlink to a directory, except for the last component | ||
/// Use `fs.path.resolve` or `fs.path.relative` to get dir of file (`file/..`). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The non-working semantics (
Could we on Windows work around the problem with calling relative on the subpath and then call resolve for each extending subpath? If you can point me to the things I need for testing, I can play abit to see if that could work. |
||
/// assume: if relative path used, then they are relative to `getcwd()` | ||
pub fn realpath(pathname: []const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 { | ||
if (builtin.os.tag == .windows) { | ||
const pathname_w = try windows.sliceToPrefixedFileW(pathname); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "Note: does not expand symlinks" is sufficient for the note here
The details on symlink resolution between platforms have to do with
realpath
and the otherstd.os
calls, not this functionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed.
Why does this not belong into the description of the portable method, if it is a portability restriction?
I would expect that users tend to do tests on one platform with the most portable method and extrapolate to the others.