mirror of
https://github.com/ziglang/zig.git
synced 2024-11-17 01:23:54 +00:00
stage2: Initialize WASI preopens on startup
This commit is contained in:
parent
089651716c
commit
692ccd01b4
10
src/main.zig
10
src/main.zig
@ -162,6 +162,16 @@ pub fn main() anyerror!void {
|
||||
return mainArgs(gpa_tracy.allocator(), arena, args);
|
||||
}
|
||||
|
||||
// WASI: `--dir` instructs the WASM runtime to "preopen" a directory, making
|
||||
// it available to the us, the guest program. This is the only way for us to
|
||||
// access files/dirs on the host filesystem
|
||||
if (builtin.os.tag == .wasi) {
|
||||
// This sets our CWD to "/preopens/cwd"
|
||||
// Dot-prefixed preopens like `--dir=.` are "mounted" at "/preopens/cwd"
|
||||
// Other preopens like `--dir=lib` are "mounted" at "/"
|
||||
try std.os.initPreopensWasi(std.heap.page_allocator, "/preopens/cwd");
|
||||
}
|
||||
|
||||
return mainArgs(gpa, arena, args);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user