Update callers of fs.makePath
This commit is contained in:
parent
695b0976c3
commit
1ca5f06762
@ -763,7 +763,7 @@ pub const Builder = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn makePath(self: *Builder, path: []const u8) !void {
|
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) });
|
warn("Unable to create path {}: {}\n", .{ path, @errorName(err) });
|
||||||
return err;
|
return err;
|
||||||
};
|
};
|
||||||
@ -2311,7 +2311,7 @@ pub const InstallDirStep = struct {
|
|||||||
const rel_path = entry.path[full_src_dir.len + 1 ..];
|
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 });
|
const dest_path = try fs.path.join(self.builder.allocator, &[_][]const u8{ dest_prefix, rel_path });
|
||||||
switch (entry.kind) {
|
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),
|
.File => try self.builder.updateFile(entry.path, dest_path),
|
||||||
else => continue,
|
else => continue,
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ pub const WriteFileStep = struct {
|
|||||||
&hash_basename,
|
&hash_basename,
|
||||||
});
|
});
|
||||||
// TODO replace with something like fs.makePathAndOpenDir
|
// 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) });
|
warn("unable to make path {}: {}\n", .{ self.output_dir, @errorName(err) });
|
||||||
return err;
|
return err;
|
||||||
};
|
};
|
||||||
|
@ -618,11 +618,10 @@ test "write a file, watch it, write it again" {
|
|||||||
// TODO re-enable this test
|
// TODO re-enable this test
|
||||||
if (true) return error.SkipZigTest;
|
if (true) return error.SkipZigTest;
|
||||||
|
|
||||||
const allocator = std.heap.page_allocator;
|
try fs.cwd().makePath(test_tmp_dir);
|
||||||
|
|
||||||
try os.makePath(allocator, test_tmp_dir);
|
|
||||||
defer os.deleteTree(test_tmp_dir) catch {};
|
defer os.deleteTree(test_tmp_dir) catch {};
|
||||||
|
|
||||||
|
const allocator = std.heap.page_allocator;
|
||||||
return testFsWatch(&allocator);
|
return testFsWatch(&allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ const AtomicRmwOp = builtin.AtomicRmwOp;
|
|||||||
const AtomicOrder = builtin.AtomicOrder;
|
const AtomicOrder = builtin.AtomicOrder;
|
||||||
|
|
||||||
test "makePath, put some files in it, deleteTree" {
|
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 ++ "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 io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah");
|
||||||
try fs.deleteTree("os_test_tmp");
|
try fs.deleteTree("os_test_tmp");
|
||||||
@ -28,7 +28,7 @@ test "makePath, put some files in it, deleteTree" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test "access file" {
|
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| {
|
if (fs.cwd().access("os_test_tmp" ++ fs.path.sep_str ++ "file.txt", .{})) |ok| {
|
||||||
@panic("expected error");
|
@panic("expected error");
|
||||||
} else |err| {
|
} else |err| {
|
||||||
|
@ -1179,7 +1179,7 @@ pub const Compilation = struct {
|
|||||||
defer self.gpa().free(zig_dir_path);
|
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..] });
|
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;
|
return tmp_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ pub const TestContext = struct {
|
|||||||
self.zig_lib_dir = try introspect.resolveZigLibDir(allocator);
|
self.zig_lib_dir = try introspect.resolveZigLibDir(allocator);
|
||||||
errdefer allocator.free(self.zig_lib_dir);
|
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 {};
|
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 });
|
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| {
|
if (std.fs.path.dirname(file1_path)) |dirname| {
|
||||||
try std.fs.makePath(allocator, dirname);
|
try std.fs.cwd().makePath(dirname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO async I/O
|
// 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() });
|
const output_file = try std.fmt.allocPrint(allocator, "{}-out{}", .{ file1_path, (Target{ .Native = {} }).exeFileExt() });
|
||||||
if (std.fs.path.dirname(file1_path)) |dirname| {
|
if (std.fs.path.dirname(file1_path)) |dirname| {
|
||||||
try std.fs.makePath(allocator, dirname);
|
try std.fs.cwd().makePath(dirname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO async I/O
|
// TODO async I/O
|
||||||
|
Loading…
x
Reference in New Issue
Block a user