Replace more miscellaenous read_wasm utilities with wat::parse_file. (#601)
This commit is contained in:
committed by
Alex Crichton
parent
7d7360b32d
commit
58dd4c6c88
@@ -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()?;
|
||||
|
||||
Reference in New Issue
Block a user