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
impl Disk
sourcepub fn from_img(
img: Box<dyn DiskImage>,
dpb: DiskParameterBlock,
cpm_vers: [u8; 3]
) -> Self
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.
Trait Implementations§
source§impl DiskFS for Disk
impl DiskFS for Disk
source§fn new_fimg(&self, chunk_len: usize) -> FileImage
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>>
fn catalog_to_stdout(&mut self, _path: &str) -> Result<(), Box<dyn Error>>
List all the files on disk to standard output, mirrors
CATALOGfn unlock(&mut self, xname: &str) -> Result<(), Box<dyn Error>>
source§fn rename(
&mut self,
old_xname: &str,
new_xname: &str
) -> Result<(), Box<dyn Error>>
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>>
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>>
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>>
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
BSAVEsource§fn load(&mut self, _name: &str) -> Result<(u16, Vec<u8>), Box<dyn Error>>
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 = 0source§fn save(
&mut self,
_name: &str,
_dat: &[u8],
_typ: ItemType,
_trailing: Option<&[u8]>
) -> Result<usize, Box<dyn Error>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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>>
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.
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> 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