use std::{
fs,
path::PathBuf,
sync::atomic::{AtomicU64, Ordering},
};
static SEQUENCE: AtomicU64 = AtomicU64::new(0);
pub struct Fixture {
pub root: PathBuf,
}
impl Fixture {
pub fn new() -> Self {
let root = std::env::temp_dir().join(format!(
"ic-host-fs-test-{}-{}",
std::process::id(),
SEQUENCE.fetch_add(1, Ordering::Relaxed)
));
fs::create_dir(&root).unwrap();
Self {
root: root.canonicalize().unwrap(),
}
}
}
impl Drop for Fixture {
fn drop(&mut self) {
let _ = fs::remove_dir_all(&self.root);
}
}