diff --git a/lib/std/build.zig b/lib/std/build.zig index ecf39305519722495392b302b649e4d7029937a6..59e6c4e87c1ad1fb31f1e4cc12b56e717621b188 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -763,7 +763,7 @@ pub const Builder = struct { } pub fn makePath(self: *Builder, path: []const u8) !void { - fs.makePath(self.allocator, self.pathFromRoot(path)) catch |err| { + fs.cwd().makePath(self.pathFromRoot(path)) catch |err| { warn("Unable to create path {}: {}\n", .{ path, @errorName(err) }); return err; }; @@ -2311,7 +2311,7 @@ pub const InstallDirStep = struct { const rel_path = entry.path[full_src_dir.len + 1 ..]; const dest_path = try fs.path.join(self.builder.allocator, &[_][]const u8{ dest_prefix, rel_path }); switch (entry.kind) { - .Directory => try fs.makePath(self.builder.allocator, dest_path), + .Directory => try fs.cwd().makePath(dest_path), .File => try self.builder.updateFile(entry.path, dest_path), else => continue, } diff --git a/lib/std/build/write_file.zig b/lib/std/build/write_file.zig index 13d131ac61f2c0d3c8b7f5a68e8585ab6e651a97..60c54336e088893c196b6e6e10a0439671e948c1 100644 --- a/lib/std/build/write_file.zig +++ b/lib/std/build/write_file.zig @@ -74,7 +74,7 @@ pub const WriteFileStep = struct { &hash_basename, }); // TODO replace with something like fs.makePathAndOpenDir - fs.makePath(self.builder.allocator, self.output_dir) catch |err| { + fs.cwd().makePath(self.output_dir) catch |err| { warn("unable to make path {}: {}\n", .{ self.output_dir, @errorName(err) }); return err; }; diff --git a/lib/std/fs/watch.zig b/lib/std/fs/watch.zig index 1eb5a97ff164f800f6d5e873cdfd0919b1bcdde0..3180240a728d8a5b0c5d4bfd078c9e3f177a21e0 100644 --- a/lib/std/fs/watch.zig +++ b/lib/std/fs/watch.zig @@ -618,11 +618,10 @@ test "write a file, watch it, write it again" { // TODO re-enable this test if (true) return error.SkipZigTest; - const allocator = std.heap.page_allocator; - - try os.makePath(allocator, test_tmp_dir); + try fs.cwd().makePath(test_tmp_dir); defer os.deleteTree(test_tmp_dir) catch {}; + const allocator = std.heap.page_allocator; return testFsWatch(&allocator); } diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index 717380ea30eb752b0446cfc400dac31cf2663147..a8544c5b8348ffe74261cd099ac6728fd2619af9 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -16,7 +16,7 @@ const AtomicRmwOp = builtin.AtomicRmwOp; const AtomicOrder = builtin.AtomicOrder; test "makePath, put some files in it, deleteTree" { - try fs.makePath(a, "os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c"); + try fs.cwd().makePath("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c"); try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c" ++ fs.path.sep_str ++ "file.txt", "nonsense"); try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah"); try fs.deleteTree("os_test_tmp"); @@ -28,7 +28,7 @@ test "makePath, put some files in it, deleteTree" { } test "access file" { - try fs.makePath(a, "os_test_tmp"); + try fs.cwd().makePath("os_test_tmp"); if (fs.cwd().access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", .{})) |ok| { @panic("expected error"); } else |err| { diff --git a/src-self-hosted/compilation.zig b/src-self-hosted/compilation.zig index 15453fabcc62ab1daec9d5c40c1899209fcb6e70..7a45bb3c37f12cc634e781ee3e2e73b67e791ce3 100644 --- a/src-self-hosted/compilation.zig +++ b/src-self-hosted/compilation.zig @@ -1179,7 +1179,7 @@ pub const Compilation = struct { defer self.gpa().free(zig_dir_path); const tmp_dir = try fs.path.join(self.arena(), &[_][]const u8{ zig_dir_path, comp_dir_name[0..] }); - try fs.makePath(self.gpa(), tmp_dir); + try fs.cwd().makePath(tmp_dir); return tmp_dir; } diff --git a/src-self-hosted/test.zig b/src-self-hosted/test.zig index 8c322e5fb62aa64bb9fe09dec31e3f446f16602a..e87164c9fb471f243a85c6708902f4c333f9d7a8 100644 --- a/src-self-hosted/test.zig +++ b/src-self-hosted/test.zig @@ -56,7 +56,7 @@ pub const TestContext = struct { self.zig_lib_dir = try introspect.resolveZigLibDir(allocator); errdefer allocator.free(self.zig_lib_dir); - try std.fs.makePath(allocator, tmp_dir_name); + try std.fs.cwd().makePath(tmp_dir_name); errdefer std.fs.deleteTree(tmp_dir_name) catch {}; } @@ -85,7 +85,7 @@ pub const TestContext = struct { const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 }); if (std.fs.path.dirname(file1_path)) |dirname| { - try std.fs.makePath(allocator, dirname); + try std.fs.cwd().makePath(dirname); } // TODO async I/O @@ -119,7 +119,7 @@ pub const TestContext = struct { const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", .{ file1_path, (Target{ .Native = {} }).exeFileExt() }); if (std.fs.path.dirname(file1_path)) |dirname| { - try std.fs.makePath(allocator, dirname); + try std.fs.cwd().makePath(dirname); } // TODO async I/O