Skip to content

Commit 713534f

Browse files
JustinBrabenricherfu
authored andcommitted
fix compilation errors for fs and fs.Dir (ziglang#21643)
* fix compilation errors for fs and fs.Dir * mem.span instead of mem.sliceTo * Updating symLinkAbsoluteW function parameters * Update with expected rename semantics
1 parent 692bc20 commit 713534f

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

lib/std/fs.zig

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
161161
pub 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.
182182
pub 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.
223223
pub 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.
339339
pub 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.
363363
pub 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.
401401
pub 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`.
439439
pub 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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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`.
11361136
pub 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.
17651765
pub 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

0 commit comments

Comments
 (0)