authorgravatar for 32079903+JustinBraben@users.noreply.github.comJustin Braben <32079903+JustinBraben@users.noreply.github.com> 2024-10-16 17:08:58-06:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-10-17 01:08:58+02:00
log4a2a0f50caac5e6f7f17e5abe17dd53e9bdc1731
treee8583a68891524aab6fb148ee17e3f86dd28e822
parent6201031e0581c54688fdf6071a250b80f892525b
signaturebadge-check Signed by PGP key B5690EEEBB952194

fix compilation errors for fs and fs.Dir (#21643)

* fix compilation errors for fs and fs.Dir * mem.span instead of mem.sliceTo * Updating symLinkAbsoluteW function parameters * Update with expected rename semantics

2 files changed, 13 insertions(+), 13 deletions(-)

lib/std/fs.zig+11-11
...@@ -160,7 +160,7 @@ pub fn makeDirAbsoluteZ(absolute_path_z: [*:0]const u8) !void {...@@ -160,7 +160,7 @@ pub fn makeDirAbsoluteZ(absolute_path_z: [*:0]const u8) !void {
160/// Same as `makeDirAbsolute` except the parameter is a null-terminated WTF-16 LE-encoded string.160/// Same as `makeDirAbsolute` except the parameter is a null-terminated WTF-16 LE-encoded string.
161pub fn makeDirAbsoluteW(absolute_path_w: [*:0]const u16) !void {161pub fn makeDirAbsoluteW(absolute_path_w: [*:0]const u16) !void {
162 assert(path.isAbsoluteWindowsW(absolute_path_w));162 assert(path.isAbsoluteWindowsW(absolute_path_w));
163 return posix.mkdirW(absolute_path_w, Dir.default_mode);163 return posix.mkdirW(mem.span(absolute_path_w), Dir.default_mode);
164}164}
165165
166/// Same as `Dir.deleteDir` except the path is absolute.166/// Same as `Dir.deleteDir` except the path is absolute.
...@@ -181,7 +181,7 @@ pub fn deleteDirAbsoluteZ(dir_path: [*:0]const u8) !void {...@@ -181,7 +181,7 @@ pub fn deleteDirAbsoluteZ(dir_path: [*:0]const u8) !void {
181/// Same as `deleteDirAbsolute` except the path parameter is WTF-16 and target OS is assumed Windows.181/// Same as `deleteDirAbsolute` except the path parameter is WTF-16 and target OS is assumed Windows.
182pub fn deleteDirAbsoluteW(dir_path: [*:0]const u16) !void {182pub fn deleteDirAbsoluteW(dir_path: [*:0]const u16) !void {
183 assert(path.isAbsoluteWindowsW(dir_path));183 assert(path.isAbsoluteWindowsW(dir_path));
184 return posix.rmdirW(dir_path);184 return posix.rmdirW(mem.span(dir_path));
185}185}
186186
187/// Same as `Dir.rename` except the paths are absolute.187/// Same as `Dir.rename` except the paths are absolute.
...@@ -221,7 +221,7 @@ pub fn renameZ(old_dir: Dir, old_sub_path_z: [*:0]const u8, new_dir: Dir, new_su...@@ -221,7 +221,7 @@ pub fn renameZ(old_dir: Dir, old_sub_path_z: [*:0]const u8, new_dir: Dir, new_su
221/// Same as `rename` except the parameters are WTF16LE, NT prefixed.221/// Same as `rename` except the parameters are WTF16LE, NT prefixed.
222/// This function is Windows-only.222/// This function is Windows-only.
223pub fn renameW(old_dir: Dir, old_sub_path_w: []const u16, new_dir: Dir, new_sub_path_w: []const u16) !void {223pub fn renameW(old_dir: Dir, old_sub_path_w: []const u16, new_dir: Dir, new_sub_path_w: []const u16) !void {
224 return posix.renameatW(old_dir.fd, old_sub_path_w, new_dir.fd, new_sub_path_w);224 return posix.renameatW(old_dir.fd, old_sub_path_w, new_dir.fd, new_sub_path_w, windows.TRUE);
225}225}
226226
227/// Returns a handle to the current working directory. It is not opened with iteration capability.227/// Returns a handle to the current working directory. It is not opened with iteration capability.
...@@ -338,7 +338,7 @@ pub fn createFileAbsoluteZ(absolute_path_c: [*:0]const u8, flags: File.CreateFla...@@ -338,7 +338,7 @@ pub fn createFileAbsoluteZ(absolute_path_c: [*:0]const u8, flags: File.CreateFla
338/// Same as `createFileAbsolute` but the path parameter is WTF-16 encoded.338/// Same as `createFileAbsolute` but the path parameter is WTF-16 encoded.
339pub fn createFileAbsoluteW(absolute_path_w: [*:0]const u16, flags: File.CreateFlags) File.OpenError!File {339pub fn createFileAbsoluteW(absolute_path_w: [*:0]const u16, flags: File.CreateFlags) File.OpenError!File {
340 assert(path.isAbsoluteWindowsW(absolute_path_w));340 assert(path.isAbsoluteWindowsW(absolute_path_w));
341 return cwd().createFileW(absolute_path_w, flags);341 return cwd().createFileW(mem.span(absolute_path_w), flags);
342}342}
343343
344/// Delete a file name and possibly the file it refers to, based on an absolute path.344/// Delete a file name and possibly the file it refers to, based on an absolute path.
...@@ -362,7 +362,7 @@ pub fn deleteFileAbsoluteZ(absolute_path_c: [*:0]const u8) Dir.DeleteFileError!v...@@ -362,7 +362,7 @@ pub fn deleteFileAbsoluteZ(absolute_path_c: [*:0]const u8) Dir.DeleteFileError!v
362/// Same as `deleteFileAbsolute` except the parameter is WTF-16 encoded.362/// Same as `deleteFileAbsolute` except the parameter is WTF-16 encoded.
363pub fn deleteFileAbsoluteW(absolute_path_w: [*:0]const u16) Dir.DeleteFileError!void {363pub fn deleteFileAbsoluteW(absolute_path_w: [*:0]const u16) Dir.DeleteFileError!void {
364 assert(path.isAbsoluteWindowsW(absolute_path_w));364 assert(path.isAbsoluteWindowsW(absolute_path_w));
365 return cwd().deleteFileW(absolute_path_w);365 return cwd().deleteFileW(mem.span(absolute_path_w));
366}366}
367367
368/// Removes a symlink, file, or directory.368/// Removes a symlink, file, or directory.
...@@ -400,7 +400,7 @@ pub fn readLinkAbsolute(pathname: []const u8, buffer: *[max_path_bytes]u8) ![]u8...@@ -400,7 +400,7 @@ pub fn readLinkAbsolute(pathname: []const u8, buffer: *[max_path_bytes]u8) ![]u8
400/// encoded.400/// encoded.
401pub fn readlinkAbsoluteW(pathname_w: [*:0]const u16, buffer: *[max_path_bytes]u8) ![]u8 {401pub fn readlinkAbsoluteW(pathname_w: [*:0]const u16, buffer: *[max_path_bytes]u8) ![]u8 {
402 assert(path.isAbsoluteWindowsW(pathname_w));402 assert(path.isAbsoluteWindowsW(pathname_w));
403 return posix.readlinkW(pathname_w, buffer);403 return posix.readlinkW(mem.span(pathname_w), buffer);
404}404}
405405
406/// Same as `readLink`, except the path parameter is null-terminated.406/// Same as `readLink`, except the path parameter is null-terminated.
...@@ -437,13 +437,13 @@ pub fn symLinkAbsolute(...@@ -437,13 +437,13 @@ pub fn symLinkAbsolute(
437/// like to create a symbolic link to a directory, specify this with `SymLinkFlags{ .is_directory = true }`.437/// like to create a symbolic link to a directory, specify this with `SymLinkFlags{ .is_directory = true }`.
438/// See also `symLinkAbsolute`, `symLinkAbsoluteZ`.438/// See also `symLinkAbsolute`, `symLinkAbsoluteZ`.
439pub fn symLinkAbsoluteW(439pub fn symLinkAbsoluteW(
440 target_path_w: []const u16,440 target_path_w: [*:0]const u16,
441 sym_link_path_w: []const u16,441 sym_link_path_w: [*:0]const u16,
442 flags: Dir.SymLinkFlags,442 flags: Dir.SymLinkFlags,
443) !void {443) !void {
444 assert(path.isAbsoluteWindowsWTF16(target_path_w));444 assert(path.isAbsoluteWindowsW(target_path_w));
445 assert(path.isAbsoluteWindowsWTF16(sym_link_path_w));445 assert(path.isAbsoluteWindowsW(sym_link_path_w));
446 return windows.CreateSymbolicLink(null, sym_link_path_w, target_path_w, flags.is_directory);446 return windows.CreateSymbolicLink(null, mem.span(sym_link_path_w), mem.span(target_path_w), flags.is_directory);
447}447}
448448
449/// Same as `symLinkAbsolute` except the parameters are null-terminated pointers.449/// Same as `symLinkAbsolute` except the parameters are null-terminated pointers.
lib/std/fs/Dir.zig+2-2
...@@ -1134,7 +1134,7 @@ pub fn makeDirZ(self: Dir, sub_path: [*:0]const u8) MakeError!void {...@@ -1134,7 +1134,7 @@ pub fn makeDirZ(self: Dir, sub_path: [*:0]const u8) MakeError!void {
1134/// To create multiple directories to make an entire path, see `makePath`.1134/// To create multiple directories to make an entire path, see `makePath`.
1135/// To operate on only absolute paths, see `makeDirAbsoluteW`.1135/// To operate on only absolute paths, see `makeDirAbsoluteW`.
1136pub fn makeDirW(self: Dir, sub_path: [*:0]const u16) MakeError!void {1136pub fn makeDirW(self: Dir, sub_path: [*:0]const u16) MakeError!void {
1137 try posix.mkdiratW(self.fd, sub_path, default_mode);1137 try posix.mkdiratW(self.fd, mem.span(sub_path), default_mode);
1138}1138}
11391139
1140/// Calls makeDir iteratively to make an entire path1140/// Calls makeDir iteratively to make an entire path
...@@ -1763,7 +1763,7 @@ pub fn renameZ(self: Dir, old_sub_path_z: [*:0]const u8, new_sub_path_z: [*:0]co...@@ -1763,7 +1763,7 @@ pub fn renameZ(self: Dir, old_sub_path_z: [*:0]const u8, new_sub_path_z: [*:0]co
1763/// Same as `rename` except the parameters are WTF16LE, NT prefixed.1763/// Same as `rename` except the parameters are WTF16LE, NT prefixed.
1764/// This function is Windows-only.1764/// This function is Windows-only.
1765pub fn renameW(self: Dir, old_sub_path_w: []const u16, new_sub_path_w: []const u16) RenameError!void {1765pub fn renameW(self: Dir, old_sub_path_w: []const u16, new_sub_path_w: []const u16) RenameError!void {
1766 return posix.renameatW(self.fd, old_sub_path_w, self.fd, new_sub_path_w);1766 return posix.renameatW(self.fd, old_sub_path_w, self.fd, new_sub_path_w, windows.TRUE);
1767}1767}
17681768
1769/// Use with `Dir.symLink`, `Dir.atomicSymLink`, and `symLinkAbsolute` to1769/// Use with `Dir.symLink`, `Dir.atomicSymLink`, and `symLinkAbsolute` to