pub struct Controller<D, T>{ /* private fields */ }
Expand description
A Controller
wraps a block device and gives access to the volumes within it.
Implementations§
Source§impl<D, T> Controller<D, T>
impl<D, T> Controller<D, T>
Sourcepub fn new(block_device: D, timesource: T) -> Controller<D, T>
pub fn new(block_device: D, timesource: T) -> Controller<D, T>
Create a new Disk Controller using a generic BlockDevice
. From this
controller we can open volumes (partitions) and with those we can open
files.
Sourcepub fn get_volume(
&mut self,
volume_idx: VolumeIdx,
) -> Result<Volume, Error<D::Error>>
pub fn get_volume( &mut self, volume_idx: VolumeIdx, ) -> Result<Volume, Error<D::Error>>
Get a volume (or partition) based on entries in the Master Boot Record. We do not support GUID Partition Table disks. Nor do we support any concept of drive letters - that is for a higher layer to handle.
Sourcepub fn open_root_dir(
&mut self,
volume: &Volume,
) -> Result<Directory, Error<D::Error>>
pub fn open_root_dir( &mut self, volume: &Volume, ) -> Result<Directory, Error<D::Error>>
Open a directory. You can then read the directory entries in a random
order using get_directory_entry
.
TODO: Work out how to prevent damage occuring to the file system while this directory handle is open. In particular, stop this directory being unlinked.
Sourcepub fn open_dir(
&mut self,
volume: &Volume,
parent_dir: &Directory,
name: &str,
) -> Result<Directory, Error<D::Error>>
pub fn open_dir( &mut self, volume: &Volume, parent_dir: &Directory, name: &str, ) -> Result<Directory, Error<D::Error>>
Open a directory. You can then read the directory entries in a random
order using get_directory_entry
.
TODO: Work out how to prevent damage occuring to the file system while this directory handle is open. In particular, stop this directory being unlinked.
Sourcepub fn close_dir(&mut self, volume: &Volume, dir: Directory)
pub fn close_dir(&mut self, volume: &Volume, dir: Directory)
Close a directory. You cannot perform operations on an open directory and so must close it if you want to do something with it.
Sourcepub fn find_directory_entry(
&mut self,
volume: &Volume,
dir: &Directory,
name: &str,
) -> Result<DirEntry, Error<D::Error>>
pub fn find_directory_entry( &mut self, volume: &Volume, dir: &Directory, name: &str, ) -> Result<DirEntry, Error<D::Error>>
Look in a directory for a named file.
Sourcepub fn iterate_dir<F>(
&mut self,
volume: &Volume,
dir: &Directory,
func: F,
) -> Result<(), Error<D::Error>>
pub fn iterate_dir<F>( &mut self, volume: &Volume, dir: &Directory, func: F, ) -> Result<(), Error<D::Error>>
Call a callback function for each directory entry in a directory.
Sourcepub fn open_file_in_dir(
&mut self,
volume: &mut Volume,
dir: &Directory,
name: &str,
mode: Mode,
) -> Result<File, Error<D::Error>>
pub fn open_file_in_dir( &mut self, volume: &mut Volume, dir: &Directory, name: &str, mode: Mode, ) -> Result<File, Error<D::Error>>
Open a file with the given full path. A file can only be opened once.
Sourcepub fn read(
&mut self,
volume: &Volume,
file: &mut File,
buffer: &mut [u8],
) -> Result<usize, Error<D::Error>>
pub fn read( &mut self, volume: &Volume, file: &mut File, buffer: &mut [u8], ) -> Result<usize, Error<D::Error>>
Read from an open file.