From 12056885eb28b4226c04c29ab433010326745f05 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 21 Jan 2021 16:08:49 -0800 Subject: [PATCH] fix preopen dir to work on windows --- crates/test-programs/tests/wasm_tests/runtime.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/test-programs/tests/wasm_tests/runtime.rs b/crates/test-programs/tests/wasm_tests/runtime.rs index 8ceaddcc5a..22b063f091 100644 --- a/crates/test-programs/tests/wasm_tests/runtime.rs +++ b/crates/test-programs/tests/wasm_tests/runtime.rs @@ -1,5 +1,4 @@ use anyhow::Context; -use std::fs::File; use std::path::Path; use wasi_c2::pipe::{ReadPipe, WritePipe}; use wasi_c2_cap_std_sync::WasiCtxBuilder; @@ -25,9 +24,7 @@ pub fn instantiate(data: &[u8], bin_name: &str, workspace: Option<&Path>) -> any if let Some(workspace) = workspace { println!("preopen: {:?}", workspace); - let dirfd = - File::open(workspace).context(format!("error while preopening {:?}", workspace))?; - let preopen_dir = unsafe { cap_std::fs::Dir::from_std_file(dirfd) }; + let preopen_dir = unsafe { cap_std::fs::Dir::open_ambient_dir(workspace) }?; builder = builder.preopened_dir(preopen_dir, ".")?; }