use crate::handle::HandleRights;
use crate::sys::sys_impl::oshandle::RawOsHandle;
use crate::Result;
use std::cell::{Cell, RefCell, RefMut};
use std::io;
use yanix::dir::Dir;
#[derive(Debug)]
pub struct OsDir {
pub(crate) rights: Cell<HandleRights>,
pub(crate) handle: RawOsHandle,
stream_ptr: RefCell<Dir>,
}
impl OsDir {
pub(crate) fn new(rights: HandleRights, handle: RawOsHandle) -> io::Result<Self> {
let rights = Cell::new(rights);
let stream_ptr = Dir::from(handle.try_clone()?)?;
let stream_ptr = RefCell::new(stream_ptr);
Ok(Self {
rights,
handle,
stream_ptr,
})
}
pub(crate) fn stream_ptr(&self) -> Result<RefMut<Dir>> {
Ok(self.stream_ptr.borrow_mut())
}
}