| ... | ... | @@ -162,6 +162,16 @@ pub fn main() anyerror!void { |
| 162 | 162 | return mainArgs(gpa_tracy.allocator(), arena, args); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | // WASI: `--dir` instructs the WASM runtime to "preopen" a directory, making |
| 166 | // it available to the us, the guest program. This is the only way for us to |
| 167 | // access files/dirs on the host filesystem |
| 168 | if (builtin.os.tag == .wasi) { |
| 169 | // This sets our CWD to "/preopens/cwd" |
| 170 | // Dot-prefixed preopens like `--dir=.` are "mounted" at "/preopens/cwd" |
| 171 | // Other preopens like `--dir=lib` are "mounted" at "/" |
| 172 | try std.os.initPreopensWasi(std.heap.page_allocator, "/preopens/cwd"); |
| 173 | } |
| 174 | |
| 165 | 175 | return mainArgs(gpa, arena, args); |
| 166 | 176 | } |
| 167 | 177 | |