diff --git a/Cargo.toml b/Cargo.toml index 90202005d1..750b8e7f92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ wasmtime-jit = { path = "wasmtime-jit" } wasmtime-obj = { path = "wasmtime-obj" } wasmtime-wast = { path = "wasmtime-wast" } wasmtime-wasi = { path = "wasmtime-wasi" } +wasi-common = { git = "https://github.com/CraneStation/wasi-common" } docopt = "1.0.1" serde = "1.0.75" serde_derive = "1.0.75" @@ -45,9 +46,6 @@ errno = "0.2.4" [target.'cfg(unix)'.dependencies] wasmtime-wasi-c = { path = "wasmtime-wasi-c" } -[target.'cfg(windows)'.dependencies] -winapi = "0.3" - [workspace] [features] diff --git a/src/wasmtime.rs b/src/wasmtime.rs index 3994da6059..4f897bd094 100644 --- a/src/wasmtime.rs +++ b/src/wasmtime.rs @@ -48,6 +48,7 @@ use std::path::Component; use std::path::{Path, PathBuf}; use std::process::exit; use wabt; +use wasi_common::preopen_dir; use wasmtime_jit::{ActionOutcome, Context}; use wasmtime_wasi::instantiate_wasi; use wasmtime_wast::instantiate_spectest; @@ -118,33 +119,6 @@ fn read_wasm(path: PathBuf) -> Result, String> { }) } -fn preopen_dir>(path: P) -> io::Result { - #[cfg(windows)] - { - use std::fs::OpenOptions; - use std::os::windows::fs::OpenOptionsExt; - use winapi::um::winbase::FILE_FLAG_BACKUP_SEMANTICS; - - // To open a directory using CreateFile2, specify the - // FILE_FLAG_BACKUP_SEMANTICS flag as part of dwFileFlags... - // cf. https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfile2 - OpenOptions::new() - .create(false) - .write(true) - .read(true) - .attributes(FILE_FLAG_BACKUP_SEMANTICS) - .open(path) - } - #[cfg(unix)] - { - File::open(path) - } - #[cfg(not(any(windows, unix)))] - { - unimplemented!("this OS is currently not supported by Wasmtime") - } -} - fn compute_preopen_dirs(flag_dir: &[String], flag_mapdir: &[String]) -> Vec<(String, File)> { let mut preopen_dirs = Vec::new();