diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-07-25 23:34:57 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-07-30 13:44:36 -0400 |
| commit | a870228ab467906ecc663bf89ecd042b49e116f5 (patch) | |
| tree | 9a584d415178434c7eecc38f7b1b3161774d351f /src-self-hosted | |
| parent | cc4552733351390aecab9ae900beb822237d6041 (diff) | |
| download | zig-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.zig | 10 |
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; }; |
