Replace more miscellaenous read_wasm utilities with wat::parse_file. (#601)

This commit is contained in:
Dan Gohman
2019-11-19 07:34:17 -08:00
committed by Alex Crichton
parent 7d7360b32d
commit 58dd4c6c88
4 changed files with 4 additions and 22 deletions

View File

@@ -1,16 +1,6 @@
use std::fs;
use std::path::Path;
use tempfile::{Builder, TempDir};
pub fn read_wasm(path: &Path) -> anyhow::Result<Vec<u8>> {
let data = fs::read(path)?;
if data.starts_with(&[b'\0', b'a', b's', b'm']) {
Ok(data)
} else {
anyhow::bail!("Invalid Wasm file encountered")
}
}
pub fn prepare_workspace(exe_name: &str) -> anyhow::Result<TempDir> {
let prefix = format!("wasi_common_{}", exe_name);
let tempdir = Builder::new().prefix(&prefix).tempdir()?;