authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-19 16:42:28-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:11-08:00
loga8088306f6223b07ad9b7ae37486bcc9e0ac08c9
tree335a999489c68619b496068062a31e572d262e50
parent6e0c7ed8659d9d60a59a9dcddd3aed9cd18b659b

std: rename other Dir "make" functions to "create"


31 files changed, 171 insertions(+), 176 deletions(-)

lib/compiler/build_runner.zig+3-3
...@@ -66,12 +66,12 @@ pub fn main() !void {...@@ -66,12 +66,12 @@ pub fn main() !void {
6666
67 const local_cache_directory: std.Build.Cache.Directory = .{67 const local_cache_directory: std.Build.Cache.Directory = .{
68 .path = cache_root,68 .path = cache_root,
69 .handle = try cwd.makeOpenPath(io, cache_root, .{}),69 .handle = try cwd.createDirPathOpen(io, cache_root, .{}),
70 };70 };
7171
72 const global_cache_directory: std.Build.Cache.Directory = .{72 const global_cache_directory: std.Build.Cache.Directory = .{
73 .path = global_cache_root,73 .path = global_cache_root,
74 .handle = try cwd.makeOpenPath(io, global_cache_root, .{}),74 .handle = try cwd.createDirPathOpen(io, global_cache_root, .{}),
75 };75 };
7676
77 var graph: std.Build.Graph = .{77 var graph: std.Build.Graph = .{
...@@ -80,7 +80,7 @@ pub fn main() !void {...@@ -80,7 +80,7 @@ pub fn main() !void {
80 .cache = .{80 .cache = .{
81 .io = io,81 .io = io,
82 .gpa = arena,82 .gpa = arena,
83 .manifest_dir = try local_cache_directory.handle.makeOpenPath(io, "h", .{}),83 .manifest_dir = try local_cache_directory.handle.createDirPathOpen(io, "h", .{}),
84 },84 },
85 .zig_exe = zig_exe,85 .zig_exe = zig_exe,
86 .env_map = try process.getEnvMap(arena),86 .env_map = try process.getEnvMap(arena),
lib/compiler/translate-c/main.zig+1-1
...@@ -253,7 +253,7 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8, zig_integration...@@ -253,7 +253,7 @@ fn translate(d: *aro.Driver, tc: *aro.Toolchain, args: [][:0]u8, zig_integration
253 if (d.output_name) |path| blk: {253 if (d.output_name) |path| blk: {
254 if (std.mem.eql(u8, path, "-")) break :blk;254 if (std.mem.eql(u8, path, "-")) break :blk;
255 if (std.fs.path.dirname(path)) |dirname| {255 if (std.fs.path.dirname(path)) |dirname| {
256 Io.Dir.cwd().makePath(io, dirname) catch |err|256 Io.Dir.cwd().createDirPath(io, dirname) catch |err|
257 return d.fatal("failed to create path to '{s}': {s}", .{ path, aro.Driver.errorDescription(err) });257 return d.fatal("failed to create path to '{s}': {s}", .{ path, aro.Driver.errorDescription(err) });
258 }258 }
259 out_file = Io.Dir.cwd().createFile(io, path, .{}) catch |err| {259 out_file = Io.Dir.cwd().createFile(io, path, .{}) catch |err| {
lib/std/Build.zig+3-3
...@@ -1701,14 +1701,14 @@ pub fn addCheckFile(...@@ -1701,14 +1701,14 @@ pub fn addCheckFile(
1701 return Step.CheckFile.create(b, file_source, options);1701 return Step.CheckFile.create(b, file_source, options);
1702}1702}
17031703
1704pub fn truncateFile(b: *Build, dest_path: []const u8) (Io.Dir.MakeError || Io.Dir.StatFileError)!void {1704pub fn truncateFile(b: *Build, dest_path: []const u8) (Io.Dir.CreateDirError || Io.Dir.StatFileError)!void {
1705 const io = b.graph.io;1705 const io = b.graph.io;
1706 if (b.verbose) log.info("truncate {s}", .{dest_path});1706 if (b.verbose) log.info("truncate {s}", .{dest_path});
1707 const cwd = Io.Dir.cwd();1707 const cwd = Io.Dir.cwd();
1708 var src_file = cwd.createFile(io, dest_path, .{}) catch |err| switch (err) {1708 var src_file = cwd.createFile(io, dest_path, .{}) catch |err| switch (err) {
1709 error.FileNotFound => blk: {1709 error.FileNotFound => blk: {
1710 if (fs.path.dirname(dest_path)) |dirname| {1710 if (fs.path.dirname(dest_path)) |dirname| {
1711 try cwd.makePath(io, dirname);1711 try cwd.createDirPath(io, dirname);
1712 }1712 }
1713 break :blk try cwd.createFile(io, dest_path, .{});1713 break :blk try cwd.createFile(io, dest_path, .{});
1714 },1714 },
...@@ -2654,7 +2654,7 @@ pub fn makeTempPath(b: *Build) []const u8 {...@@ -2654,7 +2654,7 @@ pub fn makeTempPath(b: *Build) []const u8 {
2654 const rand_int = std.crypto.random.int(u64);2654 const rand_int = std.crypto.random.int(u64);
2655 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(rand_int);2655 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(rand_int);
2656 const result_path = b.cache_root.join(b.allocator, &.{tmp_dir_sub_path}) catch @panic("OOM");2656 const result_path = b.cache_root.join(b.allocator, &.{tmp_dir_sub_path}) catch @panic("OOM");
2657 b.cache_root.handle.makePath(io, tmp_dir_sub_path) catch |err| {2657 b.cache_root.handle.createDirPath(io, tmp_dir_sub_path) catch |err| {
2658 std.debug.print("unable to make tmp path '{s}': {t}\n", .{ result_path, err });2658 std.debug.print("unable to make tmp path '{s}': {t}\n", .{ result_path, err });
2659 };2659 };
2660 return result_path;2660 return result_path;
lib/std/Build/Cache.zig+4-4
...@@ -1330,7 +1330,7 @@ test "cache file and then recall it" {...@@ -1330,7 +1330,7 @@ test "cache file and then recall it" {
1330 var cache: Cache = .{1330 var cache: Cache = .{
1331 .io = io,1331 .io = io,
1332 .gpa = testing.allocator,1332 .gpa = testing.allocator,
1333 .manifest_dir = try tmp.dir.makeOpenPath(io, temp_manifest_dir, .{}),1333 .manifest_dir = try tmp.dir.createDirPathOpen(io, temp_manifest_dir, .{}),
1334 };1334 };
1335 cache.addPrefix(.{ .path = null, .handle = tmp.dir });1335 cache.addPrefix(.{ .path = null, .handle = tmp.dir });
1336 defer cache.manifest_dir.close(io);1336 defer cache.manifest_dir.close(io);
...@@ -1396,7 +1396,7 @@ test "check that changing a file makes cache fail" {...@@ -1396,7 +1396,7 @@ test "check that changing a file makes cache fail" {
1396 var cache: Cache = .{1396 var cache: Cache = .{
1397 .io = io,1397 .io = io,
1398 .gpa = testing.allocator,1398 .gpa = testing.allocator,
1399 .manifest_dir = try tmp.dir.makeOpenPath(io, temp_manifest_dir, .{}),1399 .manifest_dir = try tmp.dir.createDirPathOpen(io, temp_manifest_dir, .{}),
1400 };1400 };
1401 cache.addPrefix(.{ .path = null, .handle = tmp.dir });1401 cache.addPrefix(.{ .path = null, .handle = tmp.dir });
1402 defer cache.manifest_dir.close(io);1402 defer cache.manifest_dir.close(io);
...@@ -1456,7 +1456,7 @@ test "no file inputs" {...@@ -1456,7 +1456,7 @@ test "no file inputs" {
1456 var cache: Cache = .{1456 var cache: Cache = .{
1457 .io = io,1457 .io = io,
1458 .gpa = testing.allocator,1458 .gpa = testing.allocator,
1459 .manifest_dir = try tmp.dir.makeOpenPath(io, temp_manifest_dir, .{}),1459 .manifest_dir = try tmp.dir.createDirPathOpen(io, temp_manifest_dir, .{}),
1460 };1460 };
1461 cache.addPrefix(.{ .path = null, .handle = tmp.dir });1461 cache.addPrefix(.{ .path = null, .handle = tmp.dir });
1462 defer cache.manifest_dir.close(io);1462 defer cache.manifest_dir.close(io);
...@@ -1515,7 +1515,7 @@ test "Manifest with files added after initial hash work" {...@@ -1515,7 +1515,7 @@ test "Manifest with files added after initial hash work" {
1515 var cache: Cache = .{1515 var cache: Cache = .{
1516 .io = io,1516 .io = io,
1517 .gpa = testing.allocator,1517 .gpa = testing.allocator,
1518 .manifest_dir = try tmp.dir.makeOpenPath(io, temp_manifest_dir, .{}),1518 .manifest_dir = try tmp.dir.createDirPathOpen(io, temp_manifest_dir, .{}),
1519 };1519 };
1520 cache.addPrefix(.{ .path = null, .handle = tmp.dir });1520 cache.addPrefix(.{ .path = null, .handle = tmp.dir });
1521 defer cache.manifest_dir.close(io);1521 defer cache.manifest_dir.close(io);
lib/std/Build/Cache/Path.zig+4-4
...@@ -84,14 +84,14 @@ pub fn openDir(...@@ -84,14 +84,14 @@ pub fn openDir(
84 return p.root_dir.handle.openDir(io, joined_path, args);84 return p.root_dir.handle.openDir(io, joined_path, args);
85}85}
8686
87pub fn makeOpenPath(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.OpenOptions) !Io.Dir {87pub fn createDirPathOpen(p: Path, io: Io, sub_path: []const u8, opts: Io.Dir.OpenOptions) !Io.Dir {
88 var buf: [fs.max_path_bytes]u8 = undefined;88 var buf: [fs.max_path_bytes]u8 = undefined;
89 const joined_path = if (p.sub_path.len == 0) sub_path else p: {89 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
90 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{90 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
91 p.sub_path, sub_path,91 p.sub_path, sub_path,
92 }) catch return error.NameTooLong;92 }) catch return error.NameTooLong;
93 };93 };
94 return p.root_dir.handle.makeOpenPath(io, joined_path, opts);94 return p.root_dir.handle.createDirPathOpen(io, joined_path, opts);
95}95}
9696
97pub fn statFile(p: Path, io: Io, sub_path: []const u8) !Io.Dir.Stat {97pub fn statFile(p: Path, io: Io, sub_path: []const u8) !Io.Dir.Stat {
...@@ -129,14 +129,14 @@ pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions...@@ -129,14 +129,14 @@ pub fn access(p: Path, io: Io, sub_path: []const u8, flags: Io.Dir.AccessOptions
129 return p.root_dir.handle.access(io, joined_path, flags);129 return p.root_dir.handle.access(io, joined_path, flags);
130}130}
131131
132pub fn makePath(p: Path, io: Io, sub_path: []const u8) !void {132pub fn createDirPath(p: Path, io: Io, sub_path: []const u8) !void {
133 var buf: [fs.max_path_bytes]u8 = undefined;133 var buf: [fs.max_path_bytes]u8 = undefined;
134 const joined_path = if (p.sub_path.len == 0) sub_path else p: {134 const joined_path = if (p.sub_path.len == 0) sub_path else p: {
135 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{135 break :p std.fmt.bufPrint(&buf, "{s}" ++ fs.path.sep_str ++ "{s}", .{
136 p.sub_path, sub_path,136 p.sub_path, sub_path,
137 }) catch return error.NameTooLong;137 }) catch return error.NameTooLong;
138 };138 };
139 return p.root_dir.handle.makePath(io, joined_path);139 return p.root_dir.handle.createDirPath(io, joined_path);
140}140}
141141
142pub fn toString(p: Path, allocator: Allocator) Allocator.Error![]u8 {142pub fn toString(p: Path, allocator: Allocator) Allocator.Error![]u8 {
lib/std/Build/Step.zig+3-3
...@@ -516,12 +516,12 @@ pub fn installFile(s: *Step, src_lazy_path: Build.LazyPath, dest_path: []const u...@@ -516,12 +516,12 @@ pub fn installFile(s: *Step, src_lazy_path: Build.LazyPath, dest_path: []const u
516 return s.fail("unable to update file from '{f}' to '{s}': {t}", .{ src_path, dest_path, err });516 return s.fail("unable to update file from '{f}' to '{s}': {t}", .{ src_path, dest_path, err });
517}517}
518518
519/// Wrapper around `Io.Dir.makePathStatus` that handles verbose and error output.519/// Wrapper around `Io.Dir.createDirPathStatus` that handles verbose and error output.
520pub fn installDir(s: *Step, dest_path: []const u8) !Io.Dir.MakePathStatus {520pub fn installDir(s: *Step, dest_path: []const u8) !Io.Dir.CreatePathStatus {
521 const b = s.owner;521 const b = s.owner;
522 const io = b.graph.io;522 const io = b.graph.io;
523 try handleVerbose(b, null, &.{ "install", "-d", dest_path });523 try handleVerbose(b, null, &.{ "install", "-d", dest_path });
524 return Io.Dir.cwd().makePathStatus(io, dest_path, .default_dir) catch |err|524 return Io.Dir.cwd().createDirPathStatus(io, dest_path, .default_dir) catch |err|
525 return s.fail("unable to create dir '{s}': {t}", .{ dest_path, err });525 return s.fail("unable to create dir '{s}': {t}", .{ dest_path, err });
526}526}
527527
lib/std/Build/Step/Compile.zig+2-2
...@@ -1669,7 +1669,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {...@@ -1669,7 +1669,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
1669 args_length += arg.len + 1; // +1 to account for null terminator1669 args_length += arg.len + 1; // +1 to account for null terminator
1670 }1670 }
1671 if (args_length >= 30 * 1024) {1671 if (args_length >= 30 * 1024) {
1672 try b.cache_root.handle.makePath(io, "args");1672 try b.cache_root.handle.createDirPath(io, "args");
16731673
1674 const args_to_escape = zig_args.items[2..];1674 const args_to_escape = zig_args.items[2..];
1675 var escaped_args = try std.array_list.Managed([]const u8).initCapacity(arena, args_to_escape.len);1675 var escaped_args = try std.array_list.Managed([]const u8).initCapacity(arena, args_to_escape.len);
...@@ -1706,7 +1706,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {...@@ -1706,7 +1706,7 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
1706 // The args file is already present from a previous run.1706 // The args file is already present from a previous run.
1707 } else |err| switch (err) {1707 } else |err| switch (err) {
1708 error.FileNotFound => {1708 error.FileNotFound => {
1709 try b.cache_root.handle.makePath(io, "tmp");1709 try b.cache_root.handle.createDirPath(io, "tmp");
1710 const rand_int = std.crypto.random.int(u64);1710 const rand_int = std.crypto.random.int(u64);
1711 const tmp_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(rand_int);1711 const tmp_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(rand_int);
1712 try b.cache_root.handle.writeFile(io, .{ .sub_path = tmp_path, .data = args });1712 try b.cache_root.handle.writeFile(io, .{ .sub_path = tmp_path, .data = args });
lib/std/Build/Step/ConfigHeader.zig+1-1
...@@ -258,7 +258,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {...@@ -258,7 +258,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
258 const sub_path = b.pathJoin(&.{ "o", &digest, config_header.include_path });258 const sub_path = b.pathJoin(&.{ "o", &digest, config_header.include_path });
259 const sub_path_dirname = std.fs.path.dirname(sub_path).?;259 const sub_path_dirname = std.fs.path.dirname(sub_path).?;
260260
261 b.cache_root.handle.makePath(io, sub_path_dirname) catch |err| {261 b.cache_root.handle.createDirPath(io, sub_path_dirname) catch |err| {
262 return step.fail("unable to make path '{f}{s}': {s}", .{262 return step.fail("unable to make path '{f}{s}': {s}", .{
263 b.cache_root, sub_path_dirname, @errorName(err),263 b.cache_root, sub_path_dirname, @errorName(err),
264 });264 });
lib/std/Build/Step/ObjCopy.zig+1-1
...@@ -177,7 +177,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {...@@ -177,7 +177,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
177 const cache_path = "o" ++ fs.path.sep_str ++ digest;177 const cache_path = "o" ++ fs.path.sep_str ++ digest;
178 const full_dest_path = try b.cache_root.join(b.allocator, &.{ cache_path, objcopy.basename });178 const full_dest_path = try b.cache_root.join(b.allocator, &.{ cache_path, objcopy.basename });
179 const full_dest_path_debug = try b.cache_root.join(b.allocator, &.{ cache_path, b.fmt("{s}.debug", .{objcopy.basename}) });179 const full_dest_path_debug = try b.cache_root.join(b.allocator, &.{ cache_path, b.fmt("{s}.debug", .{objcopy.basename}) });
180 b.cache_root.handle.makePath(io, cache_path) catch |err| {180 b.cache_root.handle.createDirPath(io, cache_path) catch |err| {
181 return step.fail("unable to make path {s}: {s}", .{ cache_path, @errorName(err) });181 return step.fail("unable to make path {s}: {s}", .{ cache_path, @errorName(err) });
182 };182 };
183183
lib/std/Build/Step/Options.zig+2-2
...@@ -477,7 +477,7 @@ fn make(step: *Step, make_options: Step.MakeOptions) !void {...@@ -477,7 +477,7 @@ fn make(step: *Step, make_options: Step.MakeOptions) !void {
477 } else |outer_err| switch (outer_err) {477 } else |outer_err| switch (outer_err) {
478 error.FileNotFound => {478 error.FileNotFound => {
479 const sub_dirname = fs.path.dirname(sub_path).?;479 const sub_dirname = fs.path.dirname(sub_path).?;
480 b.cache_root.handle.makePath(io, sub_dirname) catch |e|480 b.cache_root.handle.createDirPath(io, sub_dirname) catch |e|
481 return step.fail("unable to make path '{f}{s}': {t}", .{ b.cache_root, sub_dirname, e });481 return step.fail("unable to make path '{f}{s}': {t}", .{ b.cache_root, sub_dirname, e });
482482
483 const rand_int = std.crypto.random.int(u64);483 const rand_int = std.crypto.random.int(u64);
...@@ -486,7 +486,7 @@ fn make(step: *Step, make_options: Step.MakeOptions) !void {...@@ -486,7 +486,7 @@ fn make(step: *Step, make_options: Step.MakeOptions) !void {
486 basename;486 basename;
487 const tmp_sub_path_dirname = fs.path.dirname(tmp_sub_path).?;487 const tmp_sub_path_dirname = fs.path.dirname(tmp_sub_path).?;
488488
489 b.cache_root.handle.makePath(io, tmp_sub_path_dirname) catch |err| {489 b.cache_root.handle.createDirPath(io, tmp_sub_path_dirname) catch |err| {
490 return step.fail("unable to make temporary directory '{f}{s}': {t}", .{490 return step.fail("unable to make temporary directory '{f}{s}': {t}", .{
491 b.cache_root, tmp_sub_path_dirname, err,491 b.cache_root, tmp_sub_path_dirname, err,
492 });492 });
lib/std/Build/Step/Run.zig+3-3
...@@ -975,7 +975,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {...@@ -975,7 +975,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
975 .output_directory => output_sub_path,975 .output_directory => output_sub_path,
976 else => unreachable,976 else => unreachable,
977 };977 };
978 b.cache_root.handle.makePath(io, output_sub_dir_path) catch |err| {978 b.cache_root.handle.createDirPath(io, output_sub_dir_path) catch |err| {
979 return step.fail("unable to make path '{f}{s}': {s}", .{979 return step.fail("unable to make path '{f}{s}': {s}", .{
980 b.cache_root, output_sub_dir_path, @errorName(err),980 b.cache_root, output_sub_dir_path, @errorName(err),
981 });981 });
...@@ -1007,7 +1007,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {...@@ -1007,7 +1007,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
1007 .output_directory => output_sub_path,1007 .output_directory => output_sub_path,
1008 else => unreachable,1008 else => unreachable,
1009 };1009 };
1010 b.cache_root.handle.makePath(io, output_sub_dir_path) catch |err| {1010 b.cache_root.handle.createDirPath(io, output_sub_dir_path) catch |err| {
1011 return step.fail("unable to make path '{f}{s}': {s}", .{1011 return step.fail("unable to make path '{f}{s}': {s}", .{
1012 b.cache_root, output_sub_dir_path, @errorName(err),1012 b.cache_root, output_sub_dir_path, @errorName(err),
1013 });1013 });
...@@ -1439,7 +1439,7 @@ fn runCommand(...@@ -1439,7 +1439,7 @@ fn runCommand(
14391439
1440 const sub_path = b.pathJoin(&output_components);1440 const sub_path = b.pathJoin(&output_components);
1441 const sub_path_dirname = Dir.path.dirname(sub_path).?;1441 const sub_path_dirname = Dir.path.dirname(sub_path).?;
1442 b.cache_root.handle.makePath(io, sub_path_dirname) catch |err| {1442 b.cache_root.handle.createDirPath(io, sub_path_dirname) catch |err| {
1443 return step.fail("unable to make path '{f}{s}': {s}", .{1443 return step.fail("unable to make path '{f}{s}': {s}", .{
1444 b.cache_root, sub_path_dirname, @errorName(err),1444 b.cache_root, sub_path_dirname, @errorName(err),
1445 });1445 });
lib/std/Build/Step/UpdateSourceFiles.zig+1-1
...@@ -78,7 +78,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {...@@ -78,7 +78,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
78 var any_miss = false;78 var any_miss = false;
79 for (usf.output_source_files.items) |output_source_file| {79 for (usf.output_source_files.items) |output_source_file| {
80 if (fs.path.dirname(output_source_file.sub_path)) |dirname| {80 if (fs.path.dirname(output_source_file.sub_path)) |dirname| {
81 b.build_root.handle.makePath(io, dirname) catch |err| {81 b.build_root.handle.createDirPath(io, dirname) catch |err| {
82 return step.fail("unable to make path '{f}{s}': {t}", .{ b.build_root, dirname, err });82 return step.fail("unable to make path '{f}{s}': {t}", .{ b.build_root, dirname, err });
83 };83 };
84 }84 }
lib/std/Build/Step/WriteFile.zig+4-4
...@@ -259,13 +259,13 @@ fn make(step: *Step, options: Step.MakeOptions) !void {...@@ -259,13 +259,13 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
259259
260 write_file.generated_directory.path = try b.cache_root.join(arena, &.{ "o", &digest });260 write_file.generated_directory.path = try b.cache_root.join(arena, &.{ "o", &digest });
261261
262 var cache_dir = b.cache_root.handle.makeOpenPath(io, cache_path, .{}) catch |err|262 var cache_dir = b.cache_root.handle.createDirPathOpen(io, cache_path, .{}) catch |err|
263 return step.fail("unable to make path '{f}{s}': {t}", .{ b.cache_root, cache_path, err });263 return step.fail("unable to make path '{f}{s}': {t}", .{ b.cache_root, cache_path, err });
264 defer cache_dir.close(io);264 defer cache_dir.close(io);
265265
266 for (write_file.files.items) |file| {266 for (write_file.files.items) |file| {
267 if (fs.path.dirname(file.sub_path)) |dirname| {267 if (fs.path.dirname(file.sub_path)) |dirname| {
268 cache_dir.makePath(io, dirname) catch |err| {268 cache_dir.createDirPath(io, dirname) catch |err| {
269 return step.fail("unable to make path '{f}{s}{c}{s}': {t}", .{269 return step.fail("unable to make path '{f}{s}{c}{s}': {t}", .{
270 b.cache_root, cache_path, fs.path.sep, dirname, err,270 b.cache_root, cache_path, fs.path.sep, dirname, err,
271 });271 });
...@@ -300,7 +300,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {...@@ -300,7 +300,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
300 const dest_dirname = dir.sub_path;300 const dest_dirname = dir.sub_path;
301301
302 if (dest_dirname.len != 0) {302 if (dest_dirname.len != 0) {
303 cache_dir.makePath(io, dest_dirname) catch |err| {303 cache_dir.createDirPath(io, dest_dirname) catch |err| {
304 return step.fail("unable to make path '{f}{s}{c}{s}': {s}", .{304 return step.fail("unable to make path '{f}{s}{c}{s}': {s}", .{
305 b.cache_root, cache_path, fs.path.sep, dest_dirname, @errorName(err),305 b.cache_root, cache_path, fs.path.sep, dest_dirname, @errorName(err),
306 });306 });
...@@ -315,7 +315,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {...@@ -315,7 +315,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
315 const src_entry_path = try src_dir_path.join(arena, entry.path);315 const src_entry_path = try src_dir_path.join(arena, entry.path);
316 const dest_path = b.pathJoin(&.{ dest_dirname, entry.path });316 const dest_path = b.pathJoin(&.{ dest_dirname, entry.path });
317 switch (entry.kind) {317 switch (entry.kind) {
318 .directory => try cache_dir.makePath(io, dest_path),318 .directory => try cache_dir.createDirPath(io, dest_path),
319 .file => {319 .file => {
320 const prev_status = Io.Dir.updateFile(320 const prev_status = Io.Dir.updateFile(
321 src_entry_path.root_dir.handle,321 src_entry_path.root_dir.handle,
lib/std/Io.zig+3-3
...@@ -659,9 +659,9 @@ pub const VTable = struct {...@@ -659,9 +659,9 @@ pub const VTable = struct {
659 futexWaitUncancelable: *const fn (?*anyopaque, ptr: *const u32, expected: u32) void,659 futexWaitUncancelable: *const fn (?*anyopaque, ptr: *const u32, expected: u32) void,
660 futexWake: *const fn (?*anyopaque, ptr: *const u32, max_waiters: u32) void,660 futexWake: *const fn (?*anyopaque, ptr: *const u32, max_waiters: u32) void,
661661
662 dirMake: *const fn (?*anyopaque, Dir, []const u8, Dir.Permissions) Dir.MakeError!void,662 dirCreateDir: *const fn (?*anyopaque, Dir, []const u8, Dir.Permissions) Dir.CreateDirError!void,
663 dirMakePath: *const fn (?*anyopaque, Dir, []const u8, Dir.Permissions) Dir.MakePathError!Dir.MakePathStatus,663 dirCreateDirPath: *const fn (?*anyopaque, Dir, []const u8, Dir.Permissions) Dir.CreateDirPathError!Dir.CreatePathStatus,
664 dirMakeOpenPath: *const fn (?*anyopaque, Dir, []const u8, Dir.Permissions, Dir.OpenOptions) Dir.MakeOpenPathError!Dir,664 dirCreateDirPathOpen: *const fn (?*anyopaque, Dir, []const u8, Dir.Permissions, Dir.OpenOptions) Dir.CreateDirPathOpenError!Dir,
665 dirOpenDir: *const fn (?*anyopaque, Dir, []const u8, Dir.OpenOptions) Dir.OpenError!Dir,665 dirOpenDir: *const fn (?*anyopaque, Dir, []const u8, Dir.OpenOptions) Dir.OpenError!Dir,
666 dirStat: *const fn (?*anyopaque, Dir) Dir.StatError!Dir.Stat,666 dirStat: *const fn (?*anyopaque, Dir) Dir.StatError!Dir.Stat,
667 dirStatFile: *const fn (?*anyopaque, Dir, []const u8, Dir.StatFileOptions) Dir.StatFileError!File.Stat,667 dirStatFile: *const fn (?*anyopaque, Dir, []const u8, Dir.StatFileOptions) Dir.StatFileError!File.Stat,
lib/std/Io/Dir.zig+20-20
...@@ -590,7 +590,7 @@ pub fn updateFile(...@@ -590,7 +590,7 @@ pub fn updateFile(
590 }590 }
591591
592 if (path.dirname(dest_path)) |dirname| {592 if (path.dirname(dest_path)) |dirname| {
593 try dest_dir.makePath(io, dirname);593 try dest_dir.createDirPath(io, dirname);
594 }594 }
595595
596 var buffer: [1000]u8 = undefined; // Used only when direct fd-to-fd is not available.596 var buffer: [1000]u8 = undefined; // Used only when direct fd-to-fd is not available.
...@@ -637,7 +637,7 @@ pub fn readFile(dir: Dir, io: Io, file_path: []const u8, buffer: []u8) ReadFileE...@@ -637,7 +637,7 @@ pub fn readFile(dir: Dir, io: Io, file_path: []const u8, buffer: []u8) ReadFileE
637 return buffer[0..n];637 return buffer[0..n];
638}638}
639639
640pub const MakeError = error{640pub const CreateDirError = error{
641 /// In WASI, this error may occur when the file descriptor does641 /// In WASI, this error may occur when the file descriptor does
642 /// not hold the required rights to create a new directory relative to it.642 /// not hold the required rights to create a new directory relative to it.
643 AccessDenied,643 AccessDenied,
...@@ -663,10 +663,10 @@ pub const MakeError = error{...@@ -663,10 +663,10 @@ pub const MakeError = error{
663/// * On other platforms, `sub_path` is an opaque sequence of bytes with no particular encoding.663/// * On other platforms, `sub_path` is an opaque sequence of bytes with no particular encoding.
664///664///
665/// Related:665/// Related:
666/// * `makePath`666/// * `createDirPath`
667/// * `createDirAbsolute`667/// * `createDirAbsolute`
668pub fn createDir(dir: Dir, io: Io, sub_path: []const u8, permissions: Permissions) MakeError!void {668pub fn createDir(dir: Dir, io: Io, sub_path: []const u8, permissions: Permissions) CreateDirError!void {
669 return io.vtable.dirMake(io.userdata, dir, sub_path, permissions);669 return io.vtable.dirCreateDir(io.userdata, dir, sub_path, permissions);
670}670}
671671
672/// Create a new directory, based on an absolute path.672/// Create a new directory, based on an absolute path.
...@@ -677,14 +677,14 @@ pub fn createDir(dir: Dir, io: Io, sub_path: []const u8, permissions: Permission...@@ -677,14 +677,14 @@ pub fn createDir(dir: Dir, io: Io, sub_path: []const u8, permissions: Permission
677/// On Windows, `absolute_path` should be encoded as [WTF-8](https://wtf-8.codeberg.page/).677/// On Windows, `absolute_path` should be encoded as [WTF-8](https://wtf-8.codeberg.page/).
678/// On WASI, `absolute_path` should be encoded as valid UTF-8.678/// On WASI, `absolute_path` should be encoded as valid UTF-8.
679/// On other platforms, `absolute_path` is an opaque sequence of bytes with no particular encoding.679/// On other platforms, `absolute_path` is an opaque sequence of bytes with no particular encoding.
680pub fn createDirAbsolute(io: Io, absolute_path: []const u8, permissions: Permissions) MakeError!void {680pub fn createDirAbsolute(io: Io, absolute_path: []const u8, permissions: Permissions) CreateDirError!void {
681 assert(path.isAbsolute(absolute_path));681 assert(path.isAbsolute(absolute_path));
682 return createDir(.cwd(), io, absolute_path, permissions);682 return createDir(.cwd(), io, absolute_path, permissions);
683}683}
684684
685test createDirAbsolute {}685test createDirAbsolute {}
686686
687pub const MakePathError = MakeError || StatFileError;687pub const CreateDirPathError = CreateDirError || StatFileError;
688688
689/// Creates parent directories with default permissions as necessary to ensure689/// Creates parent directories with default permissions as necessary to ensure
690/// `sub_path` exists as a directory.690/// `sub_path` exists as a directory.
...@@ -710,27 +710,27 @@ pub const MakePathError = MakeError || StatFileError;...@@ -710,27 +710,27 @@ pub const MakePathError = MakeError || StatFileError;
710/// and a `./second` directory.710/// and a `./second` directory.
711///711///
712/// See also:712/// See also:
713/// * `makePathStatus`713/// * `createDirPathStatus`
714pub fn makePath(dir: Dir, io: Io, sub_path: []const u8) MakePathError!void {714pub fn createDirPath(dir: Dir, io: Io, sub_path: []const u8) CreateDirPathError!void {
715 _ = try io.vtable.dirMakePath(io.userdata, dir, sub_path, .default_dir);715 _ = try io.vtable.dirCreateDirPath(io.userdata, dir, sub_path, .default_dir);
716}716}
717717
718pub const MakePathStatus = enum { existed, created };718pub const CreatePathStatus = enum { existed, created };
719719
720/// Same as `makePath` except returns whether the path already existed or was720/// Same as `createDirPath` except returns whether the path already existed or was
721/// successfully created.721/// successfully created.
722pub fn makePathStatus(dir: Dir, io: Io, sub_path: []const u8, permissions: Permissions) MakePathError!MakePathStatus {722pub fn createDirPathStatus(dir: Dir, io: Io, sub_path: []const u8, permissions: Permissions) CreateDirPathError!CreatePathStatus {
723 return io.vtable.dirMakePath(io.userdata, dir, sub_path, permissions);723 return io.vtable.dirCreateDirPath(io.userdata, dir, sub_path, permissions);
724}724}
725725
726pub const MakeOpenPathError = MakeError || OpenError || StatFileError;726pub const CreateDirPathOpenError = CreateDirError || OpenError || StatFileError;
727727
728pub const MakeOpenPathOptions = struct {728pub const CreateDirPathOpenOptions = struct {
729 open_options: OpenOptions = .{},729 open_options: OpenOptions = .{},
730 permissions: Permissions = .default_dir,730 permissions: Permissions = .default_dir,
731};731};
732732
733/// Performs the equivalent of `makePath` followed by `openDir`, atomically if possible.733/// Performs the equivalent of `createDirPath` followed by `openDir`, atomically if possible.
734///734///
735/// When this operation is canceled, it may leave the file system in a735/// When this operation is canceled, it may leave the file system in a
736/// partially modified state.736/// partially modified state.
...@@ -738,8 +738,8 @@ pub const MakeOpenPathOptions = struct {...@@ -738,8 +738,8 @@ pub const MakeOpenPathOptions = struct {
738/// On Windows, `sub_path` should be encoded as [WTF-8](https://wtf-8.codeberg.page/).738/// On Windows, `sub_path` should be encoded as [WTF-8](https://wtf-8.codeberg.page/).
739/// On WASI, `sub_path` should be encoded as valid UTF-8.739/// On WASI, `sub_path` should be encoded as valid UTF-8.
740/// On other platforms, `sub_path` is an opaque sequence of bytes with no particular encoding.740/// On other platforms, `sub_path` is an opaque sequence of bytes with no particular encoding.
741pub fn makeOpenPath(dir: Dir, io: Io, sub_path: []const u8, options: MakeOpenPathOptions) MakeOpenPathError!Dir {741pub fn createDirPathOpen(dir: Dir, io: Io, sub_path: []const u8, options: CreateDirPathOpenOptions) CreateDirPathOpenError!Dir {
742 return io.vtable.dirMakeOpenPath(io.userdata, dir, sub_path, options.permissions, options.open_options);742 return io.vtable.dirCreateDirPathOpen(io.userdata, dir, sub_path, options.permissions, options.open_options);
743}743}
744744
745pub const Stat = File.Stat;745pub const Stat = File.Stat;
...@@ -1729,7 +1729,7 @@ pub const AtomicFileOptions = struct {...@@ -1729,7 +1729,7 @@ pub const AtomicFileOptions = struct {
1729pub fn atomicFile(parent: Dir, io: Io, dest_path: []const u8, options: AtomicFileOptions) !File.Atomic {1729pub fn atomicFile(parent: Dir, io: Io, dest_path: []const u8, options: AtomicFileOptions) !File.Atomic {
1730 if (path.dirname(dest_path)) |dirname| {1730 if (path.dirname(dest_path)) |dirname| {
1731 const dir = if (options.make_path)1731 const dir = if (options.make_path)
1732 try parent.makeOpenPath(io, dirname, .{})1732 try parent.createDirPathOpen(io, dirname, .{})
1733 else1733 else
1734 try parent.openDir(io, dirname, .{});1734 try parent.openDir(io, dirname, .{});
17351735
lib/std/Io/Kqueue.zig+6-6
...@@ -869,9 +869,9 @@ pub fn io(k: *Kqueue) Io {...@@ -869,9 +869,9 @@ pub fn io(k: *Kqueue) Io {
869 .conditionWaitUncancelable = conditionWaitUncancelable,869 .conditionWaitUncancelable = conditionWaitUncancelable,
870 .conditionWake = conditionWake,870 .conditionWake = conditionWake,
871871
872 .dirMake = dirMake,872 .dirCreateDir = dirCreateDir,
873 .dirMakePath = dirMakePath,873 .dirCreateDirPath = dirCreateDirPath,
874 .dirMakeOpenPath = dirMakeOpenPath,874 .dirCreateDirPathOpen = dirCreateDirPathOpen,
875 .dirStat = dirStat,875 .dirStat = dirStat,
876 .dirStatFile = dirStatFile,876 .dirStatFile = dirStatFile,
877877
...@@ -1114,7 +1114,7 @@ fn conditionWake(userdata: ?*anyopaque, cond: *Io.Condition, wake: Io.Condition....@@ -1114,7 +1114,7 @@ fn conditionWake(userdata: ?*anyopaque, cond: *Io.Condition, wake: Io.Condition.
1114 k.yield(waiting_fiber, .reschedule);1114 k.yield(waiting_fiber, .reschedule);
1115}1115}
11161116
1117fn dirMake(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.Mode) Dir.MakeError!void {1117fn dirCreateDir(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.Mode) Dir.CreateDirError!void {
1118 const k: *Kqueue = @ptrCast(@alignCast(userdata));1118 const k: *Kqueue = @ptrCast(@alignCast(userdata));
1119 _ = k;1119 _ = k;
1120 _ = dir;1120 _ = dir;
...@@ -1122,7 +1122,7 @@ fn dirMake(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.Mode...@@ -1122,7 +1122,7 @@ fn dirMake(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.Mode
1122 _ = mode;1122 _ = mode;
1123 @panic("TODO");1123 @panic("TODO");
1124}1124}
1125fn dirMakePath(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.Mode) Dir.MakeError!void {1125fn dirCreateDirPath(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.Mode) Dir.CreateDirError!void {
1126 const k: *Kqueue = @ptrCast(@alignCast(userdata));1126 const k: *Kqueue = @ptrCast(@alignCast(userdata));
1127 _ = k;1127 _ = k;
1128 _ = dir;1128 _ = dir;
...@@ -1130,7 +1130,7 @@ fn dirMakePath(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir....@@ -1130,7 +1130,7 @@ fn dirMakePath(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, mode: Dir.
1130 _ = mode;1130 _ = mode;
1131 @panic("TODO");1131 @panic("TODO");
1132}1132}
1133fn dirMakeOpenPath(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.OpenOptions) Dir.MakeOpenPathError!Dir {1133fn dirCreateDirPathOpen(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, options: Dir.OpenOptions) Dir.CreateDirPathOpenError!Dir {
1134 const k: *Kqueue = @ptrCast(@alignCast(userdata));1134 const k: *Kqueue = @ptrCast(@alignCast(userdata));
1135 _ = k;1135 _ = k;
1136 _ = dir;1136 _ = dir;
lib/std/Io/Threaded.zig+30-35
...@@ -711,9 +711,9 @@ pub fn io(t: *Threaded) Io {...@@ -711,9 +711,9 @@ pub fn io(t: *Threaded) Io {
711 .futexWaitUncancelable = futexWaitUncancelable,711 .futexWaitUncancelable = futexWaitUncancelable,
712 .futexWake = futexWake,712 .futexWake = futexWake,
713713
714 .dirMake = dirMake,714 .dirCreateDir = dirCreateDir,
715 .dirMakePath = dirMakePath,715 .dirCreateDirPath = dirCreateDirPath,
716 .dirMakeOpenPath = dirMakeOpenPath,716 .dirCreateDirPathOpen = dirCreateDirPathOpen,
717 .dirStat = dirStat,717 .dirStat = dirStat,
718 .dirStatFile = dirStatFile,718 .dirStatFile = dirStatFile,
719 .dirAccess = dirAccess,719 .dirAccess = dirAccess,
...@@ -846,9 +846,9 @@ pub fn ioBasic(t: *Threaded) Io {...@@ -846,9 +846,9 @@ pub fn ioBasic(t: *Threaded) Io {
846 .futexWaitUncancelable = futexWaitUncancelable,846 .futexWaitUncancelable = futexWaitUncancelable,
847 .futexWake = futexWake,847 .futexWake = futexWake,
848848
849 .dirMake = dirMake,849 .dirCreateDir = dirCreateDir,
850 .dirMakePath = dirMakePath,850 .dirCreateDirPath = dirCreateDirPath,
851 .dirMakeOpenPath = dirMakeOpenPath,851 .dirCreateDirPathOpen = dirCreateDirPathOpen,
852 .dirStat = dirStat,852 .dirStat = dirStat,
853 .dirStatFile = dirStatFile,853 .dirStatFile = dirStatFile,
854 .dirAccess = dirAccess,854 .dirAccess = dirAccess,
...@@ -1507,13 +1507,13 @@ fn futexWake(userdata: ?*anyopaque, ptr: *const u32, max_waiters: u32) void {...@@ -1507,13 +1507,13 @@ fn futexWake(userdata: ?*anyopaque, ptr: *const u32, max_waiters: u32) void {
1507 }1507 }
1508}1508}
15091509
1510const dirMake = switch (native_os) {1510const dirCreateDir = switch (native_os) {
1511 .windows => dirMakeWindows,1511 .windows => dirCreateDirWindows,
1512 .wasi => dirMakeWasi,1512 .wasi => dirCreateDirWasi,
1513 else => dirMakePosix,1513 else => dirCreateDirPosix,
1514};1514};
15151515
1516fn dirMakePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: Dir.Permissions) Dir.MakeError!void {1516fn dirCreateDirPosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: Dir.Permissions) Dir.CreateDirError!void {
1517 const t: *Threaded = @ptrCast(@alignCast(userdata));1517 const t: *Threaded = @ptrCast(@alignCast(userdata));
1518 const current_thread = Thread.getCurrent(t);1518 const current_thread = Thread.getCurrent(t);
15191519
...@@ -1559,8 +1559,8 @@ fn dirMakePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissio...@@ -1559,8 +1559,8 @@ fn dirMakePosix(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissio
1559 }1559 }
1560}1560}
15611561
1562fn dirMakeWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: Dir.Permissions) Dir.MakeError!void {1562fn dirCreateDirWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: Dir.Permissions) Dir.CreateDirError!void {
1563 if (builtin.link_libc) return dirMakePosix(userdata, dir, sub_path, permissions);1563 if (builtin.link_libc) return dirCreateDirPosix(userdata, dir, sub_path, permissions);
1564 const t: *Threaded = @ptrCast(@alignCast(userdata));1564 const t: *Threaded = @ptrCast(@alignCast(userdata));
1565 const current_thread = Thread.getCurrent(t);1565 const current_thread = Thread.getCurrent(t);
1566 try current_thread.beginSyscall();1566 try current_thread.beginSyscall();
...@@ -1601,7 +1601,7 @@ fn dirMakeWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permission...@@ -1601,7 +1601,7 @@ fn dirMakeWasi(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permission
1601 }1601 }
1602}1602}
16031603
1604fn dirMakeWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: Dir.Permissions) Dir.MakeError!void {1604fn dirCreateDirWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permissions: Dir.Permissions) Dir.CreateDirError!void {
1605 const t: *Threaded = @ptrCast(@alignCast(userdata));1605 const t: *Threaded = @ptrCast(@alignCast(userdata));
1606 const current_thread = Thread.getCurrent(t);1606 const current_thread = Thread.getCurrent(t);
1607 try current_thread.checkCancel();1607 try current_thread.checkCancel();
...@@ -1627,19 +1627,19 @@ fn dirMakeWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permiss...@@ -1627,19 +1627,19 @@ fn dirMakeWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, permiss
1627 windows.CloseHandle(sub_dir_handle);1627 windows.CloseHandle(sub_dir_handle);
1628}1628}
16291629
1630fn dirMakePath(1630fn dirCreateDirPath(
1631 userdata: ?*anyopaque,1631 userdata: ?*anyopaque,
1632 dir: Dir,1632 dir: Dir,
1633 sub_path: []const u8,1633 sub_path: []const u8,
1634 permissions: Dir.Permissions,1634 permissions: Dir.Permissions,
1635) Dir.MakePathError!Dir.MakePathStatus {1635) Dir.CreateDirPathError!Dir.CreatePathStatus {
1636 const t: *Threaded = @ptrCast(@alignCast(userdata));1636 const t: *Threaded = @ptrCast(@alignCast(userdata));
16371637
1638 var it = std.fs.path.componentIterator(sub_path);1638 var it = std.fs.path.componentIterator(sub_path);
1639 var status: Dir.MakePathStatus = .existed;1639 var status: Dir.CreatePathStatus = .existed;
1640 var component = it.last() orelse return error.BadPathName;1640 var component = it.last() orelse return error.BadPathName;
1641 while (true) {1641 while (true) {
1642 if (dirMake(t, dir, component.path, permissions)) |_| {1642 if (dirCreateDir(t, dir, component.path, permissions)) |_| {
1643 status = .created;1643 status = .created;
1644 } else |err| switch (err) {1644 } else |err| switch (err) {
1645 error.PathAlreadyExists => {1645 error.PathAlreadyExists => {
...@@ -1659,37 +1659,37 @@ fn dirMakePath(...@@ -1659,37 +1659,37 @@ fn dirMakePath(
1659 }1659 }
1660}1660}
16611661
1662const dirMakeOpenPath = switch (native_os) {1662const dirCreateDirPathOpen = switch (native_os) {
1663 .windows => dirMakeOpenPathWindows,1663 .windows => dirCreateDirPathOpenWindows,
1664 .wasi => dirMakeOpenPathWasi,1664 .wasi => dirCreateDirPathOpenWasi,
1665 else => dirMakeOpenPathPosix,1665 else => dirCreateDirPathOpenPosix,
1666};1666};
16671667
1668fn dirMakeOpenPathPosix(1668fn dirCreateDirPathOpenPosix(
1669 userdata: ?*anyopaque,1669 userdata: ?*anyopaque,
1670 dir: Dir,1670 dir: Dir,
1671 sub_path: []const u8,1671 sub_path: []const u8,
1672 permissions: Dir.Permissions,1672 permissions: Dir.Permissions,
1673 options: Dir.OpenOptions,1673 options: Dir.OpenOptions,
1674) Dir.MakeOpenPathError!Dir {1674) Dir.CreateDirPathOpenError!Dir {
1675 const t: *Threaded = @ptrCast(@alignCast(userdata));1675 const t: *Threaded = @ptrCast(@alignCast(userdata));
1676 const t_io = ioBasic(t);1676 const t_io = ioBasic(t);
1677 return dirOpenDirPosix(t, dir, sub_path, options) catch |err| switch (err) {1677 return dirOpenDirPosix(t, dir, sub_path, options) catch |err| switch (err) {
1678 error.FileNotFound => {1678 error.FileNotFound => {
1679 _ = try dir.makePathStatus(t_io, sub_path, permissions);1679 _ = try dir.createDirPathStatus(t_io, sub_path, permissions);
1680 return dirOpenDirPosix(t, dir, sub_path, options);1680 return dirOpenDirPosix(t, dir, sub_path, options);
1681 },1681 },
1682 else => |e| return e,1682 else => |e| return e,
1683 };1683 };
1684}1684}
16851685
1686fn dirMakeOpenPathWindows(1686fn dirCreateDirPathOpenWindows(
1687 userdata: ?*anyopaque,1687 userdata: ?*anyopaque,
1688 dir: Dir,1688 dir: Dir,
1689 sub_path: []const u8,1689 sub_path: []const u8,
1690 permissions: Dir.Permissions,1690 permissions: Dir.Permissions,
1691 options: Dir.OpenOptions,1691 options: Dir.OpenOptions,
1692) Dir.MakeOpenPathError!Dir {1692) Dir.CreateDirPathOpenError!Dir {
1693 const t: *Threaded = @ptrCast(@alignCast(userdata));1693 const t: *Threaded = @ptrCast(@alignCast(userdata));
1694 const current_thread = Thread.getCurrent(t);1694 const current_thread = Thread.getCurrent(t);
1695 const w = windows;1695 const w = windows;
...@@ -1795,18 +1795,18 @@ fn dirMakeOpenPathWindows(...@@ -1795,18 +1795,18 @@ fn dirMakeOpenPathWindows(
1795 }1795 }
1796}1796}
17971797
1798fn dirMakeOpenPathWasi(1798fn dirCreateDirPathOpenWasi(
1799 userdata: ?*anyopaque,1799 userdata: ?*anyopaque,
1800 dir: Dir,1800 dir: Dir,
1801 sub_path: []const u8,1801 sub_path: []const u8,
1802 permissions: Dir.Permissions,1802 permissions: Dir.Permissions,
1803 options: Dir.OpenOptions,1803 options: Dir.OpenOptions,
1804) Dir.MakeOpenPathError!Dir {1804) Dir.CreateDirPathOpenError!Dir {
1805 const t: *Threaded = @ptrCast(@alignCast(userdata));1805 const t: *Threaded = @ptrCast(@alignCast(userdata));
1806 const t_io = ioBasic(t);1806 const t_io = ioBasic(t);
1807 return dirOpenDirWasi(t, dir, sub_path, options) catch |err| switch (err) {1807 return dirOpenDirWasi(t, dir, sub_path, options) catch |err| switch (err) {
1808 error.FileNotFound => {1808 error.FileNotFound => {
1809 _ = try dir.makePathStatus(t_io, sub_path, permissions);1809 _ = try dir.createDirPathStatus(t_io, sub_path, permissions);
1810 return dirOpenDirWasi(t, dir, sub_path, options);1810 return dirOpenDirWasi(t, dir, sub_path, options);
1811 },1811 },
1812 else => |e| return e,1812 else => |e| return e,
...@@ -3352,11 +3352,6 @@ pub fn dirOpenDirWindows(...@@ -3352,11 +3352,6 @@ pub fn dirOpenDirWindows(
3352 }3352 }
3353}3353}
33543354
3355const MakeOpenDirAccessMaskWOptions = struct {
3356 no_follow: bool,
3357 create_disposition: u32,
3358};
3359
3360fn dirClose(userdata: ?*anyopaque, dirs: []const Dir) void {3355fn dirClose(userdata: ?*anyopaque, dirs: []const Dir) void {
3361 const t: *Threaded = @ptrCast(@alignCast(userdata));3356 const t: *Threaded = @ptrCast(@alignCast(userdata));
3362 _ = t;3357 _ = t;
lib/std/fs/test.zig+33-33
...@@ -226,7 +226,7 @@ test "Dir.readLink" {...@@ -226,7 +226,7 @@ test "Dir.readLink" {
226 // test 3: relative path symlink226 // test 3: relative path symlink
227 const parent_file = ".." ++ Dir.path.sep_str ++ "target.txt";227 const parent_file = ".." ++ Dir.path.sep_str ++ "target.txt";
228 const canonical_parent_file = try ctx.toCanonicalPathSep(parent_file);228 const canonical_parent_file = try ctx.toCanonicalPathSep(parent_file);
229 var subdir = try ctx.dir.makeOpenPath(io, "subdir", .{});229 var subdir = try ctx.dir.createDirPathOpen(io, "subdir", .{});
230 defer subdir.close(io);230 defer subdir.close(io);
231 try setupSymlink(io, subdir, canonical_parent_file, "relative-link.txt", .{});231 try setupSymlink(io, subdir, canonical_parent_file, "relative-link.txt", .{});
232 try testReadLink(io, subdir, canonical_parent_file, "relative-link.txt");232 try testReadLink(io, subdir, canonical_parent_file, "relative-link.txt");
...@@ -411,7 +411,7 @@ test "openDir non-cwd parent '..'" {...@@ -411,7 +411,7 @@ test "openDir non-cwd parent '..'" {
411 var tmp = tmpDir(.{});411 var tmp = tmpDir(.{});
412 defer tmp.cleanup();412 defer tmp.cleanup();
413413
414 var subdir = try tmp.dir.makeOpenPath(io, "subdir", .{});414 var subdir = try tmp.dir.createDirPathOpen(io, "subdir", .{});
415 defer subdir.close(io);415 defer subdir.close(io);
416416
417 var dir = try subdir.openDir(io, "..", .{});417 var dir = try subdir.openDir(io, "..", .{});
...@@ -613,13 +613,13 @@ test "Dir.Iterator but dir is deleted during iteration" {...@@ -613,13 +613,13 @@ test "Dir.Iterator but dir is deleted during iteration" {
613 defer tmp.cleanup();613 defer tmp.cleanup();
614614
615 // Create directory and setup an iterator for it615 // Create directory and setup an iterator for it
616 var subdir = try tmp.dir.makeOpenPath(io, "subdir", .{ .open_options = .{ .iterate = true } });616 var subdir = try tmp.dir.createDirPathOpen(io, "subdir", .{ .open_options = .{ .iterate = true } });
617 defer subdir.close(io);617 defer subdir.close(io);
618618
619 var iterator = subdir.iterate();619 var iterator = subdir.iterate();
620620
621 // Create something to iterate over within the subdir621 // Create something to iterate over within the subdir
622 try tmp.dir.makePath(io, "subdir" ++ Dir.path.sep_str ++ "b");622 try tmp.dir.createDirPath(io, "subdir" ++ Dir.path.sep_str ++ "b");
623623
624 // Then, before iterating, delete the directory that we're iterating.624 // Then, before iterating, delete the directory that we're iterating.
625 // This is a contrived reproduction, but this could happen outside of the program, in another thread, etc.625 // This is a contrived reproduction, but this could happen outside of the program, in another thread, etc.
...@@ -862,13 +862,13 @@ test "file operations on directories" {...@@ -862,13 +862,13 @@ test "file operations on directories" {
862 }.impl);862 }.impl);
863}863}
864864
865test "makeOpenPath parent dirs do not exist" {865test "createDirPathOpen parent dirs do not exist" {
866 const io = testing.io;866 const io = testing.io;
867867
868 var tmp_dir = tmpDir(.{});868 var tmp_dir = tmpDir(.{});
869 defer tmp_dir.cleanup();869 defer tmp_dir.cleanup();
870870
871 var dir = try tmp_dir.dir.makeOpenPath(io, "root_dir/parent_dir/some_dir", .{});871 var dir = try tmp_dir.dir.createDirPathOpen(io, "root_dir/parent_dir/some_dir", .{});
872 dir.close(io);872 dir.close(io);
873873
874 // double check that the full directory structure was created874 // double check that the full directory structure was created
...@@ -1016,7 +1016,7 @@ test "Dir.rename directory onto non-empty dir" {...@@ -1016,7 +1016,7 @@ test "Dir.rename directory onto non-empty dir" {
10161016
1017 try ctx.dir.createDir(io, test_dir_path, .default_dir);1017 try ctx.dir.createDir(io, test_dir_path, .default_dir);
10181018
1019 var target_dir = try ctx.dir.makeOpenPath(io, target_dir_path, .{});1019 var target_dir = try ctx.dir.createDirPathOpen(io, target_dir_path, .{});
1020 var file = try target_dir.createFile(io, "test_file", .{ .read = true });1020 var file = try target_dir.createFile(io, "test_file", .{ .read = true });
1021 file.close(io);1021 file.close(io);
1022 target_dir.close(io);1022 target_dir.close(io);
...@@ -1155,9 +1155,9 @@ test "deleteTree does not follow symlinks" {...@@ -1155,9 +1155,9 @@ test "deleteTree does not follow symlinks" {
1155 var tmp = tmpDir(.{});1155 var tmp = tmpDir(.{});
1156 defer tmp.cleanup();1156 defer tmp.cleanup();
11571157
1158 try tmp.dir.makePath(io, "b");1158 try tmp.dir.createDirPath(io, "b");
1159 {1159 {
1160 var a = try tmp.dir.makeOpenPath(io, "a", .{});1160 var a = try tmp.dir.createDirPathOpen(io, "a", .{});
1161 defer a.close(io);1161 defer a.close(io);
11621162
1163 try setupSymlink(io, a, "../b", "b", .{ .is_directory = true });1163 try setupSymlink(io, a, "../b", "b", .{ .is_directory = true });
...@@ -1184,7 +1184,7 @@ test "deleteTree on a symlink" {...@@ -1184,7 +1184,7 @@ test "deleteTree on a symlink" {
1184 try tmp.dir.access(io, "file", .{});1184 try tmp.dir.access(io, "file", .{});
11851185
1186 // Symlink to a directory1186 // Symlink to a directory
1187 try tmp.dir.makePath(io, "dir");1187 try tmp.dir.createDirPath(io, "dir");
1188 try setupSymlink(io, tmp.dir, "dir", "dirlink", .{ .is_directory = true });1188 try setupSymlink(io, tmp.dir, "dir", "dirlink", .{ .is_directory = true });
11891189
1190 try tmp.dir.deleteTree(io, "dirlink");1190 try tmp.dir.deleteTree(io, "dirlink");
...@@ -1192,14 +1192,14 @@ test "deleteTree on a symlink" {...@@ -1192,14 +1192,14 @@ test "deleteTree on a symlink" {
1192 try tmp.dir.access(io, "dir", .{});1192 try tmp.dir.access(io, "dir", .{});
1193}1193}
11941194
1195test "makePath, put some files in it, deleteTree" {1195test "createDirPath, put some files in it, deleteTree" {
1196 try testWithAllSupportedPathTypes(struct {1196 try testWithAllSupportedPathTypes(struct {
1197 fn impl(ctx: *TestContext) !void {1197 fn impl(ctx: *TestContext) !void {
1198 const io = ctx.io;1198 const io = ctx.io;
1199 const allocator = ctx.arena.allocator();1199 const allocator = ctx.arena.allocator();
1200 const dir_path = try ctx.transformPath("os_test_tmp");1200 const dir_path = try ctx.transformPath("os_test_tmp");
12011201
1202 try ctx.dir.makePath(io, try Dir.path.join(allocator, &.{ "os_test_tmp", "b", "c" }));1202 try ctx.dir.createDirPath(io, try Dir.path.join(allocator, &.{ "os_test_tmp", "b", "c" }));
1203 try ctx.dir.writeFile(io, .{1203 try ctx.dir.writeFile(io, .{
1204 .sub_path = try Dir.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }),1204 .sub_path = try Dir.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }),
1205 .data = "nonsense",1205 .data = "nonsense",
...@@ -1215,14 +1215,14 @@ test "makePath, put some files in it, deleteTree" {...@@ -1215,14 +1215,14 @@ test "makePath, put some files in it, deleteTree" {
1215 }.impl);1215 }.impl);
1216}1216}
12171217
1218test "makePath, put some files in it, deleteTreeMinStackSize" {1218test "createDirPath, put some files in it, deleteTreeMinStackSize" {
1219 try testWithAllSupportedPathTypes(struct {1219 try testWithAllSupportedPathTypes(struct {
1220 fn impl(ctx: *TestContext) !void {1220 fn impl(ctx: *TestContext) !void {
1221 const io = ctx.io;1221 const io = ctx.io;
1222 const allocator = ctx.arena.allocator();1222 const allocator = ctx.arena.allocator();
1223 const dir_path = try ctx.transformPath("os_test_tmp");1223 const dir_path = try ctx.transformPath("os_test_tmp");
12241224
1225 try ctx.dir.makePath(io, try Dir.path.join(allocator, &.{ "os_test_tmp", "b", "c" }));1225 try ctx.dir.createDirPath(io, try Dir.path.join(allocator, &.{ "os_test_tmp", "b", "c" }));
1226 try ctx.dir.writeFile(io, .{1226 try ctx.dir.writeFile(io, .{
1227 .sub_path = try Dir.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }),1227 .sub_path = try Dir.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }),
1228 .data = "nonsense",1228 .data = "nonsense",
...@@ -1238,7 +1238,7 @@ test "makePath, put some files in it, deleteTreeMinStackSize" {...@@ -1238,7 +1238,7 @@ test "makePath, put some files in it, deleteTreeMinStackSize" {
1238 }.impl);1238 }.impl);
1239}1239}
12401240
1241test "makePath in a directory that no longer exists" {1241test "createDirPath in a directory that no longer exists" {
1242 if (native_os == .windows) return error.SkipZigTest; // Windows returns FileBusy if attempting to remove an open dir1242 if (native_os == .windows) return error.SkipZigTest; // Windows returns FileBusy if attempting to remove an open dir
12431243
1244 const io = testing.io;1244 const io = testing.io;
...@@ -1247,10 +1247,10 @@ test "makePath in a directory that no longer exists" {...@@ -1247,10 +1247,10 @@ test "makePath in a directory that no longer exists" {
1247 defer tmp.cleanup();1247 defer tmp.cleanup();
1248 try tmp.parent_dir.deleteTree(io, &tmp.sub_path);1248 try tmp.parent_dir.deleteTree(io, &tmp.sub_path);
12491249
1250 try expectError(error.FileNotFound, tmp.dir.makePath(io, "sub-path"));1250 try expectError(error.FileNotFound, tmp.dir.createDirPath(io, "sub-path"));
1251}1251}
12521252
1253test "makePath but sub_path contains pre-existing file" {1253test "createDirPath but sub_path contains pre-existing file" {
1254 const io = testing.io;1254 const io = testing.io;
12551255
1256 var tmp = tmpDir(.{});1256 var tmp = tmpDir(.{});
...@@ -1259,7 +1259,7 @@ test "makePath but sub_path contains pre-existing file" {...@@ -1259,7 +1259,7 @@ test "makePath but sub_path contains pre-existing file" {
1259 try tmp.dir.createDir(io, "foo", .default_dir);1259 try tmp.dir.createDir(io, "foo", .default_dir);
1260 try tmp.dir.writeFile(io, .{ .sub_path = "foo/bar", .data = "" });1260 try tmp.dir.writeFile(io, .{ .sub_path = "foo/bar", .data = "" });
12611261
1262 try expectError(error.NotDir, tmp.dir.makePath(io, "foo/bar/baz"));1262 try expectError(error.NotDir, tmp.dir.createDirPath(io, "foo/bar/baz"));
1263}1263}
12641264
1265fn expectDir(io: Io, dir: Dir, path: []const u8) !void {1265fn expectDir(io: Io, dir: Dir, path: []const u8) !void {
...@@ -1279,7 +1279,7 @@ test "makepath existing directories" {...@@ -1279,7 +1279,7 @@ test "makepath existing directories" {
1279 try tmpA.createDir(io, "B", .default_dir);1279 try tmpA.createDir(io, "B", .default_dir);
12801280
1281 const testPath = "A" ++ Dir.path.sep_str ++ "B" ++ Dir.path.sep_str ++ "C";1281 const testPath = "A" ++ Dir.path.sep_str ++ "B" ++ Dir.path.sep_str ++ "C";
1282 try tmp.dir.makePath(io, testPath);1282 try tmp.dir.createDirPath(io, testPath);
12831283
1284 try expectDir(io, tmp.dir, testPath);1284 try expectDir(io, tmp.dir, testPath);
1285}1285}
...@@ -1293,7 +1293,7 @@ test "makepath through existing valid symlink" {...@@ -1293,7 +1293,7 @@ test "makepath through existing valid symlink" {
1293 try tmp.dir.createDir(io, "realfolder", .default_dir);1293 try tmp.dir.createDir(io, "realfolder", .default_dir);
1294 try setupSymlink(io, tmp.dir, "." ++ Dir.path.sep_str ++ "realfolder", "working-symlink", .{});1294 try setupSymlink(io, tmp.dir, "." ++ Dir.path.sep_str ++ "realfolder", "working-symlink", .{});
12951295
1296 try tmp.dir.makePath(io, "working-symlink" ++ Dir.path.sep_str ++ "in-realfolder");1296 try tmp.dir.createDirPath(io, "working-symlink" ++ Dir.path.sep_str ++ "in-realfolder");
12971297
1298 try expectDir(io, tmp.dir, "realfolder" ++ Dir.path.sep_str ++ "in-realfolder");1298 try expectDir(io, tmp.dir, "realfolder" ++ Dir.path.sep_str ++ "in-realfolder");
1299}1299}
...@@ -1309,7 +1309,7 @@ test "makepath relative walks" {...@@ -1309,7 +1309,7 @@ test "makepath relative walks" {
1309 });1309 });
1310 defer testing.allocator.free(relPath);1310 defer testing.allocator.free(relPath);
13111311
1312 try tmp.dir.makePath(io, relPath);1312 try tmp.dir.createDirPath(io, relPath);
13131313
1314 // How .. is handled is different on Windows than non-Windows1314 // How .. is handled is different on Windows than non-Windows
1315 switch (native_os) {1315 switch (native_os) {
...@@ -1348,7 +1348,7 @@ test "makepath ignores '.'" {...@@ -1348,7 +1348,7 @@ test "makepath ignores '.'" {
1348 });1348 });
1349 defer testing.allocator.free(expectedPath);1349 defer testing.allocator.free(expectedPath);
13501350
1351 try tmp.dir.makePath(io, dotPath);1351 try tmp.dir.createDirPath(io, dotPath);
13521352
1353 try expectDir(io, tmp.dir, expectedPath);1353 try expectDir(io, tmp.dir, expectedPath);
1354}1354}
...@@ -1358,7 +1358,7 @@ fn testFilenameLimits(io: Io, iterable_dir: Dir, maxed_filename: []const u8, max...@@ -1358,7 +1358,7 @@ fn testFilenameLimits(io: Io, iterable_dir: Dir, maxed_filename: []const u8, max
1358 {1358 {
1359 try iterable_dir.writeFile(io, .{ .sub_path = maxed_filename, .data = "" });1359 try iterable_dir.writeFile(io, .{ .sub_path = maxed_filename, .data = "" });
13601360
1361 var maxed_dir = try iterable_dir.makeOpenPath(io, maxed_dirname, .{});1361 var maxed_dir = try iterable_dir.createDirPathOpen(io, maxed_dirname, .{});
1362 defer maxed_dir.close(io);1362 defer maxed_dir.close(io);
13631363
1364 try maxed_dir.writeFile(io, .{ .sub_path = maxed_filename, .data = "" });1364 try maxed_dir.writeFile(io, .{ .sub_path = maxed_filename, .data = "" });
...@@ -1511,7 +1511,7 @@ test "access file" {...@@ -1511,7 +1511,7 @@ test "access file" {
1511 const dir_path = try ctx.transformPath("os_test_tmp");1511 const dir_path = try ctx.transformPath("os_test_tmp");
1512 const file_path = try ctx.transformPath("os_test_tmp" ++ Dir.path.sep_str ++ "file.txt");1512 const file_path = try ctx.transformPath("os_test_tmp" ++ Dir.path.sep_str ++ "file.txt");
15131513
1514 try ctx.dir.makePath(io, dir_path);1514 try ctx.dir.createDirPath(io, dir_path);
1515 try expectError(error.FileNotFound, ctx.dir.access(io, file_path, .{}));1515 try expectError(error.FileNotFound, ctx.dir.access(io, file_path, .{}));
15161516
1517 try ctx.dir.writeFile(io, .{ .sub_path = file_path, .data = "" });1517 try ctx.dir.writeFile(io, .{ .sub_path = file_path, .data = "" });
...@@ -1527,7 +1527,7 @@ test "sendfile" {...@@ -1527,7 +1527,7 @@ test "sendfile" {
1527 var tmp = tmpDir(.{});1527 var tmp = tmpDir(.{});
1528 defer tmp.cleanup();1528 defer tmp.cleanup();
15291529
1530 try tmp.dir.makePath(io, "os_test_tmp");1530 try tmp.dir.createDirPath(io, "os_test_tmp");
15311531
1532 var dir = try tmp.dir.openDir(io, "os_test_tmp", .{});1532 var dir = try tmp.dir.openDir(io, "os_test_tmp", .{});
1533 defer dir.close(io);1533 defer dir.close(io);
...@@ -1574,7 +1574,7 @@ test "sendfile with buffered data" {...@@ -1574,7 +1574,7 @@ test "sendfile with buffered data" {
1574 var tmp = tmpDir(.{});1574 var tmp = tmpDir(.{});
1575 defer tmp.cleanup();1575 defer tmp.cleanup();
15761576
1577 try tmp.dir.makePath(io, "os_test_tmp");1577 try tmp.dir.createDirPath(io, "os_test_tmp");
15781578
1579 var dir = try tmp.dir.openDir(io, "os_test_tmp", .{});1579 var dir = try tmp.dir.openDir(io, "os_test_tmp", .{});
1580 defer dir.close(io);1580 defer dir.close(io);
...@@ -1851,7 +1851,7 @@ test "walker" {...@@ -1851,7 +1851,7 @@ test "walker" {
1851 });1851 });
18521852
1853 for (expected_paths.keys()) |key| {1853 for (expected_paths.keys()) |key| {
1854 try tmp.dir.makePath(io, key);1854 try tmp.dir.createDirPath(io, key);
1855 }1855 }
18561856
1857 var walker = try tmp.dir.walk(testing.allocator);1857 var walker = try tmp.dir.walk(testing.allocator);
...@@ -1913,7 +1913,7 @@ test "selective walker, skip entries that start with ." {...@@ -1913,7 +1913,7 @@ test "selective walker, skip entries that start with ." {
1913 });1913 });
19141914
1915 for (paths_to_create) |path| {1915 for (paths_to_create) |path| {
1916 try tmp.dir.makePath(io, path);1916 try tmp.dir.createDirPath(io, path);
1917 }1917 }
19181918
1919 var walker = try tmp.dir.walkSelectively(testing.allocator);1919 var walker = try tmp.dir.walkSelectively(testing.allocator);
...@@ -1959,8 +1959,8 @@ test "walker without fully iterating" {...@@ -1959,8 +1959,8 @@ test "walker without fully iterating" {
1959 // Create 2 directories inside the tmp directory, but then only iterate once before breaking.1959 // Create 2 directories inside the tmp directory, but then only iterate once before breaking.
1960 // This ensures that walker doesn't try to close the initial directory when not fully iterating.1960 // This ensures that walker doesn't try to close the initial directory when not fully iterating.
19611961
1962 try tmp.dir.makePath(io, "a");1962 try tmp.dir.createDirPath(io, "a");
1963 try tmp.dir.makePath(io, "b");1963 try tmp.dir.createDirPath(io, "b");
19641964
1965 var num_walked: usize = 0;1965 var num_walked: usize = 0;
1966 while (try walker.next(io)) |_| {1966 while (try walker.next(io)) |_| {
...@@ -2109,8 +2109,8 @@ test "invalid UTF-8/WTF-8 paths" {...@@ -2109,8 +2109,8 @@ test "invalid UTF-8/WTF-8 paths" {
21092109
2110 try expectError(expected_err, ctx.dir.createDir(io, invalid_path, .default_dir));2110 try expectError(expected_err, ctx.dir.createDir(io, invalid_path, .default_dir));
21112111
2112 try expectError(expected_err, ctx.dir.makePath(io, invalid_path));2112 try expectError(expected_err, ctx.dir.createDirPath(io, invalid_path));
2113 try expectError(expected_err, ctx.dir.makeOpenPath(io, invalid_path, .{}));2113 try expectError(expected_err, ctx.dir.createDirPathOpen(io, invalid_path, .{}));
21142114
2115 try expectError(expected_err, ctx.dir.openDir(io, invalid_path, .{}));2115 try expectError(expected_err, ctx.dir.openDir(io, invalid_path, .{}));
21162116
...@@ -2574,7 +2574,7 @@ test "hard link with different directories" {...@@ -2574,7 +2574,7 @@ test "hard link with different directories" {
2574 const target_name = "link-target";2574 const target_name = "link-target";
2575 const link_name = "newlink";2575 const link_name = "newlink";
25762576
2577 const subdir = try tmp.dir.makeOpenPath(io, "subdir", .{});2577 const subdir = try tmp.dir.createDirPathOpen(io, "subdir", .{});
25782578
2579 defer tmp.dir.deleteFile(io, target_name) catch {};2579 defer tmp.dir.deleteFile(io, target_name) catch {};
2580 try tmp.dir.writeFile(io, .{ .sub_path = target_name, .data = "example" });2580 try tmp.dir.writeFile(io, .{ .sub_path = target_name, .data = "example" });
lib/std/posix.zig+1-1
...@@ -1079,7 +1079,7 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: mode_t) MakeDir...@@ -1079,7 +1079,7 @@ pub fn mkdiratZ(dir_fd: fd_t, sub_dir_path: [*:0]const u8, mode: mode_t) MakeDir
1079 }1079 }
1080}1080}
10811081
1082pub const MakeDirError = std.Io.Dir.MakeError;1082pub const MakeDirError = std.Io.Dir.CreateDirError;
10831083
1084/// Create a directory.1084/// Create a directory.
1085/// `mode` is ignored on Windows and WASI.1085/// `mode` is ignored on Windows and WASI.
lib/std/tar.zig+3-3
...@@ -606,7 +606,7 @@ pub fn pipeToFileSystem(io: Io, dir: Io.Dir, reader: *Io.Reader, options: PipeOp...@@ -606,7 +606,7 @@ pub fn pipeToFileSystem(io: Io, dir: Io.Dir, reader: *Io.Reader, options: PipeOp
606 switch (file.kind) {606 switch (file.kind) {
607 .directory => {607 .directory => {
608 if (file_name.len > 0 and !options.exclude_empty_directories) {608 if (file_name.len > 0 and !options.exclude_empty_directories) {
609 try dir.makePath(io, file_name);609 try dir.createDirPath(io, file_name);
610 }610 }
611 },611 },
612 .file => {612 .file => {
...@@ -642,7 +642,7 @@ fn createDirAndFile(io: Io, dir: Io.Dir, file_name: []const u8, permissions: Io....@@ -642,7 +642,7 @@ fn createDirAndFile(io: Io, dir: Io.Dir, file_name: []const u8, permissions: Io.
642 const fs_file = dir.createFile(io, file_name, .{ .exclusive = true, .permissions = permissions }) catch |err| {642 const fs_file = dir.createFile(io, file_name, .{ .exclusive = true, .permissions = permissions }) catch |err| {
643 if (err == error.FileNotFound) {643 if (err == error.FileNotFound) {
644 if (std.fs.path.dirname(file_name)) |dir_name| {644 if (std.fs.path.dirname(file_name)) |dir_name| {
645 try dir.makePath(io, dir_name);645 try dir.createDirPath(io, dir_name);
646 return try dir.createFile(io, file_name, .{ .exclusive = true, .permissions = permissions });646 return try dir.createFile(io, file_name, .{ .exclusive = true, .permissions = permissions });
647 }647 }
648 }648 }
...@@ -656,7 +656,7 @@ fn createDirAndSymlink(io: Io, dir: Io.Dir, link_name: []const u8, file_name: []...@@ -656,7 +656,7 @@ fn createDirAndSymlink(io: Io, dir: Io.Dir, link_name: []const u8, file_name: []
656 dir.symLink(io, link_name, file_name, .{}) catch |err| {656 dir.symLink(io, link_name, file_name, .{}) catch |err| {
657 if (err == error.FileNotFound) {657 if (err == error.FileNotFound) {
658 if (std.fs.path.dirname(file_name)) |dir_name| {658 if (std.fs.path.dirname(file_name)) |dir_name| {
659 try dir.makePath(io, dir_name);659 try dir.createDirPath(io, dir_name);
660 return try dir.symLink(io, link_name, file_name, .{});660 return try dir.symLink(io, link_name, file_name, .{});
661 }661 }
662 }662 }
lib/std/testing.zig+3-3
...@@ -635,12 +635,12 @@ pub fn tmpDir(opts: Io.Dir.OpenOptions) TmpDir {...@@ -635,12 +635,12 @@ pub fn tmpDir(opts: Io.Dir.OpenOptions) TmpDir {
635 _ = std.fs.base64_encoder.encode(&sub_path, &random_bytes);635 _ = std.fs.base64_encoder.encode(&sub_path, &random_bytes);
636636
637 const cwd = Io.Dir.cwd();637 const cwd = Io.Dir.cwd();
638 var cache_dir = cwd.makeOpenPath(io, ".zig-cache", .{}) catch638 var cache_dir = cwd.createDirPathOpen(io, ".zig-cache", .{}) catch
639 @panic("unable to make tmp dir for testing: unable to make and open .zig-cache dir");639 @panic("unable to make tmp dir for testing: unable to make and open .zig-cache dir");
640 defer cache_dir.close(io);640 defer cache_dir.close(io);
641 const parent_dir = cache_dir.makeOpenPath(io, "tmp", .{}) catch641 const parent_dir = cache_dir.createDirPathOpen(io, "tmp", .{}) catch
642 @panic("unable to make tmp dir for testing: unable to make and open .zig-cache/tmp dir");642 @panic("unable to make tmp dir for testing: unable to make and open .zig-cache/tmp dir");
643 const dir = parent_dir.makeOpenPath(io, &sub_path, .{ .open_options = opts }) catch643 const dir = parent_dir.createDirPathOpen(io, &sub_path, .{ .open_options = opts }) catch
644 @panic("unable to make tmp dir for testing: unable to make and open the tmp dir");644 @panic("unable to make tmp dir for testing: unable to make and open the tmp dir");
645645
646 return .{646 return .{
lib/std/zip.zig+2-2
...@@ -554,13 +554,13 @@ pub const Iterator = struct {...@@ -554,13 +554,13 @@ pub const Iterator = struct {
554 if (filename[filename.len - 1] == '/') {554 if (filename[filename.len - 1] == '/') {
555 if (self.uncompressed_size != 0)555 if (self.uncompressed_size != 0)
556 return error.ZipBadDirectorySize;556 return error.ZipBadDirectorySize;
557 try dest.makePath(io, filename[0 .. filename.len - 1]);557 try dest.createDirPath(io, filename[0 .. filename.len - 1]);
558 return;558 return;
559 }559 }
560560
561 const out_file = blk: {561 const out_file = blk: {
562 if (std.fs.path.dirname(filename)) |dirname| {562 if (std.fs.path.dirname(filename)) |dirname| {
563 var parent_dir = try dest.makeOpenPath(io, dirname, .{});563 var parent_dir = try dest.createDirPathOpen(io, dirname, .{});
564 defer parent_dir.close(io);564 defer parent_dir.close(io);
565565
566 const basename = std.fs.path.basename(filename);566 const basename = std.fs.path.basename(filename);
src/Compilation.zig+17-17
...@@ -832,7 +832,7 @@ pub const Directories = struct {...@@ -832,7 +832,7 @@ pub const Directories = struct {
832 const nonempty_path = if (path.len == 0) "." else path;832 const nonempty_path = if (path.len == 0) "." else path;
833 const handle_or_err = switch (thing) {833 const handle_or_err = switch (thing) {
834 .@"zig lib" => Io.Dir.cwd().openDir(io, nonempty_path, .{}),834 .@"zig lib" => Io.Dir.cwd().openDir(io, nonempty_path, .{}),
835 .@"global cache", .@"local cache" => Io.Dir.cwd().makeOpenPath(io, nonempty_path, .{}),835 .@"global cache", .@"local cache" => Io.Dir.cwd().createDirPathOpen(io, nonempty_path, .{}),
836 };836 };
837 return .{837 return .{
838 .path = if (path.len == 0) null else path,838 .path = if (path.len == 0) null else path,
...@@ -1879,7 +1879,7 @@ pub const CreateDiagnostic = union(enum) {...@@ -1879,7 +1879,7 @@ pub const CreateDiagnostic = union(enum) {
1879 pub const CreateCachePath = struct {1879 pub const CreateCachePath = struct {
1880 which: enum { local, global },1880 which: enum { local, global },
1881 sub: []const u8,1881 sub: []const u8,
1882 err: (Io.Dir.MakeError || Io.Dir.OpenError || Io.Dir.StatFileError),1882 err: (Io.Dir.CreateDirError || Io.Dir.OpenError || Io.Dir.StatFileError),
1883 };1883 };
1884 pub fn format(diag: CreateDiagnostic, w: *Writer) Writer.Error!void {1884 pub fn format(diag: CreateDiagnostic, w: *Writer) Writer.Error!void {
1885 switch (diag) {1885 switch (diag) {
...@@ -2120,7 +2120,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,...@@ -2120,7 +2120,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
2120 cache.* = .{2120 cache.* = .{
2121 .gpa = gpa,2121 .gpa = gpa,
2122 .io = io,2122 .io = io,
2123 .manifest_dir = options.dirs.local_cache.handle.makeOpenPath(io, "h", .{}) catch |err| {2123 .manifest_dir = options.dirs.local_cache.handle.createDirPathOpen(io, "h", .{}) catch |err| {
2124 return diag.fail(.{ .create_cache_path = .{ .which = .local, .sub = "h", .err = err } });2124 return diag.fail(.{ .create_cache_path = .{ .which = .local, .sub = "h", .err = err } });
2125 },2125 },
2126 };2126 };
...@@ -2170,7 +2170,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,...@@ -2170,7 +2170,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
2170 // to redundantly happen for each AstGen operation.2170 // to redundantly happen for each AstGen operation.
2171 const zir_sub_dir = "z";2171 const zir_sub_dir = "z";
21722172
2173 var local_zir_dir = options.dirs.local_cache.handle.makeOpenPath(io, zir_sub_dir, .{}) catch |err| {2173 var local_zir_dir = options.dirs.local_cache.handle.createDirPathOpen(io, zir_sub_dir, .{}) catch |err| {
2174 return diag.fail(.{ .create_cache_path = .{ .which = .local, .sub = zir_sub_dir, .err = err } });2174 return diag.fail(.{ .create_cache_path = .{ .which = .local, .sub = zir_sub_dir, .err = err } });
2175 };2175 };
2176 errdefer local_zir_dir.close(io);2176 errdefer local_zir_dir.close(io);
...@@ -2178,7 +2178,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,...@@ -2178,7 +2178,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
2178 .handle = local_zir_dir,2178 .handle = local_zir_dir,
2179 .path = try options.dirs.local_cache.join(arena, &.{zir_sub_dir}),2179 .path = try options.dirs.local_cache.join(arena, &.{zir_sub_dir}),
2180 };2180 };
2181 var global_zir_dir = options.dirs.global_cache.handle.makeOpenPath(io, zir_sub_dir, .{}) catch |err| {2181 var global_zir_dir = options.dirs.global_cache.handle.createDirPathOpen(io, zir_sub_dir, .{}) catch |err| {
2182 return diag.fail(.{ .create_cache_path = .{ .which = .global, .sub = zir_sub_dir, .err = err } });2182 return diag.fail(.{ .create_cache_path = .{ .which = .global, .sub = zir_sub_dir, .err = err } });
2183 };2183 };
2184 errdefer global_zir_dir.close(io);2184 errdefer global_zir_dir.close(io);
...@@ -2449,7 +2449,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,...@@ -2449,7 +2449,7 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
2449 const digest = hash.final();2449 const digest = hash.final();
24502450
2451 const artifact_sub_dir = "o" ++ fs.path.sep_str ++ digest;2451 const artifact_sub_dir = "o" ++ fs.path.sep_str ++ digest;
2452 var artifact_dir = options.dirs.local_cache.handle.makeOpenPath(io, artifact_sub_dir, .{}) catch |err| {2452 var artifact_dir = options.dirs.local_cache.handle.createDirPathOpen(io, artifact_sub_dir, .{}) catch |err| {
2453 return diag.fail(.{ .create_cache_path = .{ .which = .local, .sub = artifact_sub_dir, .err = err } });2453 return diag.fail(.{ .create_cache_path = .{ .which = .local, .sub = artifact_sub_dir, .err = err } });
2454 };2454 };
2455 errdefer artifact_dir.close(io);2455 errdefer artifact_dir.close(io);
...@@ -2917,7 +2917,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE...@@ -2917,7 +2917,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
2917 tmp_dir_rand_int = std.crypto.random.int(u64);2917 tmp_dir_rand_int = std.crypto.random.int(u64);
2918 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);2918 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);
2919 const path = try comp.dirs.local_cache.join(arena, &.{tmp_dir_sub_path});2919 const path = try comp.dirs.local_cache.join(arena, &.{tmp_dir_sub_path});
2920 const handle = comp.dirs.local_cache.handle.makeOpenPath(io, tmp_dir_sub_path, .{}) catch |err| {2920 const handle = comp.dirs.local_cache.handle.createDirPathOpen(io, tmp_dir_sub_path, .{}) catch |err| {
2921 return comp.setMiscFailure(.open_output, "failed to create output directory '{s}': {t}", .{ path, err });2921 return comp.setMiscFailure(.open_output, "failed to create output directory '{s}': {t}", .{ path, err });
2922 };2922 };
2923 break :d .{ .path = path, .handle = handle };2923 break :d .{ .path = path, .handle = handle };
...@@ -2998,7 +2998,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE...@@ -2998,7 +2998,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) UpdateE
2998 tmp_dir_rand_int = std.crypto.random.int(u64);2998 tmp_dir_rand_int = std.crypto.random.int(u64);
2999 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);2999 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(tmp_dir_rand_int);
3000 const path = try comp.dirs.local_cache.join(arena, &.{tmp_dir_sub_path});3000 const path = try comp.dirs.local_cache.join(arena, &.{tmp_dir_sub_path});
3001 const handle = comp.dirs.local_cache.handle.makeOpenPath(io, tmp_dir_sub_path, .{}) catch |err| {3001 const handle = comp.dirs.local_cache.handle.createDirPathOpen(io, tmp_dir_sub_path, .{}) catch |err| {
3002 return comp.setMiscFailure(.open_output, "failed to create output directory '{s}': {t}", .{ path, err });3002 return comp.setMiscFailure(.open_output, "failed to create output directory '{s}': {t}", .{ path, err });
3003 };3003 };
3004 break :d .{ .path = path, .handle = handle };3004 break :d .{ .path = path, .handle = handle };
...@@ -3437,7 +3437,7 @@ fn renameTmpIntoCache(...@@ -3437,7 +3437,7 @@ fn renameTmpIntoCache(
3437 continue;3437 continue;
3438 },3438 },
3439 error.FileNotFound => {3439 error.FileNotFound => {
3440 try cache_directory.handle.makePath(io, "o");3440 try cache_directory.handle.createDirPath(io, "o");
3441 continue;3441 continue;
3442 },3442 },
3443 else => |e| return e,3443 else => |e| return e,
...@@ -5276,7 +5276,7 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void {...@@ -5276,7 +5276,7 @@ fn docsCopyFallible(comp: *Compilation) anyerror!void {
5276 const io = comp.io;5276 const io = comp.io;
52775277
5278 const docs_path = comp.resolveEmitPath(comp.emit_docs.?);5278 const docs_path = comp.resolveEmitPath(comp.emit_docs.?);
5279 var out_dir = docs_path.root_dir.handle.makeOpenPath(io, docs_path.sub_path, .{}) catch |err| {5279 var out_dir = docs_path.root_dir.handle.createDirPathOpen(io, docs_path.sub_path, .{}) catch |err| {
5280 return comp.lockAndSetMiscFailure(5280 return comp.lockAndSetMiscFailure(
5281 .docs_copy,5281 .docs_copy,
5282 "unable to create output directory '{f}': {s}",5282 "unable to create output directory '{f}': {s}",
...@@ -5513,7 +5513,7 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) SubU...@@ -5513,7 +5513,7 @@ fn workerDocsWasmFallible(comp: *Compilation, prog_node: std.Progress.Node) SubU
5513 assert(docs_bin_file.sub_path.len > 0); // emitted binary is not a directory5513 assert(docs_bin_file.sub_path.len > 0); // emitted binary is not a directory
55145514
5515 const docs_path = comp.resolveEmitPath(comp.emit_docs.?);5515 const docs_path = comp.resolveEmitPath(comp.emit_docs.?);
5516 var out_dir = docs_path.root_dir.handle.makeOpenPath(io, docs_path.sub_path, .{}) catch |err| {5516 var out_dir = docs_path.root_dir.handle.createDirPathOpen(io, docs_path.sub_path, .{}) catch |err| {
5517 comp.lockAndSetMiscFailure(5517 comp.lockAndSetMiscFailure(
5518 .docs_copy,5518 .docs_copy,
5519 "unable to create output directory '{f}': {t}",5519 "unable to create output directory '{f}': {t}",
...@@ -5705,7 +5705,7 @@ pub fn translateC(...@@ -5705,7 +5705,7 @@ pub fn translateC(
5705 const tmp_basename = std.fmt.hex(std.crypto.random.int(u64));5705 const tmp_basename = std.fmt.hex(std.crypto.random.int(u64));
5706 const tmp_sub_path = "tmp" ++ fs.path.sep_str ++ tmp_basename;5706 const tmp_sub_path = "tmp" ++ fs.path.sep_str ++ tmp_basename;
5707 const cache_dir = comp.dirs.local_cache.handle;5707 const cache_dir = comp.dirs.local_cache.handle;
5708 var cache_tmp_dir = try cache_dir.makeOpenPath(io, tmp_sub_path, .{});5708 var cache_tmp_dir = try cache_dir.createDirPathOpen(io, tmp_sub_path, .{});
5709 defer cache_tmp_dir.close(io);5709 defer cache_tmp_dir.close(io);
57105710
5711 const translated_path = try comp.dirs.local_cache.join(arena, &.{ tmp_sub_path, translated_basename });5711 const translated_path = try comp.dirs.local_cache.join(arena, &.{ tmp_sub_path, translated_basename });
...@@ -6280,7 +6280,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr...@@ -6280,7 +6280,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr
6280 // We can't know the digest until we do the C compiler invocation,6280 // We can't know the digest until we do the C compiler invocation,
6281 // so we need a temporary filename.6281 // so we need a temporary filename.
6282 const out_obj_path = try comp.tmpFilePath(arena, o_basename);6282 const out_obj_path = try comp.tmpFilePath(arena, o_basename);
6283 var zig_cache_tmp_dir = try comp.dirs.local_cache.handle.makeOpenPath(io, "tmp", .{});6283 var zig_cache_tmp_dir = try comp.dirs.local_cache.handle.createDirPathOpen(io, "tmp", .{});
6284 defer zig_cache_tmp_dir.close(io);6284 defer zig_cache_tmp_dir.close(io);
62856285
6286 const out_diag_path = if (comp.clang_passthrough_mode or !ext.clangSupportsDiagnostics())6286 const out_diag_path = if (comp.clang_passthrough_mode or !ext.clangSupportsDiagnostics())
...@@ -6445,7 +6445,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr...@@ -6445,7 +6445,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr
6445 // Rename into place.6445 // Rename into place.
6446 const digest = man.final();6446 const digest = man.final();
6447 const o_sub_path = try fs.path.join(arena, &[_][]const u8{ "o", &digest });6447 const o_sub_path = try fs.path.join(arena, &[_][]const u8{ "o", &digest });
6448 var o_dir = try comp.dirs.local_cache.handle.makeOpenPath(io, o_sub_path, .{});6448 var o_dir = try comp.dirs.local_cache.handle.createDirPathOpen(io, o_sub_path, .{});
6449 defer o_dir.close(io);6449 defer o_dir.close(io);
6450 const tmp_basename = fs.path.basename(out_obj_path);6450 const tmp_basename = fs.path.basename(out_obj_path);
6451 try Io.Dir.rename(zig_cache_tmp_dir, tmp_basename, o_dir, o_basename, io);6451 try Io.Dir.rename(zig_cache_tmp_dir, tmp_basename, o_dir, o_basename, io);
...@@ -6534,7 +6534,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -6534,7 +6534,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
6534 const digest = man.final();6534 const digest = man.final();
65356535
6536 const o_sub_path = try fs.path.join(arena, &.{ "o", &digest });6536 const o_sub_path = try fs.path.join(arena, &.{ "o", &digest });
6537 var o_dir = try comp.dirs.local_cache.handle.makeOpenPath(io, o_sub_path, .{});6537 var o_dir = try comp.dirs.local_cache.handle.createDirPathOpen(io, o_sub_path, .{});
6538 defer o_dir.close(io);6538 defer o_dir.close(io);
65396539
6540 const in_rc_path = try comp.dirs.local_cache.join(comp.gpa, &.{6540 const in_rc_path = try comp.dirs.local_cache.join(comp.gpa, &.{
...@@ -6622,7 +6622,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -6622,7 +6622,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
6622 const rc_basename_noext = src_basename[0 .. src_basename.len - fs.path.extension(src_basename).len];6622 const rc_basename_noext = src_basename[0 .. src_basename.len - fs.path.extension(src_basename).len];
66236623
6624 const digest = if (try man.hit()) man.final() else blk: {6624 const digest = if (try man.hit()) man.final() else blk: {
6625 var zig_cache_tmp_dir = try comp.dirs.local_cache.handle.makeOpenPath(io, "tmp", .{});6625 var zig_cache_tmp_dir = try comp.dirs.local_cache.handle.createDirPathOpen(io, "tmp", .{});
6626 defer zig_cache_tmp_dir.close(io);6626 defer zig_cache_tmp_dir.close(io);
66276627
6628 const res_filename = try std.fmt.allocPrint(arena, "{s}.res", .{rc_basename_noext});6628 const res_filename = try std.fmt.allocPrint(arena, "{s}.res", .{rc_basename_noext});
...@@ -6693,7 +6693,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -6693,7 +6693,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
6693 // Rename into place.6693 // Rename into place.
6694 const digest = man.final();6694 const digest = man.final();
6695 const o_sub_path = try fs.path.join(arena, &[_][]const u8{ "o", &digest });6695 const o_sub_path = try fs.path.join(arena, &[_][]const u8{ "o", &digest });
6696 var o_dir = try comp.dirs.local_cache.handle.makeOpenPath(io, o_sub_path, .{});6696 var o_dir = try comp.dirs.local_cache.handle.createDirPathOpen(io, o_sub_path, .{});
6697 defer o_dir.close(io);6697 defer o_dir.close(io);
6698 const tmp_basename = fs.path.basename(out_res_path);6698 const tmp_basename = fs.path.basename(out_res_path);
6699 try Io.Dir.rename(zig_cache_tmp_dir, tmp_basename, o_dir, res_filename, io);6699 try Io.Dir.rename(zig_cache_tmp_dir, tmp_basename, o_dir, res_filename, io);
src/Package/Fetch.zig+6-6
...@@ -500,7 +500,7 @@ fn runResource(...@@ -500,7 +500,7 @@ fn runResource(
500 var tmp_directory: Cache.Directory = .{500 var tmp_directory: Cache.Directory = .{
501 .path = tmp_directory_path,501 .path = tmp_directory_path,
502 .handle = handle: {502 .handle = handle: {
503 const dir = cache_root.handle.makeOpenPath(io, tmp_dir_sub_path, .{503 const dir = cache_root.handle.createDirPathOpen(io, tmp_dir_sub_path, .{
504 .open_options = .{ .iterate = true },504 .open_options = .{ .iterate = true },
505 }) catch |err| {505 }) catch |err| {
506 try eb.addRootErrorMessage(.{506 try eb.addRootErrorMessage(.{
...@@ -524,7 +524,7 @@ fn runResource(...@@ -524,7 +524,7 @@ fn runResource(
524 if (native_os == .linux and f.job_queue.work_around_btrfs_bug) {524 if (native_os == .linux and f.job_queue.work_around_btrfs_bug) {
525 // https://github.com/ziglang/zig/issues/17095525 // https://github.com/ziglang/zig/issues/17095
526 pkg_path.root_dir.handle.close(io);526 pkg_path.root_dir.handle.close(io);
527 pkg_path.root_dir.handle = cache_root.handle.makeOpenPath(io, tmp_dir_sub_path, .{527 pkg_path.root_dir.handle = cache_root.handle.createDirPathOpen(io, tmp_dir_sub_path, .{
528 .open_options = .{ .iterate = true },528 .open_options = .{ .iterate = true },
529 }) catch @panic("btrfs workaround failed");529 }) catch @panic("btrfs workaround failed");
530 }530 }
...@@ -1366,7 +1366,7 @@ fn unpackGitPack(f: *Fetch, out_dir: Io.Dir, resource: *Resource.Git) anyerror!U...@@ -1366,7 +1366,7 @@ fn unpackGitPack(f: *Fetch, out_dir: Io.Dir, resource: *Resource.Git) anyerror!U
1366 // we do not attempt to replicate the exact structure of a real .git1366 // we do not attempt to replicate the exact structure of a real .git
1367 // directory, since that isn't relevant for fetching a package.1367 // directory, since that isn't relevant for fetching a package.
1368 {1368 {
1369 var pack_dir = try out_dir.makeOpenPath(io, ".git", .{});1369 var pack_dir = try out_dir.createDirPathOpen(io, ".git", .{});
1370 defer pack_dir.close(io);1370 defer pack_dir.close(io);
1371 var pack_file = try pack_dir.createFile(io, "pkg.pack", .{ .read = true });1371 var pack_file = try pack_dir.createFile(io, "pkg.pack", .{ .read = true });
1372 defer pack_file.close(io);1372 defer pack_file.close(io);
...@@ -1427,7 +1427,7 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: Io.Dir, tmp_dir: Io.Dir) anyerror!void...@@ -1427,7 +1427,7 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: Io.Dir, tmp_dir: Io.Dir) anyerror!void
1427 .file => {1427 .file => {
1428 dir.copyFile(entry.path, tmp_dir, entry.path, io, .{}) catch |err| switch (err) {1428 dir.copyFile(entry.path, tmp_dir, entry.path, io, .{}) catch |err| switch (err) {
1429 error.FileNotFound => {1429 error.FileNotFound => {
1430 if (fs.path.dirname(entry.path)) |dirname| try tmp_dir.makePath(io, dirname);1430 if (fs.path.dirname(entry.path)) |dirname| try tmp_dir.createDirPath(io, dirname);
1431 try dir.copyFile(entry.path, tmp_dir, entry.path, io, .{});1431 try dir.copyFile(entry.path, tmp_dir, entry.path, io, .{});
1432 },1432 },
1433 else => |e| return e,1433 else => |e| return e,
...@@ -1440,7 +1440,7 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: Io.Dir, tmp_dir: Io.Dir) anyerror!void...@@ -1440,7 +1440,7 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: Io.Dir, tmp_dir: Io.Dir) anyerror!void
1440 // the destination directory, fail with an error instead.1440 // the destination directory, fail with an error instead.
1441 tmp_dir.symLink(io, link_name, entry.path, .{}) catch |err| switch (err) {1441 tmp_dir.symLink(io, link_name, entry.path, .{}) catch |err| switch (err) {
1442 error.FileNotFound => {1442 error.FileNotFound => {
1443 if (fs.path.dirname(entry.path)) |dirname| try tmp_dir.makePath(io, dirname);1443 if (fs.path.dirname(entry.path)) |dirname| try tmp_dir.createDirPath(io, dirname);
1444 try tmp_dir.symLink(io, link_name, entry.path, .{});1444 try tmp_dir.symLink(io, link_name, entry.path, .{});
1445 },1445 },
1446 else => |e| return e,1446 else => |e| return e,
...@@ -2250,7 +2250,7 @@ const TestFetchBuilder = struct {...@@ -2250,7 +2250,7 @@ const TestFetchBuilder = struct {
2250 cache_parent_dir: std.Io.Dir,2250 cache_parent_dir: std.Io.Dir,
2251 path_or_url: []const u8,2251 path_or_url: []const u8,
2252 ) !*Fetch {2252 ) !*Fetch {
2253 const cache_dir = try cache_parent_dir.makeOpenPath(io, "zig-global-cache", .{});2253 const cache_dir = try cache_parent_dir.createDirPathOpen(io, "zig-global-cache", .{});
22542254
2255 self.http_client = .{ .allocator = allocator, .io = io };2255 self.http_client = .{ .allocator = allocator, .io = io };
2256 self.global_cache_directory = .{ .handle = cache_dir, .path = null };2256 self.global_cache_directory = .{ .handle = cache_dir, .path = null };
src/Package/Fetch/git.zig+2-2
...@@ -1720,10 +1720,10 @@ pub fn main() !void {...@@ -1720,10 +1720,10 @@ pub fn main() !void {
1720 var pack_file_reader = pack_file.reader(io, &pack_file_buffer);1720 var pack_file_reader = pack_file.reader(io, &pack_file_buffer);
17211721
1722 const commit = try Oid.parse(format, args[3]);1722 const commit = try Oid.parse(format, args[3]);
1723 var worktree = try Io.Dir.cwd().makeOpenPath(io, args[4], .{});1723 var worktree = try Io.Dir.cwd().createDirPathOpen(io, args[4], .{});
1724 defer worktree.close(io);1724 defer worktree.close(io);
17251725
1726 var git_dir = try worktree.makeOpenPath(io, ".git", .{});1726 var git_dir = try worktree.createDirPathOpen(io, ".git", .{});
1727 defer git_dir.close(io);1727 defer git_dir.close(io);
17281728
1729 std.debug.print("Starting index...\n", .{});1729 std.debug.print("Starting index...\n", .{});
src/libs/freebsd.zig+2-2
...@@ -444,7 +444,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -444,7 +444,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
444 var cache: Cache = .{444 var cache: Cache = .{
445 .gpa = gpa,445 .gpa = gpa,
446 .io = io,446 .io = io,
447 .manifest_dir = try comp.dirs.global_cache.handle.makeOpenPath(io, "h", .{}),447 .manifest_dir = try comp.dirs.global_cache.handle.createDirPathOpen(io, "h", .{}),
448 };448 };
449 cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() });449 cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() });
450 cache.addPrefix(comp.dirs.zig_lib);450 cache.addPrefix(comp.dirs.zig_lib);
...@@ -477,7 +477,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -477,7 +477,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
477 const o_sub_path = try path.join(arena, &[_][]const u8{ "o", &digest });477 const o_sub_path = try path.join(arena, &[_][]const u8{ "o", &digest });
478478
479 var o_directory: Cache.Directory = .{479 var o_directory: Cache.Directory = .{
480 .handle = try comp.dirs.global_cache.handle.makeOpenPath(io, o_sub_path, .{}),480 .handle = try comp.dirs.global_cache.handle.createDirPathOpen(io, o_sub_path, .{}),
481 .path = try comp.dirs.global_cache.join(arena, &.{o_sub_path}),481 .path = try comp.dirs.global_cache.join(arena, &.{o_sub_path}),
482 };482 };
483 defer o_directory.handle.close(io);483 defer o_directory.handle.close(io);
src/libs/glibc.zig+2-2
...@@ -679,7 +679,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -679,7 +679,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
679 var cache: Cache = .{679 var cache: Cache = .{
680 .gpa = gpa,680 .gpa = gpa,
681 .io = io,681 .io = io,
682 .manifest_dir = try comp.dirs.global_cache.handle.makeOpenPath(io, "h", .{}),682 .manifest_dir = try comp.dirs.global_cache.handle.createDirPathOpen(io, "h", .{}),
683 };683 };
684 cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() });684 cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() });
685 cache.addPrefix(comp.dirs.zig_lib);685 cache.addPrefix(comp.dirs.zig_lib);
...@@ -712,7 +712,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -712,7 +712,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
712 const o_sub_path = try path.join(arena, &[_][]const u8{ "o", &digest });712 const o_sub_path = try path.join(arena, &[_][]const u8{ "o", &digest });
713713
714 var o_directory: Cache.Directory = .{714 var o_directory: Cache.Directory = .{
715 .handle = try comp.dirs.global_cache.handle.makeOpenPath(io, o_sub_path, .{}),715 .handle = try comp.dirs.global_cache.handle.createDirPathOpen(io, o_sub_path, .{}),
716 .path = try comp.dirs.global_cache.join(arena, &.{o_sub_path}),716 .path = try comp.dirs.global_cache.join(arena, &.{o_sub_path}),
717 };717 };
718 defer o_directory.handle.close(io);718 defer o_directory.handle.close(io);
src/libs/mingw.zig+2-2
...@@ -258,7 +258,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {...@@ -258,7 +258,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
258 var cache: Cache = .{258 var cache: Cache = .{
259 .gpa = gpa,259 .gpa = gpa,
260 .io = io,260 .io = io,
261 .manifest_dir = try comp.dirs.global_cache.handle.makeOpenPath(io, "h", .{}),261 .manifest_dir = try comp.dirs.global_cache.handle.createDirPathOpen(io, "h", .{}),
262 };262 };
263 cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() });263 cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() });
264 cache.addPrefix(comp.dirs.zig_lib);264 cache.addPrefix(comp.dirs.zig_lib);
...@@ -297,7 +297,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {...@@ -297,7 +297,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void {
297297
298 const digest = man.final();298 const digest = man.final();
299 const o_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest });299 const o_sub_path = try std.fs.path.join(arena, &[_][]const u8{ "o", &digest });
300 var o_dir = try comp.dirs.global_cache.handle.makeOpenPath(io, o_sub_path, .{});300 var o_dir = try comp.dirs.global_cache.handle.createDirPathOpen(io, o_sub_path, .{});
301 defer o_dir.close(io);301 defer o_dir.close(io);
302302
303 const aro = @import("aro");303 const aro = @import("aro");
src/libs/netbsd.zig+2-2
...@@ -385,7 +385,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -385,7 +385,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
385 var cache: Cache = .{385 var cache: Cache = .{
386 .gpa = gpa,386 .gpa = gpa,
387 .io = io,387 .io = io,
388 .manifest_dir = try comp.dirs.global_cache.handle.makeOpenPath(io, "h", .{}),388 .manifest_dir = try comp.dirs.global_cache.handle.createDirPathOpen(io, "h", .{}),
389 };389 };
390 cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() });390 cache.addPrefix(.{ .path = null, .handle = Io.Dir.cwd() });
391 cache.addPrefix(comp.dirs.zig_lib);391 cache.addPrefix(comp.dirs.zig_lib);
...@@ -418,7 +418,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye...@@ -418,7 +418,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
418 const o_sub_path = try path.join(arena, &[_][]const u8{ "o", &digest });418 const o_sub_path = try path.join(arena, &[_][]const u8{ "o", &digest });
419419
420 var o_directory: Cache.Directory = .{420 var o_directory: Cache.Directory = .{
421 .handle = try comp.dirs.global_cache.handle.makeOpenPath(io, o_sub_path, .{}),421 .handle = try comp.dirs.global_cache.handle.createDirPathOpen(io, o_sub_path, .{}),
422 .path = try comp.dirs.global_cache.join(arena, &.{o_sub_path}),422 .path = try comp.dirs.global_cache.join(arena, &.{o_sub_path}),
423 };423 };
424 defer o_directory.handle.close(io);424 defer o_directory.handle.close(io);
src/link/MachO.zig+1-1
...@@ -3319,7 +3319,7 @@ pub fn reopenDebugInfo(self: *MachO) !void {...@@ -3319,7 +3319,7 @@ pub fn reopenDebugInfo(self: *MachO) !void {
3319 );3319 );
3320 defer gpa.free(d_sym_path);3320 defer gpa.free(d_sym_path);
33213321
3322 var d_sym_bundle = try self.base.emit.root_dir.handle.makeOpenPath(io, d_sym_path, .{});3322 var d_sym_bundle = try self.base.emit.root_dir.handle.createDirPathOpen(io, d_sym_path, .{});
3323 defer d_sym_bundle.close(io);3323 defer d_sym_bundle.close(io);
33243324
3325 self.d_sym.?.file = try d_sym_bundle.createFile(io, fs.path.basename(self.base.emit.sub_path), .{3325 self.d_sym.?.file = try d_sym_bundle.createFile(io, fs.path.basename(self.base.emit.sub_path), .{
src/main.zig+4-4
...@@ -3381,7 +3381,7 @@ fn buildOutputType(...@@ -3381,7 +3381,7 @@ fn buildOutputType(
3381 const dump_path = try std.fmt.allocPrint(arena, "tmp" ++ sep ++ "{x}-dump-stdin{s}", .{3381 const dump_path = try std.fmt.allocPrint(arena, "tmp" ++ sep ++ "{x}-dump-stdin{s}", .{
3382 std.crypto.random.int(u64), ext.canonicalName(target),3382 std.crypto.random.int(u64), ext.canonicalName(target),
3383 });3383 });
3384 try dirs.local_cache.handle.makePath(io, "tmp");3384 try dirs.local_cache.handle.createDirPath(io, "tmp");
33853385
3386 // Note that in one of the happy paths, execve() is used to switch to3386 // Note that in one of the happy paths, execve() is used to switch to
3387 // clang in which case any cleanup logic that exists for this temporary3387 // clang in which case any cleanup logic that exists for this temporary
...@@ -6955,7 +6955,7 @@ fn cmdFetch(...@@ -6955,7 +6955,7 @@ fn cmdFetch(
6955 var global_cache_directory: Directory = l: {6955 var global_cache_directory: Directory = l: {
6956 const p = override_global_cache_dir orelse try introspect.resolveGlobalCacheDir(arena);6956 const p = override_global_cache_dir orelse try introspect.resolveGlobalCacheDir(arena);
6957 break :l .{6957 break :l .{
6958 .handle = try Io.Dir.cwd().makeOpenPath(io, p, .{}),6958 .handle = try Io.Dir.cwd().createDirPathOpen(io, p, .{}),
6959 .path = p,6959 .path = p,
6960 };6960 };
6961 };6961 };
...@@ -7201,7 +7201,7 @@ fn createDependenciesModule(...@@ -7201,7 +7201,7 @@ fn createDependenciesModule(
7201 const rand_int = std.crypto.random.int(u64);7201 const rand_int = std.crypto.random.int(u64);
7202 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(rand_int);7202 const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ std.fmt.hex(rand_int);
7203 {7203 {
7204 var tmp_dir = try dirs.local_cache.handle.makeOpenPath(io, tmp_dir_sub_path, .{});7204 var tmp_dir = try dirs.local_cache.handle.createDirPathOpen(io, tmp_dir_sub_path, .{});
7205 defer tmp_dir.close(io);7205 defer tmp_dir.close(io);
7206 try tmp_dir.writeFile(io, .{ .sub_path = basename, .data = source });7206 try tmp_dir.writeFile(io, .{ .sub_path = basename, .data = source });
7207 }7207 }
...@@ -7396,7 +7396,7 @@ const Templates = struct {...@@ -7396,7 +7396,7 @@ const Templates = struct {
7396 fingerprint: Package.Fingerprint,7396 fingerprint: Package.Fingerprint,
7397 ) !void {7397 ) !void {
7398 if (fs.path.dirname(template_path)) |dirname| {7398 if (fs.path.dirname(template_path)) |dirname| {
7399 out_dir.makePath(io, dirname) catch |err| {7399 out_dir.createDirPath(io, dirname) catch |err| {
7400 fatal("unable to make path '{s}': {t}", .{ dirname, err });7400 fatal("unable to make path '{s}': {t}", .{ dirname, err });
7401 };7401 };
7402 }7402 }