pub struct AffsReader<'a, D: BlockDevice> { /* private fields */ }Expand description
Main AFFS filesystem reader.
Provides read-only access to an AFFS/OFS filesystem image.
§Example
ⓘ
use affs_read::{AffsReader, BlockDevice};
struct MyDevice { data: Vec<u8> }
impl BlockDevice for MyDevice {
fn read_block(&self, block: u32, buf: &mut [u8; 512]) -> Result<(), ()> {
let offset = block as usize * 512;
buf.copy_from_slice(&self.data[offset..offset + 512]);
Ok(())
}
}
let device = MyDevice { data: adf_data };
let reader = AffsReader::new(&device)?;
// Get disk info
println!("Disk: {:?}", reader.disk_name());
println!("Type: {:?}", reader.fs_type());
// List root directory
for entry in reader.read_dir(reader.root_block())? {
let entry = entry?;
println!("{:?}: {} bytes", entry.name(), entry.size);
}Implementations§
Source§impl<'a, D: BlockDevice> AffsReader<'a, D>
impl<'a, D: BlockDevice> AffsReader<'a, D>
Sourcepub fn new(device: &'a D) -> Result<Self, AffsError>
pub fn new(device: &'a D) -> Result<Self, AffsError>
Create a new AFFS reader for a standard DD floppy (880KB).
Sourcepub fn new_hd(device: &'a D) -> Result<Self, AffsError>
pub fn new_hd(device: &'a D) -> Result<Self, AffsError>
Create a new AFFS reader for an HD floppy (1.76MB).
Sourcepub fn with_size(device: &'a D, total_blocks: u32) -> Result<Self, AffsError>
pub fn with_size(device: &'a D, total_blocks: u32) -> Result<Self, AffsError>
Create a new AFFS reader with a specific block count.
Sourcepub const fn root_block(&self) -> u32
pub const fn root_block(&self) -> u32
Get the root block number.
Sourcepub const fn total_blocks(&self) -> u32
pub const fn total_blocks(&self) -> u32
Get the total number of blocks.
Sourcepub fn disk_name_str(&self) -> Option<&str>
pub fn disk_name_str(&self) -> Option<&str>
Get the disk name as a string (if valid UTF-8).
Sourcepub const fn bitmap_valid(&self) -> bool
pub const fn bitmap_valid(&self) -> bool
Check if the bitmap is valid.
Sourcepub fn root_hash_table(&self) -> &[u32; 72]
pub fn root_hash_table(&self) -> &[u32; 72]
Get the root directory hash table.
Sourcepub fn read_root_dir(&self) -> DirIter<'_, D> ⓘ
pub fn read_root_dir(&self) -> DirIter<'_, D> ⓘ
Iterate over entries in the root directory.
Sourcepub fn find_entry(
&self,
dir_block: u32,
name: &[u8],
) -> Result<DirEntry, AffsError>
pub fn find_entry( &self, dir_block: u32, name: &[u8], ) -> Result<DirEntry, AffsError>
Find an entry by name in a directory.
§Arguments
dir_block- Block number of the directoryname- Name to search for
Sourcepub fn find_path(&self, path: &[u8]) -> Result<DirEntry, AffsError>
pub fn find_path(&self, path: &[u8]) -> Result<DirEntry, AffsError>
Find an entry by path from the root.
Path components are separated by ‘/’.
Sourcepub fn read_entry(&self, block: u32) -> Result<EntryBlock, AffsError>
pub fn read_entry(&self, block: u32) -> Result<EntryBlock, AffsError>
Read an entry block.
Sourcepub fn root_entry(&self) -> DirEntry
pub fn root_entry(&self) -> DirEntry
Get a DirEntry for the root directory.
Auto Trait Implementations§
impl<'a, D> Freeze for AffsReader<'a, D>
impl<'a, D> RefUnwindSafe for AffsReader<'a, D>where
D: RefUnwindSafe,
impl<'a, D> Send for AffsReader<'a, D>where
D: Sync,
impl<'a, D> Sync for AffsReader<'a, D>where
D: Sync,
impl<'a, D> Unpin for AffsReader<'a, D>
impl<'a, D> UnwindSafe for AffsReader<'a, D>where
D: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more