Struct a2kit::fs::cpm::Disk

source ·
pub struct Disk { /* private fields */ }
Expand description

The primary interface for disk operations. The “Disk Parameter Block” that is provided upon creation is in correspondence with what would be stored in BIOS.

Implementations§

source§

impl Disk

source

pub fn from_img( img: Box<dyn DiskImage>, dpb: DiskParameterBlock, cpm_vers: [u8; 3] ) -> Self

Create a disk file system using the given image as storage. The DiskFS takes ownership of the image and DPB.

source

pub fn test_img( img: &mut Box<dyn DiskImage>, dpb: &DiskParameterBlock, cpm_vers: [u8; 3] ) -> bool

Test an image for the CP/M file system.

source

pub fn format( &mut self, vol_name: &str, _time: Option<NaiveDateTime> ) -> Result<(), Box<dyn Error>>

Format disk for the CP/M file system. The time argument is currently ignored, because we are not using the disk label extent.

Trait Implementations§

source§

impl DiskFS for Disk

source§

fn new_fimg(&self, chunk_len: usize) -> FileImage

Create an empty file image appropriate for this file system
source§

fn catalog_to_stdout(&mut self, _path: &str) -> Result<(), Box<dyn Error>>

List all the files on disk to standard output, mirrors CATALOG
source§

fn create(&mut self, _path: &str) -> Result<(), Box<dyn Error>>

Create a new directory
source§

fn delete(&mut self, xname: &str) -> Result<(), Box<dyn Error>>

Delete a file or directory
source§

fn lock(&mut self, xname: &str) -> Result<(), Box<dyn Error>>

write protect a file
source§

fn unlock(&mut self, xname: &str) -> Result<(), Box<dyn Error>>

source§

fn rename( &mut self, old_xname: &str, new_xname: &str ) -> Result<(), Box<dyn Error>>

Rename a file or directory
source§

fn retype( &mut self, xname: &str, new_type: &str, _sub_type: &str ) -> Result<(), Box<dyn Error>>

Change the type and subtype of a file, strings may contain numbers as appropriate.
source§

fn bload(&mut self, xname: &str) -> Result<(u16, Vec<u8>), Box<dyn Error>>

Read a binary file from the disk, mirrors BLOAD. Returns (aux,data), aux = starting address.
source§

fn bsave( &mut self, xname: &str, dat: &[u8], _start_addr: u16, trailing: Option<&[u8]> ) -> Result<usize, Box<dyn Error>>

Write a binary file to the disk, mirrors BSAVE
source§

fn load(&mut self, _name: &str) -> Result<(u16, Vec<u8>), Box<dyn Error>>

Read a BASIC program file from the disk, mirrors LOAD, program is in tokenized form. Detokenization is handled in a different module. Returns (aux,data), aux = 0
source§

fn save( &mut self, _name: &str, _dat: &[u8], _typ: ItemType, _trailing: Option<&[u8]> ) -> Result<usize, Box<dyn Error>>

Write a BASIC program to the disk, mirrors SAVE, program must already be tokenized. Tokenization is handled in a different module.
source§

fn read_text(&mut self, xname: &str) -> Result<(u16, Vec<u8>), Box<dyn Error>>

Read sequential text file from the disk, mirrors READ, text remains in raw A2 format. Use decode_text to get a UTF8 string. Returns (aux,data), aux = 0.
source§

fn write_text( &mut self, xname: &str, dat: &[u8] ) -> Result<usize, Box<dyn Error>>

Write sequential text file to the disk, mirrors WRITE, text must already be in A2 format. Use encode_text to generate data from a UTF8 string.
source§

fn read_records( &mut self, _name: &str, _record_length: usize ) -> Result<Records, Box<dyn Error>>

Read records from a random access text file. This finds all possible records, some may be spurious. The record_length can be set to 0 on file systems where this is stored with the file.
source§

fn write_records( &mut self, _name: &str, _records: &Records ) -> Result<usize, Box<dyn Error>>

Write records to a random access text file
source§

fn read_block(&mut self, num: &str) -> Result<(u16, Vec<u8>), Box<dyn Error>>

Get a native file system allocation unit
source§

fn write_block( &mut self, num: &str, dat: &[u8] ) -> Result<usize, Box<dyn Error>>

Put a native file system allocation unit N.b. this simply zaps the block and can break the file system.
source§

fn read_any(&mut self, xname: &str) -> Result<FileImage, Box<dyn Error>>

Read a file into a generalized representation
source§

fn write_any( &mut self, xname: &str, fimg: &FileImage ) -> Result<usize, Box<dyn Error>>

Write a file from a generalized representation
source§

fn decode_text(&self, dat: &[u8]) -> Result<String, Box<dyn Error>>

Convert file system text to a UTF8 string
source§

fn encode_text(&self, s: &str) -> Result<Vec<u8>, Box<dyn Error>>

Convert UTF8 string to file system text
source§

fn standardize(&mut self, _ref_con: u16) -> HashMap<Block, Vec<usize>>

Standardize for comparison with other sources of disk images. Returns a map from blocks to offsets within the block that are to be zeroed or ignored. Typically it is important to call this before deletions happen. May be recursive, ref_con can be used to initialize each recursion.
source§

fn compare(&mut self, path: &Path, ignore: &HashMap<Block, Vec<usize>>)

Compare this disk with a reference disk for testing purposes. Panics if comparison fails.
source§

fn get_img(&mut self) -> &mut Box<dyn DiskImage>

Mutably borrow the underlying disk image

Auto Trait Implementations§

§

impl !RefUnwindSafe for Disk

§

impl !Send for Disk

§

impl !Sync for Disk

§

impl Unpin for Disk

§

impl !UnwindSafe for Disk

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.