aboutsummaryrefslogtreecommitdiff
path: root/src-self-hosted
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-07-25 23:34:57 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-07-30 13:44:36 -0400
commita870228ab467906ecc663bf89ecd042b49e116f5 (patch)
tree9a584d415178434c7eecc38f7b1b3161774d351f /src-self-hosted
parentcc4552733351390aecab9ae900beb822237d6041 (diff)
downloadzig-a870228ab467906ecc663bf89ecd042b49e116f5.tar.gz
zig-a870228ab467906ecc663bf89ecd042b49e116f5.zip
self-hosted: use std.event.fs.readFile
Diffstat (limited to 'src-self-hosted')
-rw-r--r--src-self-hosted/compilation.zig10
1 files changed, 8 insertions, 2 deletions
diff --git a/src-self-hosted/compilation.zig b/src-self-hosted/compilation.zig
index 5ff8b1a858..e7b2131cd6 100644
--- a/src-self-hosted/compilation.zig
+++ b/src-self-hosted/compilation.zig
@@ -30,6 +30,9 @@ const Package = @import("package.zig").Package;
const link = @import("link.zig").link;
const LibCInstallation = @import("libc_installation.zig").LibCInstallation;
const CInt = @import("c_int.zig").CInt;
+const fs = event.fs;
+
+const max_src_size = 2 * 1024 * 1024 * 1024; // 2 GiB
/// Data that is local to the event loop.
pub const EventLoopLocal = struct {
@@ -757,8 +760,11 @@ pub const Compilation = struct {
const root_scope = blk: {
errdefer self.gpa().free(root_src_real_path);
- // TODO async/await readFileAlloc()
- const source_code = io.readFileAlloc(self.gpa(), root_src_real_path) catch |err| {
+ const source_code = (await (async fs.readFile(
+ self.loop,
+ root_src_real_path,
+ max_src_size,
+ ) catch unreachable)) catch |err| {
try printError("unable to open '{}': {}", root_src_real_path, err);
return err;
};