aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormlarouche <michael.larouche@gmail.com>2020-10-09 16:50:43 -0400
committermlarouche <michael.larouche@gmail.com>2020-10-09 16:50:43 -0400
commit57912964af0247a7aa940f76d09a8994d8fe1ec8 (patch)
tree89d818f19130c03b55926d4b6beb927be9bc85c2 /lib
parent04b0ffdd13e32be0ef5cc84983f8bb830db7520f (diff)
downloadzig-57912964af0247a7aa940f76d09a8994d8fe1ec8.tar.gz
zig-57912964af0247a7aa940f76d09a8994d8fe1ec8.zip
Use regular file for caching stage 1 hash digest instead of symlink, fix zig build caching on Windows
Fix #6500
Diffstat (limited to 'lib')
-rw-r--r--lib/std/fs.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/std/fs.zig b/lib/std/fs.zig
index 5e440ec900..bebc954746 100644
--- a/lib/std/fs.zig
+++ b/lib/std/fs.zig
@@ -1490,6 +1490,15 @@ pub const Dir = struct {
return os.windows.ReadLink(self.fd, sub_path_w, buffer);
}
+ /// Read all of file contents using a preallocated buffer
+ pub fn readFile(self: Dir, file_path: []const u8, buffer: []u8) ![]u8 {
+ var file = try self.openFile(file_path, .{});
+ defer file.close();
+
+ const end_index = try file.readAll(buffer);
+ return buffer[0..end_index];
+ }
+
/// On success, caller owns returned buffer.
/// If the file is larger than `max_bytes`, returns `error.FileTooBig`.
pub fn readFileAlloc(self: Dir, allocator: *mem.Allocator, file_path: []const u8, max_bytes: usize) ![]u8 {