pub struct Directory<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize>where
D: BlockDevice,
T: TimeSource,{ /* private fields */ }
Expand description
A handle for an open directory on disk, which closes on drop.
In contrast to a RawDirectory
, a Directory
holds a mutable reference to
its parent VolumeManager
, which restricts which operations you can perform.
If you drop a value of this type, it closes the directory automatically, but
any error that may occur will be ignored. To handle potential errors, use
the Directory::close
method.
Implementations§
Source§impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>where
D: BlockDevice,
T: TimeSource,
impl<'a, D, T, const MAX_DIRS: usize, const MAX_FILES: usize, const MAX_VOLUMES: usize> Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>where
D: BlockDevice,
T: TimeSource,
Sourcepub fn new(
raw_directory: RawDirectory,
volume_mgr: &'a mut VolumeManager<D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>,
) -> Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
pub fn new( raw_directory: RawDirectory, volume_mgr: &'a mut VolumeManager<D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>, ) -> Directory<'a, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>
Create a new Directory
from a RawDirectory
Sourcepub fn open_dir<N>(
&mut self,
name: N,
) -> Result<Directory<'_, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>, Error<D::Error>>where
N: ToShortFileName,
pub fn open_dir<N>(
&mut self,
name: N,
) -> Result<Directory<'_, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>, Error<D::Error>>where
N: ToShortFileName,
Open a directory.
You can then read the directory entries with iterate_dir
and open_file_in_dir
.
Sourcepub fn change_dir<N>(&mut self, name: N) -> Result<(), Error<D::Error>>where
N: ToShortFileName,
pub fn change_dir<N>(&mut self, name: N) -> Result<(), Error<D::Error>>where
N: ToShortFileName,
Change to a directory, mutating this object.
You can then read the directory entries with iterate_dir
and open_file_in_dir
.
Sourcepub fn find_directory_entry<N>(
&mut self,
name: N,
) -> Result<DirEntry, Error<D::Error>>where
N: ToShortFileName,
pub fn find_directory_entry<N>(
&mut self,
name: N,
) -> Result<DirEntry, Error<D::Error>>where
N: ToShortFileName,
Look in a directory for a named file.
Sourcepub fn iterate_dir<F>(&mut self, func: F) -> Result<(), Error<D::Error>>
pub fn iterate_dir<F>(&mut self, func: F) -> Result<(), Error<D::Error>>
Call a callback function for each directory entry in a directory.
Sourcepub fn open_file_in_dir<N>(
&mut self,
name: N,
mode: Mode,
) -> Result<File<'_, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>, Error<D::Error>>where
N: ToShortFileName,
pub fn open_file_in_dir<N>(
&mut self,
name: N,
mode: Mode,
) -> Result<File<'_, D, T, MAX_DIRS, MAX_FILES, MAX_VOLUMES>, Error<D::Error>>where
N: ToShortFileName,
Open a file with the given full path. A file can only be opened once.
Sourcepub fn delete_file_in_dir<N>(&mut self, name: N) -> Result<(), Error<D::Error>>where
N: ToShortFileName,
pub fn delete_file_in_dir<N>(&mut self, name: N) -> Result<(), Error<D::Error>>where
N: ToShortFileName,
Delete a closed file with the given filename, if it exists.
Sourcepub fn make_dir_in_dir<N>(&mut self, name: N) -> Result<(), Error<D::Error>>where
N: ToShortFileName,
pub fn make_dir_in_dir<N>(&mut self, name: N) -> Result<(), Error<D::Error>>where
N: ToShortFileName,
Make a directory inside this directory
Sourcepub fn to_raw_directory(self) -> RawDirectory
pub fn to_raw_directory(self) -> RawDirectory
Convert back to a raw directory
Sourcepub fn close(self) -> Result<(), Error<D::Error>>
pub fn close(self) -> Result<(), Error<D::Error>>
Consume the Directory
handle and close it. The behavior of this is similar
to using core::mem::drop
or letting the Directory
go out of scope,
except this lets the user handle any errors that may occur in the process,
whereas when using drop, any errors will be discarded silently.