DiskFS

Trait DiskFS 

Source
pub trait DiskFS {
Show 27 methods // Required methods fn new_fimg( &self, chunk_len: Option<usize>, set_time: bool, path: &str, ) -> Result<FileImage, Box<dyn Error>>; fn stat(&mut self) -> Result<Stat, Box<dyn Error>>; fn catalog_to_stdout(&mut self, path: &str) -> Result<(), Box<dyn Error>>; fn catalog_to_vec( &mut self, path: &str, ) -> Result<Vec<String>, Box<dyn Error>>; fn glob( &mut self, pattern: &str, case_sensitive: bool, ) -> Result<Vec<String>, Box<dyn Error>>; fn tree( &mut self, include_meta: bool, indent: Option<u16>, ) -> Result<String, Box<dyn Error>>; fn create(&mut self, path: &str) -> Result<(), Box<dyn Error>>; fn delete(&mut self, path: &str) -> Result<(), Box<dyn Error>>; fn rename(&mut self, path: &str, name: &str) -> Result<(), Box<dyn Error>>; fn set_attrib( &mut self, path: &str, attrib: Attributes, password: Option<&str>, ) -> Result<(), Box<dyn Error>>; fn retype( &mut self, path: &str, new_type: &str, sub_type: &str, ) -> Result<(), Box<dyn Error>>; fn get(&mut self, path: &str) -> Result<FileImage, Box<dyn Error>>; fn put(&mut self, fimg: &FileImage) -> Result<usize, Box<dyn Error>>; fn read_block(&mut self, num: &str) -> Result<Vec<u8>, Box<dyn Error>>; fn write_block( &mut self, num: &str, dat: &[u8], ) -> Result<usize, Box<dyn Error>>; fn standardize(&mut self, ref_con: u16) -> HashMap<Block, Vec<usize>>; fn compare(&mut self, path: &Path, ignore: &HashMap<Block, Vec<usize>>); fn get_img(&mut self) -> &mut Box<dyn DiskImage>; // Provided methods fn put_at( &mut self, path: &str, fimg: &mut FileImage, ) -> Result<usize, Box<dyn Error>> { ... } fn bload(&mut self, path: &str) -> Result<(usize, Vec<u8>), Box<dyn Error>> { ... } fn bsave( &mut self, path: &str, dat: &[u8], load_addr: Option<usize>, trailing: Option<&[u8]>, ) -> Result<usize, Box<dyn Error>> { ... } fn load(&mut self, path: &str) -> Result<(usize, Vec<u8>), Box<dyn Error>> { ... } fn save( &mut self, path: &str, dat: &[u8], lang: ItemType, trailing: Option<&[u8]>, ) -> Result<usize, Box<dyn Error>> { ... } fn read_text(&mut self, path: &str) -> Result<String, Box<dyn Error>> { ... } fn write_text( &mut self, path: &str, txt: &str, ) -> Result<usize, Box<dyn Error>> { ... } fn read_records( &mut self, path: &str, rec_len: Option<usize>, ) -> Result<Records, Box<dyn Error>> { ... } fn write_records( &mut self, path: &str, recs: &Records, ) -> Result<usize, Box<dyn Error>> { ... }
}
Expand description

Abstract file system interface. Presumed to own an underlying DiskImage. Handles files, blocks, and directory structures. Files are loaded or saved by passing file images. File images are manipulated using the Packing trait.

Required Methods§

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: &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 rename(&mut self, path: &str, name: &str) -> Result<(), Box<dyn Error>>

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

Provided Methods§

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)

Implementors§

Source§

impl DiskFS for a2kit::fs::cpm::Disk

Source§

impl DiskFS for a2kit::fs::dos3x::Disk

Source§

impl DiskFS for a2kit::fs::fat::Disk

Source§

impl DiskFS for a2kit::fs::pascal::Disk

Source§

impl DiskFS for a2kit::fs::prodos::Disk