use sc::syscall;
use crate::platform::{Fd, Mode, AT_FDCWD};
use crate::string::unix_str::UnixStr;
use crate::Result;
#[inline]
pub fn mkdir(path: &UnixStr, mode: Mode) -> Result<()> {
do_mkdir(AT_FDCWD, path, mode)
}
pub fn mkdir_at(dir_fd: Fd, path: &UnixStr, mode: Mode) -> Result<()> {
do_mkdir(dir_fd.0, path, mode)
}
#[inline(always)]
#[expect(clippy::inline_always)]
fn do_mkdir(dir_fd: i32, path: &UnixStr, mode: Mode) -> Result<()> {
let res = unsafe { syscall!(MKDIRAT, dir_fd, path.as_ptr(), mode.bits()) };
bail_on_below_zero!(res, "`MKDIRAT` syscall failed");
Ok(())
}