Disk

Struct Disk 

Source
pub struct Disk { /* private fields */ }
Expand description

The primary interface for disk operations.

Implementations§

Source§

impl Disk

Source

pub fn from_img( img: Box<dyn DiskImage>, maybe_boot: Option<BootSector>, ) -> Result<Self, Box<dyn Error>>

Create a disk file system using the given image as storage. The DiskFS takes ownership of the image. If maybe_boot is None, the FAT boot sector is buffered from the image. If maybe_boot is Some, the provided boot sector is buffered and written to the image. If disk layout matches a 160K or 180K disk, the BPB foundation is overwritten with hard coded values, but only in the buffer, i.e., without affecting the boot sector on the image.

Source

pub fn from_img_dos1x(img: Box<dyn DiskImage>) -> Result<Self, Box<dyn Error>>

Create an MS-DOS 1.0 file system using the given image as storage. The DiskFS takes ownership of the image.

Source

pub fn test_img(img: &mut Box<dyn DiskImage>) -> bool

Test an image for the FAT file system.

Source

pub fn test_img_dos1x(img: &mut Box<dyn DiskImage>) -> bool

Test an image for DOS 1.x (no signature, no BPB)

Source

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

Format a disk with the FAT file system, by this point the boot sector is presumed to be buffered, and must at least contain a valid BPB foundation. If there is a BPB tail it is overwritten.

Trait Implementations§

Source§

impl DiskFS for Disk

Source§

fn new_fimg( &self, chunk_len: Option<usize>, set_time: bool, path: &str, ) -> Result<FileImage, Box<dyn Error>>

Create an empty file image appropriate for this file system. To use the block size of this specific disk set chunk_len to None.
Source§

fn stat(&mut self) -> Result<Stat, Box<dyn Error>>

Stat the file system
Source§

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

Directory listing to standard output in the file system’s native style
Source§

fn catalog_to_vec(&mut self, path: &str) -> Result<Vec<String>, Box<dyn Error>>

Get directory listing as a Vec. The rows are in an easily parsed fixed column format that is the same for all file systems. Columns 0..4 are the type/extension, 5..10 are the block count, 12.. is the basename. For flat file systems, the path must be “” or “/”, or else an error is returned. For any file system, if the path resolves to a file, an error is returned.
Source§

fn glob( &mut self, pattern: &str, case_sensitive: bool, ) -> Result<Vec<String>, Box<dyn Error>>

Return vector of paths based on the glob pattern
Source§

fn tree( &mut self, include_meta: bool, indent: Option<u16>, ) -> Result<String, Box<dyn Error>>

Get the file system tree as a JSON string
Source§

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

Create a new directory
Source§

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

Delete a file or directory
Source§

fn set_attrib( &mut self, path: &str, attrib: Attributes, _password: Option<&str>, ) -> Result<(), Box<dyn Error>>

Set permissions or other attributes for the given path, flags that are not Some will be left as they are
Source§

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

Rename a file or directory
Source§

fn retype( &mut self, path: &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 read_block(&mut self, num: &str) -> Result<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 get(&mut self, path: &str) -> Result<FileImage, Box<dyn Error>>

Get file image from the path within this disk image.
Source§

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

Write file image to this disk image at the path stored in fimg.
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
Source§

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

Convenience function to set path and put (default method)
Source§

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

Convenience function to get (load_addr,binary_data) (default method)
Source§

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

Convenience function to save binary file (default method)
Source§

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

Convenience function to get (load_addr,tokens) (default method)
Source§

fn save( &mut self, path: &str, dat: &[u8], lang: ItemType, trailing: Option<&[u8]>, ) -> Result<usize, Box<dyn Error>>

Convenience function to save tokens (default method)
Source§

fn read_text(&mut self, path: &str) -> Result<String, Box<dyn Error>>

Convenience function to load text (default method)
Source§

fn write_text(&mut self, path: &str, txt: &str) -> Result<usize, Box<dyn Error>>

Convenience function to save text (default method)
Source§

fn read_records( &mut self, path: &str, rec_len: Option<usize>, ) -> Result<Records, Box<dyn Error>>

Convenience function to load records (default method)
Source§

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

Convenience function to save records (default method)

Auto Trait Implementations§

§

impl Freeze for Disk

§

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

impl<T> ErasedDestructor for T
where T: 'static,