pub struct Disk { /* private fields */ }Expand description
The primary interface for disk operations. The “Disk Parameter Block” that is provided upon creation should be in correspondence with DRI specifications.
Implementations§
Source§impl Disk
impl Disk
Sourcepub fn from_img(
img: Box<dyn DiskImage>,
dpb: DiskParameterBlock,
cpm_vers: [u8; 3],
) -> Result<Self, Box<dyn Error>>
pub fn from_img( img: Box<dyn DiskImage>, dpb: DiskParameterBlock, cpm_vers: [u8; 3], ) -> Result<Self, Box<dyn Error>>
Create a disk file system using the given image as storage. The DiskFS takes ownership of the image and DPB.
Sourcepub fn test_img(
img: &mut Box<dyn DiskImage>,
dpb: &DiskParameterBlock,
cpm_vers: [u8; 3],
) -> bool
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, changes method to Auto.
Usually called before user parameters are applied.
Will not accept images with directory structures corresponding to CP/M versions higher than cpm_vers.
Sourcepub fn format(
&mut self,
vol_name: &str,
time: Option<NaiveDateTime>,
) -> Result<(), Box<dyn Error>>
pub fn format( &mut self, vol_name: &str, time: Option<NaiveDateTime>, ) -> Result<(), Box<dyn Error>>
Format disk for the CP/M file system. If CP/M version is 2.x, arguments are ignored. If CP/M version is 3.x:
vol_name.len()>0causes creation of a label with the specified nametime.is_some()causes creation of a label (maybe default name) and timestamps
Trait Implementations§
Source§impl DiskFS for Disk
impl DiskFS for Disk
Source§fn 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.Source§fn catalog_to_stdout(&mut self, opt: &str) -> Result<(), Box<dyn Error>>
fn catalog_to_stdout(&mut self, opt: &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>>
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>>
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>>
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 set_attrib(
&mut self,
xname: &str,
permissions: Attributes,
maybe_password: Option<&str>,
) -> Result<(), Box<dyn Error>>
fn set_attrib( &mut self, xname: &str, permissions: Attributes, maybe_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 areSource§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 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
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 get(&mut self, xname: &str) -> Result<FileImage, Box<dyn Error>>
fn get(&mut self, xname: &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>>
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>>
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>>)
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 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)
Source§fn 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)
Source§fn 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)
Source§fn 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)
Source§fn 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)
Source§fn 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)
Source§fn 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)
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> 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