ntfs_reader/
test_utils.rs1use std::path::{Path, PathBuf};
2
3pub const TEST_VOLUME_LETTER: &str = "R";
5
6pub struct TempDirGuard(pub PathBuf);
7
8impl TempDirGuard {
9 pub fn new<P: AsRef<Path>>(path: P) -> std::io::Result<Self> {
10 let p = path.as_ref().to_path_buf();
11 let _ = std::fs::remove_dir_all(&p);
12 std::fs::create_dir_all(&p)?;
13 Ok(TempDirGuard(p))
14 }
15
16 pub fn path(&self) -> &Path {
17 &self.0
18 }
19}
20
21impl Drop for TempDirGuard {
22 fn drop(&mut self) {
23 let _ = std::fs::remove_dir_all(&self.0);
24 }
25}