diff --git a/lib/std/build.zig b/lib/std/build.zig index ecf3930551..59e6c4e87c 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 13d131ac61..60c54336e0 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 1eb5a97ff1..3180240a72 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 717380ea30..a8544c5b83 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 15453fabcc..7a45bb3c37 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 8c322e5fb6..e87164c9fb 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