diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-12-08 17:45:17 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-12-23 22:15:08 -0800 |
| commit | 4be8be1d2bd6959efae7df95e3f5713adf953a42 (patch) | |
| tree | ee9fb0f267e80ba20d4ae26e1ee61c5c348a08da /lib/std/Io/Dir.zig | |
| parent | 4218344dd3178f2fd3d9d00e9ff6895ee344df6d (diff) | |
| download | zig-4be8be1d2bd6959efae7df95e3f5713adf953a42.tar.gz zig-4be8be1d2bd6959efae7df95e3f5713adf953a42.zip | |
update all rename() to rename(io)
Diffstat (limited to 'lib/std/Io/Dir.zig')
| -rw-r--r-- | lib/std/Io/Dir.zig | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/std/Io/Dir.zig b/lib/std/Io/Dir.zig index 755ce924ad..7d1f6212dc 100644 --- a/lib/std/Io/Dir.zig +++ b/lib/std/Io/Dir.zig @@ -501,7 +501,7 @@ pub const WriteFileError = File.Writer.Error || File.OpenError; pub fn writeFile(dir: Dir, io: Io, options: WriteFileOptions) WriteFileError!void { var file = try dir.createFile(io, options.sub_path, options.flags); defer file.close(io); - try file.writeAll(io, options.data); + try file.writeStreamingAll(io, options.data); } pub const PrevStatus = enum { @@ -955,6 +955,13 @@ pub fn rename( return io.vtable.dirRename(io.userdata, old_dir, old_sub_path, new_dir, new_sub_path); } +pub fn renameAbsolute(io: Io, old_path: []const u8, new_path: []const u8) RenameError!void { + assert(path.isAbsolute(old_path)); + assert(path.isAbsolute(new_path)); + const my_cwd = cwd(); + return io.vtable.dirRename(io.userdata, my_cwd, old_path, my_cwd, new_path); +} + /// Use with `Dir.symLink`, `Dir.symLinkAtomic`, and `symLinkAbsolute` to /// specify whether the symlink will point to a file or a directory. This value /// is ignored on all hosts except Windows where creating symlinks to different @@ -1053,7 +1060,7 @@ pub fn symLinkAtomic( temp_path[dirname.len + 1 ..][0..rand_len].* = std.fmt.hex(random_integer); if (dir.symLink(io, target_path, temp_path, flags)) { - return dir.rename(temp_path, dir, io, sym_link_path); + return dir.rename(temp_path, dir, sym_link_path, io); } else |err| switch (err) { error.PathAlreadyExists => continue, else => |e| return e, |
