AffsReader

Struct AffsReader 

Source
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>

Source

pub fn new(device: &'a D) -> Result<Self, AffsError>

Create a new AFFS reader for a standard DD floppy (880KB).

Source

pub fn new_hd(device: &'a D) -> Result<Self, AffsError>

Create a new AFFS reader for an HD floppy (1.76MB).

Source

pub fn with_size(device: &'a D, total_blocks: u32) -> Result<Self, AffsError>

Create a new AFFS reader with a specific block count.

Source

pub const fn fs_type(&self) -> FsType

Get the filesystem type (OFS or FFS).

Source

pub const fn fs_flags(&self) -> FsFlags

Get filesystem flags.

Source

pub const fn is_intl(&self) -> bool

Check if international mode is enabled.

Source

pub const fn root_block(&self) -> u32

Get the root block number.

Source

pub const fn total_blocks(&self) -> u32

Get the total number of blocks.

Source

pub fn disk_name(&self) -> &[u8]

Get the disk name as bytes.

Source

pub fn disk_name_str(&self) -> Option<&str>

Get the disk name as a string (if valid UTF-8).

Source

pub const fn bitmap_valid(&self) -> bool

Check if the bitmap is valid.

Source

pub fn root_hash_table(&self) -> &[u32; 72]

Get the root directory hash table.

Source

pub const fn device(&self) -> &'a D

Get a reference to the block device.

Source

pub fn read_root_dir(&self) -> DirIter<'_, D>

Iterate over entries in the root directory.

Source

pub fn read_dir(&self, block: u32) -> Result<DirIter<'_, D>, AffsError>

Iterate over entries in a directory.

§Arguments
  • block - Block number of the directory entry
Source

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 directory
  • name - Name to search for
Source

pub fn find_path(&self, path: &[u8]) -> Result<DirEntry, AffsError>

Find an entry by path from the root.

Path components are separated by ‘/’.

Source

pub fn read_file(&self, block: u32) -> Result<FileReader<'_, D>, AffsError>

Read a file’s contents.

§Arguments
  • block - Block number of the file header
Source

pub fn read_entry(&self, block: u32) -> Result<EntryBlock, AffsError>

Read an entry block.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.