diff options
| author | Ryan Liptak <squeek502@hotmail.com> | 2024-01-04 23:03:46 -0800 |
|---|---|---|
| committer | Ryan Liptak <squeek502@hotmail.com> | 2024-01-05 17:56:31 -0800 |
| commit | 51946f5adcc0e2a7c26f17ab7784e5e90aba2ea1 (patch) | |
| tree | 1b0f1996abd450b2068d6e084c25e7f5daf9d7b3 /lib/std/fs/Dir.zig | |
| parent | 9335529b9be8f7c359e6f2ba79099f263f1a8479 (diff) | |
| download | zig-51946f5adcc0e2a7c26f17ab7784e5e90aba2ea1.tar.gz zig-51946f5adcc0e2a7c26f17ab7784e5e90aba2ea1.zip | |
Dir.makePath: Document/test platform differences around .. component handling
Closes #18452
Diffstat (limited to 'lib/std/fs/Dir.zig')
| -rw-r--r-- | lib/std/fs/Dir.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/std/fs/Dir.zig b/lib/std/fs/Dir.zig index 4a45975ccc..8a1d38996e 100644 --- a/lib/std/fs/Dir.zig +++ b/lib/std/fs/Dir.zig @@ -1111,6 +1111,14 @@ pub fn makeDirW(self: Dir, sub_path: [*:0]const u16) !void { /// Returns success if the path already exists and is a directory. /// This function is not atomic, and if it returns an error, the file system may /// have been modified regardless. +/// +/// Paths containing `..` components are handled differently depending on the platform: +/// - On Windows, `..` are resolved before the path is passed to NtCreateFile, meaning +/// a `sub_path` like "first/../second" will resolve to "second" and only a +/// `./second` directory will be created. +/// - On other platforms, `..` are not resolved before the path is passed to `mkdirat`, +/// meaning a `sub_path` like "first/../second" will create both a `./first` +/// and a `./second` directory. pub fn makePath(self: Dir, sub_path: []const u8) !void { var it = try fs.path.componentIterator(sub_path); var component = it.last() orelse return; |
