1 use crate::error::IoResultExt;
2 use crate::TempDir;
3 use std::io;
4 use std::path::PathBuf;
5 
create( path: PathBuf, permissions: Option<&std::fs::Permissions>, keep: bool, ) -> io::Result<TempDir>6 pub fn create(
7     path: PathBuf,
8     permissions: Option<&std::fs::Permissions>,
9     keep: bool,
10 ) -> io::Result<TempDir> {
11     let mut dir_options = std::fs::DirBuilder::new();
12     #[cfg(not(target_os = "wasi"))]
13     {
14         use std::os::unix::fs::{DirBuilderExt, PermissionsExt};
15         if let Some(p) = permissions {
16             dir_options.mode(p.mode());
17         }
18     }
19     dir_options
20         .create(&path)
21         .with_err_path(|| &path)
22         .map(|_| TempDir {
23             path: path.into_boxed_path(),
24             keep,
25         })
26 }
27