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 {
160160/// Same as `makeDirAbsolute` except the parameter is a null-terminated WTF-16 LE-encoded string.
161161pub fn makeDirAbsoluteW(absolute_path_w: [*:0]const u16) !void {
162162 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);
164164}
165165
166166/// Same as `Dir.deleteDir` except the path is absolute.
......@@ -181,7 +181,7 @@ pub fn deleteDirAbsoluteZ(dir_path: [*:0]const u8) !void {
181181/// Same as `deleteDirAbsolute` except the path parameter is WTF-16 and target OS is assumed Windows.
182182pub fn deleteDirAbsoluteW(dir_path: [*:0]const u16) !void {
183183 assert(path.isAbsoluteWindowsW(dir_path));
184 return posix.rmdirW(dir_path);
184 return posix.rmdirW(mem.span(dir_path));
185185}
186186
187187/// 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
221221/// Same as `rename` except the parameters are WTF16LE, NT prefixed.
222222/// This function is Windows-only.
223223pub 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);
225225}
226226
227227/// 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
338338/// Same as `createFileAbsolute` but the path parameter is WTF-16 encoded.
339339pub fn createFileAbsoluteW(absolute_path_w: [*:0]const u16, flags: File.CreateFlags) File.OpenError!File {
340340 assert(path.isAbsoluteWindowsW(absolute_path_w));
341 return cwd().createFileW(absolute_path_w, flags);
341 return cwd().createFileW(mem.span(absolute_path_w), flags);
342342}
343343
344344/// 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
362362/// Same as `deleteFileAbsolute` except the parameter is WTF-16 encoded.
363363pub fn deleteFileAbsoluteW(absolute_path_w: [*:0]const u16) Dir.DeleteFileError!void {
364364 assert(path.isAbsoluteWindowsW(absolute_path_w));
365 return cwd().deleteFileW(absolute_path_w);
365 return cwd().deleteFileW(mem.span(absolute_path_w));
366366}
367367
368368/// Removes a symlink, file, or directory.
......@@ -400,7 +400,7 @@ pub fn readLinkAbsolute(pathname: []const u8, buffer: *[max_path_bytes]u8) ![]u8
400400/// encoded.
401401pub fn readlinkAbsoluteW(pathname_w: [*:0]const u16, buffer: *[max_path_bytes]u8) ![]u8 {
402402 assert(path.isAbsoluteWindowsW(pathname_w));
403 return posix.readlinkW(pathname_w, buffer);
403 return posix.readlinkW(mem.span(pathname_w), buffer);
404404}
405405
406406/// Same as `readLink`, except the path parameter is null-terminated.
......@@ -437,13 +437,13 @@ pub fn symLinkAbsolute(
437437/// like to create a symbolic link to a directory, specify this with `SymLinkFlags{ .is_directory = true }`.
438438/// See also `symLinkAbsolute`, `symLinkAbsoluteZ`.
439439pub fn symLinkAbsoluteW(
440 target_path_w: []const u16,
441 sym_link_path_w: []const u16,
440 target_path_w: [*:0]const u16,
441 sym_link_path_w: [*:0]const u16,
442442 flags: Dir.SymLinkFlags,
443443) !void {
444 assert(path.isAbsoluteWindowsWTF16(target_path_w));
445 assert(path.isAbsoluteWindowsWTF16(sym_link_path_w));
446 return windows.CreateSymbolicLink(null, sym_link_path_w, target_path_w, flags.is_directory);
444 assert(path.isAbsoluteWindowsW(target_path_w));
445 assert(path.isAbsoluteWindowsW(sym_link_path_w));
446 return windows.CreateSymbolicLink(null, mem.span(sym_link_path_w), mem.span(target_path_w), flags.is_directory);
447447}
448448
449449/// 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 {
11341134/// To create multiple directories to make an entire path, see `makePath`.
11351135/// To operate on only absolute paths, see `makeDirAbsoluteW`.
11361136pub 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);
11381138}
11391139
11401140/// 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
17631763/// Same as `rename` except the parameters are WTF16LE, NT prefixed.
17641764/// This function is Windows-only.
17651765pub 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);
17671767}
17681768
17691769/// Use with `Dir.symLink`, `Dir.atomicSymLink`, and `symLinkAbsolute` to