authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-01-16 12:21:00+10:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-03 13:25:43-05:00
log1ca5f06762401d2e90c8119acb4837571696dd5e
tree156e1e5f40abfc798301f35be792463c8bf5b4fe
parent695b0976c3757325d4b2043151d267bcc7490f7e
signaturelock-open Commit is signed but in an unrecognized format.

Update callers of fs.makePath


6 files changed, 11 insertions(+), 12 deletions(-)

lib/std/build.zig+2-2
...@@ -763,7 +763,7 @@ pub const Builder = struct {...@@ -763,7 +763,7 @@ pub const Builder = struct {
763 }763 }
764764
765 pub fn makePath(self: *Builder, path: []const u8) !void {765 pub fn makePath(self: *Builder, path: []const u8) !void {
766 fs.makePath(self.allocator, self.pathFromRoot(path)) catch |err| {766 fs.cwd().makePath(self.pathFromRoot(path)) catch |err| {
767 warn("Unable to create path {}: {}\n", .{ path, @errorName(err) });767 warn("Unable to create path {}: {}\n", .{ path, @errorName(err) });
768 return err;768 return err;
769 };769 };
...@@ -2311,7 +2311,7 @@ pub const InstallDirStep = struct {...@@ -2311,7 +2311,7 @@ pub const InstallDirStep = struct {
2311 const rel_path = entry.path[full_src_dir.len + 1 ..];2311 const rel_path = entry.path[full_src_dir.len + 1 ..];
2312 const dest_path = try fs.path.join(self.builder.allocator, &[_][]const u8{ dest_prefix, rel_path });2312 const dest_path = try fs.path.join(self.builder.allocator, &[_][]const u8{ dest_prefix, rel_path });
2313 switch (entry.kind) {2313 switch (entry.kind) {
2314 .Directory => try fs.makePath(self.builder.allocator, dest_path),2314 .Directory => try fs.cwd().makePath(dest_path),
2315 .File => try self.builder.updateFile(entry.path, dest_path),2315 .File => try self.builder.updateFile(entry.path, dest_path),
2316 else => continue,2316 else => continue,
2317 }2317 }
lib/std/build/write_file.zig+1-1
...@@ -74,7 +74,7 @@ pub const WriteFileStep = struct {...@@ -74,7 +74,7 @@ pub const WriteFileStep = struct {
74 &hash_basename,74 &hash_basename,
75 });75 });
76 // TODO replace with something like fs.makePathAndOpenDir76 // TODO replace with something like fs.makePathAndOpenDir
77 fs.makePath(self.builder.allocator, self.output_dir) catch |err| {77 fs.cwd().makePath(self.output_dir) catch |err| {
78 warn("unable to make path {}: {}\n", .{ self.output_dir, @errorName(err) });78 warn("unable to make path {}: {}\n", .{ self.output_dir, @errorName(err) });
79 return err;79 return err;
80 };80 };
lib/std/fs/watch.zig+2-3
...@@ -618,11 +618,10 @@ test "write a file, watch it, write it again" {...@@ -618,11 +618,10 @@ test "write a file, watch it, write it again" {
618 // TODO re-enable this test618 // TODO re-enable this test
619 if (true) return error.SkipZigTest;619 if (true) return error.SkipZigTest;
620620
621 const allocator = std.heap.page_allocator;621 try fs.cwd().makePath(test_tmp_dir);
622
623 try os.makePath(allocator, test_tmp_dir);
624 defer os.deleteTree(test_tmp_dir) catch {};622 defer os.deleteTree(test_tmp_dir) catch {};
625623
624 const allocator = std.heap.page_allocator;
626 return testFsWatch(&allocator);625 return testFsWatch(&allocator);
627}626}
628627
lib/std/os/test.zig+2-2
...@@ -16,7 +16,7 @@ const AtomicRmwOp = builtin.AtomicRmwOp;...@@ -16,7 +16,7 @@ const AtomicRmwOp = builtin.AtomicRmwOp;
16const AtomicOrder = builtin.AtomicOrder;16const AtomicOrder = builtin.AtomicOrder;
1717
18test "makePath, put some files in it, deleteTree" {18test "makePath, put some files in it, deleteTree" {
19 try fs.makePath(a, "os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c");19 try fs.cwd().makePath("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c");
20 try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c" ++ fs.path.sep_str ++ "file.txt", "nonsense");20 try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c" ++ fs.path.sep_str ++ "file.txt", "nonsense");
21 try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah");21 try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah");
22 try fs.deleteTree("os_test_tmp");22 try fs.deleteTree("os_test_tmp");
...@@ -28,7 +28,7 @@ test "makePath, put some files in it, deleteTree" {...@@ -28,7 +28,7 @@ test "makePath, put some files in it, deleteTree" {
28}28}
2929
30test "access file" {30test "access file" {
31 try fs.makePath(a, "os_test_tmp");31 try fs.cwd().makePath("os_test_tmp");
32 if (fs.cwd().access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", .{})) |ok| {32 if (fs.cwd().access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", .{})) |ok| {
33 @panic("expected error");33 @panic("expected error");
34 } else |err| {34 } else |err| {
src-self-hosted/compilation.zig+1-1
...@@ -1179,7 +1179,7 @@ pub const Compilation = struct {...@@ -1179,7 +1179,7 @@ pub const Compilation = struct {
1179 defer self.gpa().free(zig_dir_path);1179 defer self.gpa().free(zig_dir_path);
11801180
1181 const tmp_dir = try fs.path.join(self.arena(), &[_][]const u8{ zig_dir_path, comp_dir_name[0..] });1181 const tmp_dir = try fs.path.join(self.arena(), &[_][]const u8{ zig_dir_path, comp_dir_name[0..] });
1182 try fs.makePath(self.gpa(), tmp_dir);1182 try fs.cwd().makePath(tmp_dir);
1183 return tmp_dir;1183 return tmp_dir;
1184 }1184 }
11851185
src-self-hosted/test.zig+3-3
...@@ -56,7 +56,7 @@ pub const TestContext = struct {...@@ -56,7 +56,7 @@ pub const TestContext = struct {
56 self.zig_lib_dir = try introspect.resolveZigLibDir(allocator);56 self.zig_lib_dir = try introspect.resolveZigLibDir(allocator);
57 errdefer allocator.free(self.zig_lib_dir);57 errdefer allocator.free(self.zig_lib_dir);
5858
59 try std.fs.makePath(allocator, tmp_dir_name);59 try std.fs.cwd().makePath(tmp_dir_name);
60 errdefer std.fs.deleteTree(tmp_dir_name) catch {};60 errdefer std.fs.deleteTree(tmp_dir_name) catch {};
61 }61 }
6262
...@@ -85,7 +85,7 @@ pub const TestContext = struct {...@@ -85,7 +85,7 @@ pub const TestContext = struct {
85 const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });85 const file1_path = try std.fs.path.join(allocator, [_][]const u8{ tmp_dir_name, file_index, file1 });
8686
87 if (std.fs.path.dirname(file1_path)) |dirname| {87 if (std.fs.path.dirname(file1_path)) |dirname| {
88 try std.fs.makePath(allocator, dirname);88 try std.fs.cwd().makePath(dirname);
89 }89 }
9090
91 // TODO async I/O91 // TODO async I/O
...@@ -119,7 +119,7 @@ pub const TestContext = struct {...@@ -119,7 +119,7 @@ pub const TestContext = struct {
119119
120 const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", .{ file1_path, (Target{ .Native = {} }).exeFileExt() });120 const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", .{ file1_path, (Target{ .Native = {} }).exeFileExt() });
121 if (std.fs.path.dirname(file1_path)) |dirname| {121 if (std.fs.path.dirname(file1_path)) |dirname| {
122 try std.fs.makePath(allocator, dirname);122 try std.fs.cwd().makePath(dirname);
123 }123 }
124124
125 // TODO async I/O125 // TODO async I/O