pub struct Directory(pub Arc<dyn Directory>);Expand description
A handle to a directory.
This struct represents a reference-counted directory that supports file entry management, including opening and removing entries.
Tuple Fields§
§0: Arc<dyn Directory>Implementations§
Source§impl Directory
impl Directory
Sourcepub fn ino(&self) -> InodeNumber
pub fn ino(&self) -> InodeNumber
Inode number of the directory.
Sourcepub fn link_count(&self) -> usize
pub fn link_count(&self) -> usize
Link count of the directory.
Sourcepub fn new(r: impl Directory + 'static) -> Self
pub fn new(r: impl Directory + 'static) -> Self
Creates a new Directory handle from a given implementation of
traits::Directory.
This function takes an instance of any type that implements the
traits::Directory trait, wraps it in a reference-counted
[Arc], and returns a Directory handle.
§Parameters
r: An instance of a type that implementstraits::Directory.
§Returns
A Directory handle that enables reference-counted access to the
underlying file.
Sourcepub fn open(&self, path: &str) -> Result<File, KernelError>
pub fn open(&self, path: &str) -> Result<File, KernelError>
Sourcepub fn create(&self, path: &str, is_dir: bool) -> Result<File, KernelError>
pub fn create(&self, path: &str, is_dir: bool) -> Result<File, KernelError>
Sourcepub fn unlink(&self, path: &str) -> Result<(), KernelError>
pub fn unlink(&self, path: &str) -> Result<(), KernelError>
Sourcepub fn read_dir(&self) -> Result<Vec<(InodeNumber, String)>, KernelError>
pub fn read_dir(&self) -> Result<Vec<(InodeNumber, String)>, KernelError>
Reads the contents of the directory.
This function lists all the entries within the directory.
§Returns
Ok(()): If the directory was successfully read.Err(Error): An error if the read operation fails.
Sourcepub fn removed(&self) -> Result<&AtomicBool, KernelError>
pub fn removed(&self) -> Result<&AtomicBool, KernelError>
Returns AtomicBool which contains whether directory is removed.
This is important because directory operations against the removed directory will result in undesirable behavior (e.g. unreachable file).
§Returns
Ok(()): If the directory was successfully read.Err(Error): An error if the operation fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Directory
impl !RefUnwindSafe for Directory
impl Send for Directory
impl Sync for Directory
impl Unpin for Directory
impl !UnwindSafe for Directory
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)