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§
Sourcefn new_fimg(
&self,
chunk_len: Option<usize>,
set_time: bool,
path: &str,
) -> Result<FileImage, Box<dyn Error>>
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.
Sourcefn catalog_to_stdout(&mut self, path: &str) -> Result<(), Box<dyn Error>>
fn catalog_to_stdout(&mut self, path: &str) -> Result<(), Box<dyn Error>>
Directory listing to standard output in the file system’s native style
Sourcefn catalog_to_vec(&mut self, path: &str) -> Result<Vec<String>, Box<dyn Error>>
fn catalog_to_vec(&mut self, path: &str) -> Result<Vec<String>, Box<dyn Error>>
Get directory listing as a Vec
Sourcefn glob(
&mut self,
pattern: &str,
case_sensitive: bool,
) -> Result<Vec<String>, Box<dyn Error>>
fn glob( &mut self, pattern: &str, case_sensitive: bool, ) -> Result<Vec<String>, Box<dyn Error>>
Return vector of paths based on the glob pattern
Sourcefn tree(
&mut self,
include_meta: bool,
indent: Option<u16>,
) -> Result<String, Box<dyn Error>>
fn tree( &mut self, include_meta: bool, indent: Option<u16>, ) -> Result<String, Box<dyn Error>>
Get the file system tree as a JSON string
Sourcefn rename(&mut self, path: &str, name: &str) -> Result<(), Box<dyn Error>>
fn rename(&mut self, path: &str, name: &str) -> Result<(), Box<dyn Error>>
Rename a file or directory
Sourcefn set_attrib(
&mut self,
path: &str,
attrib: Attributes,
password: Option<&str>,
) -> Result<(), Box<dyn Error>>
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
Sourcefn retype(
&mut self,
path: &str,
new_type: &str,
sub_type: &str,
) -> Result<(), Box<dyn Error>>
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.
Sourcefn get(&mut self, path: &str) -> Result<FileImage, Box<dyn Error>>
fn get(&mut self, path: &str) -> Result<FileImage, Box<dyn Error>>
Get file image from the path within this disk image.
Sourcefn put(&mut self, fimg: &FileImage) -> Result<usize, Box<dyn Error>>
fn put(&mut self, fimg: &FileImage) -> Result<usize, Box<dyn Error>>
Write file image to this disk image at the path stored in fimg.
Sourcefn read_block(&mut self, num: &str) -> Result<Vec<u8>, Box<dyn Error>>
fn read_block(&mut self, num: &str) -> Result<Vec<u8>, Box<dyn Error>>
Get a native file system allocation unit
Sourcefn 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.
Sourcefn 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.
Provided Methods§
Sourcefn put_at(
&mut self,
path: &str,
fimg: &mut FileImage,
) -> Result<usize, Box<dyn Error>>
fn put_at( &mut self, path: &str, fimg: &mut FileImage, ) -> Result<usize, Box<dyn Error>>
Convenience function to set path and put (default method)
Sourcefn bload(&mut self, path: &str) -> Result<(usize, Vec<u8>), Box<dyn Error>>
fn bload(&mut self, path: &str) -> Result<(usize, Vec<u8>), Box<dyn Error>>
Convenience function to get (load_addr,binary_data) (default method)
Sourcefn bsave(
&mut self,
path: &str,
dat: &[u8],
load_addr: Option<usize>,
trailing: Option<&[u8]>,
) -> Result<usize, Box<dyn Error>>
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)
Sourcefn load(&mut self, path: &str) -> Result<(usize, Vec<u8>), Box<dyn Error>>
fn load(&mut self, path: &str) -> Result<(usize, Vec<u8>), Box<dyn Error>>
Convenience function to get (load_addr,tokens) (default method)
Sourcefn save(
&mut self,
path: &str,
dat: &[u8],
lang: ItemType,
trailing: Option<&[u8]>,
) -> Result<usize, Box<dyn Error>>
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)
Sourcefn read_text(&mut self, path: &str) -> Result<String, Box<dyn Error>>
fn read_text(&mut self, path: &str) -> Result<String, Box<dyn Error>>
Convenience function to load text (default method)
Sourcefn write_text(&mut self, path: &str, txt: &str) -> Result<usize, Box<dyn Error>>
fn write_text(&mut self, path: &str, txt: &str) -> Result<usize, Box<dyn Error>>
Convenience function to save text (default method)