cap_primitives/rustix/fs/
create_dir_unchecked.rs

1use crate::fs::DirOptions;
2use rustix::fs::{mkdirat, Mode, RawMode};
3use std::path::Path;
4use std::{fs, io};
5
6/// *Unsandboxed* function similar to `create_dir`, but which does not perform
7/// sandboxing.
8pub(crate) fn create_dir_unchecked(
9    start: &fs::File,
10    path: &Path,
11    options: &DirOptions,
12) -> io::Result<()> {
13    #[cfg(not(target_os = "wasi"))]
14    let raw_mode = options.ext.mode as RawMode;
15    #[cfg(target_os = "wasi")]
16    let raw_mode = 0;
17
18    Ok(mkdirat(start, path, Mode::from_bits(raw_mode).unwrap())?)
19}