mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:24:33 +01:00
std.Build.Cache: remove readSmallFile and writeSmallFile
These were to support optimizations involving detecting when to avoid calling into LLD, which are no longer implemented.
This commit is contained in:
parent
950d18ef69
commit
4218344dd3
18 changed files with 63 additions and 75 deletions
|
|
@ -459,7 +459,7 @@ pub fn main() !void {
|
|||
}
|
||||
const s = std.fs.path.sep_str;
|
||||
const tmp_sub_path = "tmp" ++ s ++ (output_tmp_nonce orelse fatal("missing -Z arg", .{}));
|
||||
local_cache_directory.handle.writeFile(.{
|
||||
local_cache_directory.handle.writeFile(io, .{
|
||||
.sub_path = tmp_sub_path,
|
||||
.data = buffer.items,
|
||||
.flags = .{ .exclusive = true },
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ pub fn main() !void {
|
|||
var general_purpose_allocator: std.heap.GeneralPurposeAllocator(.{}) = .init;
|
||||
const gpa = general_purpose_allocator.allocator();
|
||||
|
||||
var threaded: std.Io.Threaded = .init(gpa);
|
||||
defer threaded.deinit();
|
||||
const io = threaded.io();
|
||||
|
||||
const args = try std.process.argsAlloc(arena);
|
||||
|
||||
var opt_checker_path: ?[]const u8 = null;
|
||||
|
|
@ -233,12 +237,12 @@ pub fn main() !void {
|
|||
}
|
||||
}
|
||||
|
||||
try Io.Dir.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.written() });
|
||||
try Io.Dir.cwd().writeFile(io, .{ .sub_path = root_source_file_path, .data = rendered.written() });
|
||||
// std.debug.print("trying this code:\n{s}\n", .{rendered.items});
|
||||
|
||||
const interestingness = try runCheck(arena, interestingness_argv.items);
|
||||
std.debug.print("{d} random transformations: {s}. {d}/{d}\n", .{
|
||||
subset_size, @tagName(interestingness), start_index, transformations.items.len,
|
||||
std.debug.print("{d} random transformations: {t}. {d}/{d}\n", .{
|
||||
subset_size, interestingness, start_index, transformations.items.len,
|
||||
});
|
||||
switch (interestingness) {
|
||||
.interesting => {
|
||||
|
|
@ -274,7 +278,7 @@ pub fn main() !void {
|
|||
fixups.clearRetainingCapacity();
|
||||
rendered.clearRetainingCapacity();
|
||||
try tree.render(gpa, &rendered.writer, fixups);
|
||||
try Io.Dir.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.written() });
|
||||
try Io.Dir.cwd().writeFile(io, .{ .sub_path = root_source_file_path, .data = rendered.written() });
|
||||
|
||||
return std.process.cleanExit();
|
||||
}
|
||||
|
|
|
|||
2
lib/compiler/resinator/main.zig
vendored
2
lib/compiler/resinator/main.zig
vendored
|
|
@ -212,7 +212,7 @@ pub fn main() !void {
|
|||
try output_file.writeAll(full_input);
|
||||
},
|
||||
.filename => |output_filename| {
|
||||
try Io.Dir.cwd().writeFile(.{ .sub_path = output_filename, .data = full_input });
|
||||
try Io.Dir.cwd().writeFile(io, .{ .sub_path = output_filename, .data = full_input });
|
||||
},
|
||||
}
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ fn serveSourcesTar(request: *std.http.Server.Request, context: *Context) !void {
|
|||
.interface = std.Io.File.Reader.initInterface(&.{}),
|
||||
.size = stat.size,
|
||||
};
|
||||
try archiver.writeFile(entry.path, &file_reader, stat.mtime);
|
||||
try archiver.writeFile(io, entry.path, &file_reader, stat.mtime);
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1276,30 +1276,6 @@ pub const Manifest = struct {
|
|||
}
|
||||
};
|
||||
|
||||
/// On operating systems that support symlinks, does a readlink. On other operating systems,
|
||||
/// uses the file contents. Windows supports symlinks but only with elevated privileges, so
|
||||
/// it is treated as not supporting symlinks.
|
||||
pub fn readSmallFile(dir: Io.Dir, sub_path: []const u8, buffer: []u8) ![]u8 {
|
||||
if (builtin.os.tag == .windows) {
|
||||
return dir.readFile(sub_path, buffer);
|
||||
} else {
|
||||
return dir.readLink(sub_path, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/// On operating systems that support symlinks, does a symlink. On other operating systems,
|
||||
/// uses the file contents. Windows supports symlinks but only with elevated privileges, so
|
||||
/// it is treated as not supporting symlinks.
|
||||
/// `data` must be a valid UTF-8 encoded file path and 255 bytes or fewer.
|
||||
pub fn writeSmallFile(dir: Io.Dir, sub_path: []const u8, data: []const u8) !void {
|
||||
assert(data.len <= 255);
|
||||
if (builtin.os.tag == .windows) {
|
||||
return dir.writeFile(.{ .sub_path = sub_path, .data = data });
|
||||
} else {
|
||||
return dir.symLink(data, sub_path, .{});
|
||||
}
|
||||
}
|
||||
|
||||
fn hashFile(io: Io, file: Io.File, bin_digest: *[Hasher.mac_length]u8) Io.File.ReadPositionalError!void {
|
||||
var buffer: [2048]u8 = undefined;
|
||||
var hasher = hasher_init;
|
||||
|
|
@ -1338,7 +1314,7 @@ test "cache file and then recall it" {
|
|||
const temp_file = "test.txt";
|
||||
const temp_manifest_dir = "temp_manifest_dir";
|
||||
|
||||
try tmp.dir.writeFile(.{ .sub_path = temp_file, .data = "Hello, world!\n" });
|
||||
try tmp.dir.writeFile(io, .{ .sub_path = temp_file, .data = "Hello, world!\n" });
|
||||
|
||||
// Wait for file timestamps to tick
|
||||
const initial_time = try testGetCurrentFileTimestamp(io, tmp.dir);
|
||||
|
|
@ -1404,7 +1380,7 @@ test "check that changing a file makes cache fail" {
|
|||
const original_temp_file_contents = "Hello, world!\n";
|
||||
const updated_temp_file_contents = "Hello, world; but updated!\n";
|
||||
|
||||
try tmp.dir.writeFile(.{ .sub_path = temp_file, .data = original_temp_file_contents });
|
||||
try tmp.dir.writeFile(io, .{ .sub_path = temp_file, .data = original_temp_file_contents });
|
||||
|
||||
// Wait for file timestamps to tick
|
||||
const initial_time = try testGetCurrentFileTimestamp(tmp.dir);
|
||||
|
|
@ -1441,7 +1417,7 @@ test "check that changing a file makes cache fail" {
|
|||
try ch.writeManifest();
|
||||
}
|
||||
|
||||
try tmp.dir.writeFile(.{ .sub_path = temp_file, .data = updated_temp_file_contents });
|
||||
try tmp.dir.writeFile(io, .{ .sub_path = temp_file, .data = updated_temp_file_contents });
|
||||
|
||||
{
|
||||
var ch = cache.obtain();
|
||||
|
|
@ -1521,8 +1497,8 @@ test "Manifest with files added after initial hash work" {
|
|||
const temp_file2 = "cache_hash_post_file_test2.txt";
|
||||
const temp_manifest_dir = "cache_hash_post_file_manifest_dir";
|
||||
|
||||
try tmp.dir.writeFile(.{ .sub_path = temp_file1, .data = "Hello, world!\n" });
|
||||
try tmp.dir.writeFile(.{ .sub_path = temp_file2, .data = "Hello world the second!\n" });
|
||||
try tmp.dir.writeFile(io, .{ .sub_path = temp_file1, .data = "Hello, world!\n" });
|
||||
try tmp.dir.writeFile(io, .{ .sub_path = temp_file2, .data = "Hello world the second!\n" });
|
||||
|
||||
// Wait for file timestamps to tick
|
||||
const initial_time = try testGetCurrentFileTimestamp(tmp.dir);
|
||||
|
|
@ -1573,7 +1549,7 @@ test "Manifest with files added after initial hash work" {
|
|||
try testing.expect(mem.eql(u8, &digest1, &digest2));
|
||||
|
||||
// Modify the file added after initial hash
|
||||
try tmp.dir.writeFile(.{ .sub_path = temp_file2, .data = "Hello world the second, updated\n" });
|
||||
try tmp.dir.writeFile(io, .{ .sub_path = temp_file2, .data = "Hello world the second, updated\n" });
|
||||
|
||||
// Wait for file timestamps to tick
|
||||
const initial_time2 = try testGetCurrentFileTimestamp(tmp.dir);
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
|
|||
});
|
||||
};
|
||||
|
||||
b.cache_root.handle.writeFile(.{ .sub_path = sub_path, .data = output }) catch |err| {
|
||||
b.cache_root.handle.writeFile(io, .{ .sub_path = sub_path, .data = output }) catch |err| {
|
||||
return step.fail("unable to write file '{f}{s}': {s}", .{
|
||||
b.cache_root, sub_path, @errorName(err),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1482,7 +1482,7 @@ fn runCommand(
|
|||
.leading => mem.trimStart(u8, stream.bytes.?, &std.ascii.whitespace),
|
||||
.trailing => mem.trimEnd(u8, stream.bytes.?, &std.ascii.whitespace),
|
||||
};
|
||||
b.cache_root.handle.writeFile(.{ .sub_path = sub_path, .data = data }) catch |err| {
|
||||
b.cache_root.handle.writeFile(io, .{ .sub_path = sub_path, .data = data }) catch |err| {
|
||||
return step.fail("unable to write file '{f}{s}': {s}", .{
|
||||
b.cache_root, sub_path, @errorName(err),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
|
|||
}
|
||||
switch (output_source_file.contents) {
|
||||
.bytes => |bytes| {
|
||||
b.build_root.handle.writeFile(.{ .sub_path = output_source_file.sub_path, .data = bytes }) catch |err| {
|
||||
b.build_root.handle.writeFile(io, .{ .sub_path = output_source_file.sub_path, .data = bytes }) catch |err| {
|
||||
return step.fail("unable to write file '{f}{s}': {t}", .{
|
||||
b.build_root, output_source_file.sub_path, err,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void {
|
|||
}
|
||||
switch (file.contents) {
|
||||
.bytes => |bytes| {
|
||||
cache_dir.writeFile(.{ .sub_path = file.sub_path, .data = bytes }) catch |err| {
|
||||
cache_dir.writeFile(io, .{ .sub_path = file.sub_path, .data = bytes }) catch |err| {
|
||||
return step.fail("unable to write file '{f}{s}{c}{s}': {t}", .{
|
||||
b.cache_root, cache_path, fs.path.sep, file.sub_path, err,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -523,7 +523,7 @@ pub fn serveTarFile(ws: *WebServer, request: *http.Server.Request, paths: []cons
|
|||
if (cached_cwd_path == null) cached_cwd_path = try std.process.getCwdAlloc(gpa);
|
||||
break :cwd cached_cwd_path.?;
|
||||
};
|
||||
try archiver.writeFile(path.sub_path, &file_reader, @intCast(stat.mtime.toSeconds()));
|
||||
try archiver.writeFile(io, path.sub_path, &file_reader, @intCast(stat.mtime.toSeconds()));
|
||||
}
|
||||
|
||||
// intentionally not calling `archiver.finishPedantically`
|
||||
|
|
|
|||
|
|
@ -1243,7 +1243,7 @@ test printLineFromFile {
|
|||
{
|
||||
const path = try join(gpa, &.{ test_dir_path, "one_line.zig" });
|
||||
defer gpa.free(path);
|
||||
try test_dir.dir.writeFile(.{ .sub_path = "one_line.zig", .data = "no new lines in this file, but one is printed anyway" });
|
||||
try test_dir.dir.writeFile(io, .{ .sub_path = "one_line.zig", .data = "no new lines in this file, but one is printed anyway" });
|
||||
|
||||
try expectError(error.EndOfFile, printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
|
||||
|
||||
|
|
@ -1254,7 +1254,7 @@ test printLineFromFile {
|
|||
{
|
||||
const path = try fs.path.join(gpa, &.{ test_dir_path, "three_lines.zig" });
|
||||
defer gpa.free(path);
|
||||
try test_dir.dir.writeFile(.{
|
||||
try test_dir.dir.writeFile(io, .{
|
||||
.sub_path = "three_lines.zig",
|
||||
.data =
|
||||
\\1
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ test "Dir.readLink" {
|
|||
fn impl(ctx: *TestContext) !void {
|
||||
// Create some targets
|
||||
const file_target_path = try ctx.transformPath("file.txt");
|
||||
try ctx.dir.writeFile(.{ .sub_path = file_target_path, .data = "nonsense" });
|
||||
try ctx.dir.writeFile(io, .{ .sub_path = file_target_path, .data = "nonsense" });
|
||||
const dir_target_path = try ctx.transformPath("subdir");
|
||||
try ctx.dir.makeDir(dir_target_path);
|
||||
|
||||
|
|
@ -487,11 +487,13 @@ test "readLinkAbsolute" {
|
|||
if (native_os == .wasi) return error.SkipZigTest;
|
||||
if (native_os == .openbsd) return error.SkipZigTest;
|
||||
|
||||
const io = testing.io;
|
||||
|
||||
var tmp = tmpDir(.{});
|
||||
defer tmp.cleanup();
|
||||
|
||||
// Create some targets
|
||||
try tmp.dir.writeFile(.{ .sub_path = "file.txt", .data = "nonsense" });
|
||||
try tmp.dir.writeFile(io, .{ .sub_path = "file.txt", .data = "nonsense" });
|
||||
try tmp.dir.makeDir("subdir");
|
||||
|
||||
// Get base abs path
|
||||
|
|
@ -708,6 +710,7 @@ test "Dir.realpath smoke test" {
|
|||
|
||||
try testWithAllSupportedPathTypes(struct {
|
||||
fn impl(ctx: *TestContext) !void {
|
||||
const io = ctx.io;
|
||||
const allocator = ctx.arena.allocator();
|
||||
const test_file_path = try ctx.transformPath("test_file");
|
||||
const test_dir_path = try ctx.transformPath("test_dir");
|
||||
|
|
@ -720,7 +723,7 @@ test "Dir.realpath smoke test" {
|
|||
try testing.expectError(error.FileNotFound, ctx.dir.realpath(test_dir_path, &buf));
|
||||
|
||||
// Now create the file and dir
|
||||
try ctx.dir.writeFile(.{ .sub_path = test_file_path, .data = "" });
|
||||
try ctx.dir.writeFile(io, .{ .sub_path = test_file_path, .data = "" });
|
||||
try ctx.dir.makeDir(test_dir_path);
|
||||
|
||||
const base_path = try ctx.transformPath(".");
|
||||
|
|
@ -803,11 +806,12 @@ test "readFileAlloc" {
|
|||
test "Dir.statFile" {
|
||||
try testWithAllSupportedPathTypes(struct {
|
||||
fn impl(ctx: *TestContext) !void {
|
||||
const io = ctx.io;
|
||||
const test_file_name = try ctx.transformPath("test_file");
|
||||
|
||||
try testing.expectError(error.FileNotFound, ctx.dir.statFile(test_file_name));
|
||||
|
||||
try ctx.dir.writeFile(.{ .sub_path = test_file_name, .data = "" });
|
||||
try ctx.dir.writeFile(io, .{ .sub_path = test_file_name, .data = "" });
|
||||
|
||||
const stat = try ctx.dir.statFile(test_file_name);
|
||||
try testing.expectEqual(File.Kind.file, stat.kind);
|
||||
|
|
@ -925,6 +929,7 @@ test "makeOpenPath parent dirs do not exist" {
|
|||
test "deleteDir" {
|
||||
try testWithAllSupportedPathTypes(struct {
|
||||
fn impl(ctx: *TestContext) !void {
|
||||
const io = ctx.io;
|
||||
const test_dir_path = try ctx.transformPath("test_dir");
|
||||
const test_file_path = try ctx.transformPath("test_dir" ++ fs.path.sep_str ++ "test_file");
|
||||
|
||||
|
|
@ -933,7 +938,7 @@ test "deleteDir" {
|
|||
|
||||
// deleting a non-empty directory
|
||||
try ctx.dir.makeDir(test_dir_path);
|
||||
try ctx.dir.writeFile(.{ .sub_path = test_file_path, .data = "" });
|
||||
try ctx.dir.writeFile(io, .{ .sub_path = test_file_path, .data = "" });
|
||||
try testing.expectError(error.DirNotEmpty, ctx.dir.deleteDir(test_dir_path));
|
||||
|
||||
// deleting an empty directory
|
||||
|
|
@ -1217,7 +1222,7 @@ test "deleteTree on a symlink" {
|
|||
defer tmp.cleanup();
|
||||
|
||||
// Symlink to a file
|
||||
try tmp.dir.writeFile(.{ .sub_path = "file", .data = "" });
|
||||
try tmp.dir.writeFile(io, .{ .sub_path = "file", .data = "" });
|
||||
try setupSymlink(tmp.dir, "file", "filelink", .{});
|
||||
|
||||
try tmp.dir.deleteTree("filelink");
|
||||
|
|
@ -1241,11 +1246,11 @@ test "makePath, put some files in it, deleteTree" {
|
|||
const dir_path = try ctx.transformPath("os_test_tmp");
|
||||
|
||||
try ctx.dir.makePath(io, try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c" }));
|
||||
try ctx.dir.writeFile(.{
|
||||
try ctx.dir.writeFile(io, .{
|
||||
.sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }),
|
||||
.data = "nonsense",
|
||||
});
|
||||
try ctx.dir.writeFile(.{
|
||||
try ctx.dir.writeFile(io, .{
|
||||
.sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "file2.txt" }),
|
||||
.data = "blah",
|
||||
});
|
||||
|
|
@ -1264,11 +1269,11 @@ test "makePath, put some files in it, deleteTreeMinStackSize" {
|
|||
const dir_path = try ctx.transformPath("os_test_tmp");
|
||||
|
||||
try ctx.dir.makePath(io, try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c" }));
|
||||
try ctx.dir.writeFile(.{
|
||||
try ctx.dir.writeFile(io, .{
|
||||
.sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "c", "file.txt" }),
|
||||
.data = "nonsense",
|
||||
});
|
||||
try ctx.dir.writeFile(.{
|
||||
try ctx.dir.writeFile(io, .{
|
||||
.sub_path = try fs.path.join(allocator, &.{ "os_test_tmp", "b", "file2.txt" }),
|
||||
.data = "blah",
|
||||
});
|
||||
|
|
@ -1298,7 +1303,7 @@ test "makePath but sub_path contains pre-existing file" {
|
|||
defer tmp.cleanup();
|
||||
|
||||
try tmp.dir.makeDir("foo");
|
||||
try tmp.dir.writeFile(.{ .sub_path = "foo/bar", .data = "" });
|
||||
try tmp.dir.writeFile(io, .{ .sub_path = "foo/bar", .data = "" });
|
||||
|
||||
try testing.expectError(error.NotDir, tmp.dir.makePath(io, "foo/bar/baz"));
|
||||
}
|
||||
|
|
@ -1400,7 +1405,7 @@ fn testFilenameLimits(io: Io, iterable_dir: Dir, maxed_filename: []const u8) !vo
|
|||
var maxed_dir = try iterable_dir.makeOpenPath(maxed_filename, .{});
|
||||
defer maxed_dir.close(io);
|
||||
|
||||
try maxed_dir.writeFile(.{ .sub_path = maxed_filename, .data = "" });
|
||||
try maxed_dir.writeFile(io, .{ .sub_path = maxed_filename, .data = "" });
|
||||
|
||||
var walker = try iterable_dir.walk(testing.allocator);
|
||||
defer walker.deinit();
|
||||
|
|
@ -1513,7 +1518,7 @@ test "setEndPos" {
|
|||
defer tmp.cleanup();
|
||||
|
||||
const file_name = "afile.txt";
|
||||
try tmp.dir.writeFile(.{ .sub_path = file_name, .data = "ninebytes" });
|
||||
try tmp.dir.writeFile(io, .{ .sub_path = file_name, .data = "ninebytes" });
|
||||
const f = try tmp.dir.openFile(io, file_name, .{ .mode = .read_write });
|
||||
defer f.close(io);
|
||||
|
||||
|
|
@ -1563,7 +1568,7 @@ test "access file" {
|
|||
try ctx.dir.makePath(io, dir_path);
|
||||
try testing.expectError(error.FileNotFound, ctx.dir.access(io, file_path, .{}));
|
||||
|
||||
try ctx.dir.writeFile(.{ .sub_path = file_path, .data = "" });
|
||||
try ctx.dir.writeFile(io, .{ .sub_path = file_path, .data = "" });
|
||||
try ctx.dir.access(io, file_path, .{});
|
||||
try ctx.dir.deleteTree(dir_path);
|
||||
}
|
||||
|
|
@ -1659,12 +1664,13 @@ test "sendfile with buffered data" {
|
|||
test "copyFile" {
|
||||
try testWithAllSupportedPathTypes(struct {
|
||||
fn impl(ctx: *TestContext) !void {
|
||||
const io = ctx.io;
|
||||
const data = "u6wj+JmdF3qHsFPE BUlH2g4gJCmEz0PP";
|
||||
const src_file = try ctx.transformPath("tmp_test_copy_file.txt");
|
||||
const dest_file = try ctx.transformPath("tmp_test_copy_file2.txt");
|
||||
const dest_file2 = try ctx.transformPath("tmp_test_copy_file3.txt");
|
||||
|
||||
try ctx.dir.writeFile(.{ .sub_path = src_file, .data = data });
|
||||
try ctx.dir.writeFile(io, .{ .sub_path = src_file, .data = data });
|
||||
defer ctx.dir.deleteFile(src_file) catch {};
|
||||
|
||||
try ctx.dir.copyFile(src_file, ctx.dir, dest_file, .{});
|
||||
|
|
@ -2050,7 +2056,7 @@ test "'.' and '..' in Io.Dir functions" {
|
|||
renamed_file.close(io);
|
||||
try ctx.dir.deleteFile(rename_path);
|
||||
|
||||
try ctx.dir.writeFile(.{ .sub_path = update_path, .data = "something" });
|
||||
try ctx.dir.writeFile(io, .{ .sub_path = update_path, .data = "something" });
|
||||
var dir = ctx.dir;
|
||||
const prev_status = try dir.updateFile(io, file_path, dir, update_path, .{});
|
||||
try testing.expectEqual(Io.Dir.PrevStatus.stale, prev_status);
|
||||
|
|
@ -2187,7 +2193,7 @@ test "invalid UTF-8/WTF-8 paths" {
|
|||
try testing.expectError(expected_err, ctx.dir.deleteTree(invalid_path));
|
||||
try testing.expectError(expected_err, ctx.dir.deleteTreeMinStackSize(invalid_path));
|
||||
|
||||
try testing.expectError(expected_err, ctx.dir.writeFile(.{ .sub_path = invalid_path, .data = "" }));
|
||||
try testing.expectError(expected_err, ctx.dir.writeFile(io, .{ .sub_path = invalid_path, .data = "" }));
|
||||
|
||||
try testing.expectError(expected_err, ctx.dir.access(invalid_path, .{}));
|
||||
|
||||
|
|
@ -2304,7 +2310,7 @@ test "seekBy" {
|
|||
var tmp_dir = testing.tmpDir(.{});
|
||||
defer tmp_dir.cleanup();
|
||||
|
||||
try tmp_dir.dir.writeFile(.{ .sub_path = "blah.txt", .data = "let's test seekBy" });
|
||||
try tmp_dir.dir.writeFile(io, .{ .sub_path = "blah.txt", .data = "let's test seekBy" });
|
||||
const f = try tmp_dir.dir.openFile(io, "blah.txt", .{ .mode = .read_only });
|
||||
defer f.close(io);
|
||||
var reader = f.readerStreaming(io, &.{});
|
||||
|
|
@ -2350,7 +2356,7 @@ test "File.Writer sendfile with buffered contents" {
|
|||
defer tmp_dir.cleanup();
|
||||
|
||||
{
|
||||
try tmp_dir.dir.writeFile(.{ .sub_path = "a", .data = "bcd" });
|
||||
try tmp_dir.dir.writeFile(io, .{ .sub_path = "a", .data = "bcd" });
|
||||
const in = try tmp_dir.dir.openFile(io, "a", .{});
|
||||
defer in.close(io);
|
||||
const out = try tmp_dir.dir.createFile(io, "b", .{});
|
||||
|
|
@ -2391,11 +2397,13 @@ fn testReadlink(target_path: []const u8, symlink_path: []const u8) !void {
|
|||
}
|
||||
|
||||
test "readlinkat" {
|
||||
const io = testing.io;
|
||||
|
||||
var tmp = tmpDir(.{});
|
||||
defer tmp.cleanup();
|
||||
|
||||
// create file
|
||||
try tmp.dir.writeFile(.{ .sub_path = "file.txt", .data = "nonsense" });
|
||||
try tmp.dir.writeFile(io, .{ .sub_path = "file.txt", .data = "nonsense" });
|
||||
|
||||
// create a symbolic link
|
||||
if (native_os == .windows) {
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ test "linkat with different directories" {
|
|||
const subdir = try tmp.dir.makeOpenPath("subdir", .{});
|
||||
|
||||
defer tmp.dir.deleteFile(target_name) catch {};
|
||||
try tmp.dir.writeFile(.{ .sub_path = target_name, .data = "example" });
|
||||
try tmp.dir.writeFile(io, .{ .sub_path = target_name, .data = "example" });
|
||||
|
||||
// Test 1: link from file in subdir back up to target in parent directory
|
||||
try posix.linkat(tmp.dir.handle, target_name, subdir.handle, link_name, 0);
|
||||
|
|
|
|||
|
|
@ -5715,7 +5715,7 @@ pub fn translateC(
|
|||
const out_h_sub_path = tmp_sub_path ++ fs.path.sep_str ++ cimport_basename;
|
||||
const out_h_path = try comp.dirs.local_cache.join(arena, &.{out_h_sub_path});
|
||||
if (comp.verbose_cimport) log.info("writing C import source to {s}", .{out_h_path});
|
||||
try cache_dir.writeFile(.{ .sub_path = out_h_sub_path, .data = c_src });
|
||||
try cache_dir.writeFile(io, .{ .sub_path = out_h_sub_path, .data = c_src });
|
||||
break :path out_h_path;
|
||||
},
|
||||
.path => |p| p,
|
||||
|
|
@ -6572,7 +6572,7 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
|
|||
resource_id, resource_type, fmtRcEscape(src_path),
|
||||
});
|
||||
|
||||
try o_dir.writeFile(.{ .sub_path = rc_basename, .data = input });
|
||||
try o_dir.writeFile(io, .{ .sub_path = rc_basename, .data = input });
|
||||
|
||||
var argv = std.array_list.Managed([]const u8).init(comp.gpa);
|
||||
defer argv.deinit();
|
||||
|
|
|
|||
|
|
@ -520,7 +520,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
|
|||
for (metadata.all_versions[0 .. target_ver_index + 1]) |ver| {
|
||||
try map_contents.print("FBSD_{d}.{d} {{ }};\n", .{ ver.major, ver.minor });
|
||||
}
|
||||
try o_directory.handle.writeFile(.{ .sub_path = all_map_basename, .data = map_contents.items });
|
||||
try o_directory.handle.writeFile(io, .{ .sub_path = all_map_basename, .data = map_contents.items });
|
||||
map_contents.deinit();
|
||||
}
|
||||
|
||||
|
|
@ -974,7 +974,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
|
|||
|
||||
var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "stdthreads", etc.
|
||||
const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
|
||||
try o_directory.handle.writeFile(.{ .sub_path = asm_file_basename, .data = stubs_asm.items });
|
||||
try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items });
|
||||
try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -759,7 +759,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
|
|||
try map_contents.print("GLIBC_{d}.{d}.{d} {{ }};\n", .{ ver.major, ver.minor, ver.patch });
|
||||
}
|
||||
}
|
||||
try o_directory.handle.writeFile(.{ .sub_path = all_map_basename, .data = map_contents.items });
|
||||
try o_directory.handle.writeFile(io, .{ .sub_path = all_map_basename, .data = map_contents.items });
|
||||
map_contents.deinit(); // The most recent allocation of an arena can be freed :)
|
||||
}
|
||||
|
||||
|
|
@ -1118,7 +1118,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
|
|||
|
||||
var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.
|
||||
const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
|
||||
try o_directory.handle.writeFile(.{ .sub_path = asm_file_basename, .data = stubs_asm.items });
|
||||
try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items });
|
||||
try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -628,7 +628,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye
|
|||
|
||||
var lib_name_buf: [32]u8 = undefined; // Larger than each of the names "c", "pthread", etc.
|
||||
const asm_file_basename = std.fmt.bufPrint(&lib_name_buf, "{s}.s", .{lib.name}) catch unreachable;
|
||||
try o_directory.handle.writeFile(.{ .sub_path = asm_file_basename, .data = stubs_asm.items });
|
||||
try o_directory.handle.writeFile(io, .{ .sub_path = asm_file_basename, .data = stubs_asm.items });
|
||||
try buildSharedLib(comp, arena, o_directory, asm_file_basename, lib, prog_node);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7164,7 +7164,7 @@ fn cmdFetch(
|
|||
try ast.render(gpa, &aw.writer, fixups);
|
||||
const rendered = aw.written();
|
||||
|
||||
build_root.directory.handle.writeFile(.{ .sub_path = Package.Manifest.basename, .data = rendered }) catch |err| {
|
||||
build_root.directory.handle.writeFile(io, .{ .sub_path = Package.Manifest.basename, .data = rendered }) catch |err| {
|
||||
fatal("unable to write {s} file: {t}", .{ Package.Manifest.basename, err });
|
||||
};
|
||||
|
||||
|
|
@ -7207,7 +7207,7 @@ fn createDependenciesModule(
|
|||
{
|
||||
var tmp_dir = try dirs.local_cache.handle.makeOpenPath(tmp_dir_sub_path, .{});
|
||||
defer tmp_dir.close(io);
|
||||
try tmp_dir.writeFile(.{ .sub_path = basename, .data = source });
|
||||
try tmp_dir.writeFile(io, .{ .sub_path = basename, .data = source });
|
||||
}
|
||||
|
||||
var hh: Cache.HashHelper = .{};
|
||||
|
|
@ -7438,7 +7438,7 @@ const Templates = struct {
|
|||
i += 1;
|
||||
}
|
||||
|
||||
return out_dir.writeFile(.{
|
||||
return out_dir.writeFile(io, .{
|
||||
.sub_path = template_path,
|
||||
.data = templates.buffer.items,
|
||||
.flags = .{ .exclusive = true },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue