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 fn label(&self) -> &[u8] ⓘ
pub fn label(&self) -> &[u8] ⓘ
Get the volume label (alias for disk_name).
This matches GRUB’s grub_affs_label() behavior.
Sourcepub fn label_str(&self) -> Option<&str>
pub fn label_str(&self) -> Option<&str>
Get the volume label as string (alias for disk_name_str).
Sourcepub fn creation_date(&self) -> AmigaDate
pub fn creation_date(&self) -> AmigaDate
Get the volume creation date.
Sourcepub fn last_modified(&self) -> AmigaDate
pub fn last_modified(&self) -> AmigaDate
Get the volume last modification date.
Sourcepub fn mtime(&self) -> i64
pub fn mtime(&self) -> i64
Get the volume modification time as Unix timestamp.
This matches GRUB’s grub_affs_mtime() behavior:
- days * 86400 + min * 60 + hz / 50 + epoch offset
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 read_symlink(
&self,
block: u32,
out: &mut [u8],
) -> Result<usize, AffsError>
pub fn read_symlink( &self, block: u32, out: &mut [u8], ) -> Result<usize, AffsError>
Read a symlink target.
§Arguments
block- Block number of the symlink entryout- Buffer to write the UTF-8 symlink target into
§Returns
The number of bytes written to out.
§Notes
- The symlink target is stored as Latin1 and converted to UTF-8
- Leading
:(Amiga volume reference) is replaced with/ - The output buffer should be at least
MAX_SYMLINK_LEN * 2bytes to handle worst-case Latin1 to UTF-8 expansion
Sourcepub fn read_symlink_entry(
&self,
entry: &DirEntry,
out: &mut [u8],
) -> Result<usize, AffsError>
pub fn read_symlink_entry( &self, entry: &DirEntry, out: &mut [u8], ) -> Result<usize, AffsError>
Read a symlink target from a DirEntry.
Convenience method that takes a DirEntry instead of a block number.
Sourcepub fn root_entry(&self) -> DirEntry
pub fn root_entry(&self) -> DirEntry
Get a DirEntry for the root directory.