You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
593 B
20 lines
593 B
use std::path::Path;
|
|
use tempfile::{Builder, TempDir};
|
|
|
|
pub fn prepare_workspace(exe_name: &str) -> anyhow::Result<TempDir> {
|
|
let prefix = format!("wasi_common_{}", exe_name);
|
|
let tempdir = Builder::new().prefix(&prefix).tempdir()?;
|
|
Ok(tempdir)
|
|
}
|
|
|
|
pub fn extract_exec_name_from_path(path: &Path) -> anyhow::Result<String> {
|
|
path.file_stem()
|
|
.and_then(|s| s.to_str())
|
|
.map(String::from)
|
|
.ok_or_else(|| {
|
|
anyhow::anyhow!(
|
|
"couldn't extract the file stem from path {}",
|
|
path.display()
|
|
)
|
|
})
|
|
}
|
|
|