stree 0.1.0

A directory hierarchy mapping format, similar to mtree
Documentation
use std::mem::MaybeUninit;
use std::path::Path;
use crate::{Result, Error, Time};
use pathstr::PathStr;

pub(crate) fn btime<P>(p: P) -> Result<Time>
where P: AsRef<Path>
{
    let path = PathStr::from(p.as_ref());
    let cpath = path.cstring()?;
    let mut buffer = unsafe { MaybeUninit::<libc::statx>::zeroed().assume_init() };
    unsafe
    {
        if libc::statx(
            libc::AT_FDCWD,
            cpath.as_ptr(),
            libc::AT_SYMLINK_NOFOLLOW,
            libc::STATX_BTIME,
            &mut buffer
        ) == -1
        {
            return Err(Error::io(std::io::Error::last_os_error()))
        }
    }
    Ok(Time { seconds: buffer.stx_btime.tv_sec as u64, nanos: buffer.stx_btime.tv_nsec as u64 })
}