Module a2kit::fs

source ·
Expand description

File System Module

File system modules handle interactions with directories and files. There is a sub-module for each supported file system.

File systems are represented by the DiskFS trait. The trait object takes ownership of some disk image, which it uses as storage. Files are represented by a FileImage trait object. This is a low level representation of the file that works for any of the supported file systems.

This module also contains the Block enumeration, which specifies and locates allocation units. The enumeration names the file system’s allocation system, and its value is a specific block. The value can take any form, e.g., DOS blocks are 2-element lists with [track,sector], whereas CPM blocks are 3-tuples with (block,BSH,OFF).

Sector skews are not handled here. Transformation of a Block to a physical disk address is handled within the img module. Transformations that go between a file system and a disk, such as sector skews, are kept in the bios module.

Modules

  • CP/M file system module
  • DOS 3.x file system module
  • Pascal file system module
  • ProDOS file system module

Structs

  • This is an abstraction of a sparse file and its metadata. Sequential files are a special case. Metadata items are represented by a Vec that contains the same byte ordering that is stored on disk. In the JSON representation these become hex strings. The DiskFS is responsible for further interpretation. The data itself is stored in a map with a numerical chunk id as the key, and a Vec as the chunk data. The JSON representation uses decimal strings for the key and hex strings for the data. Beware of sorting routines that put “10” before “9”.
  • This is an abstraction used in handling random access text files. Text encoding at this level is UTF8, it may be translated at lower levels. This will usually be translated into FileImage for lower level handling.

Enums

  • Encapsulates the disk address and addressing mode used by a file system. Disk addresses generally involve some transformation between logical (file system) and physical (disk fields) addresses. The disk image layer has the final responsibility for making this transformation. The Block implementation includes a simple mapping from blocks to sectors; disk images can use this or not as appropriate. Disk images can also decide whether to immediately return an error given certain block types; e.g., a PO image might refuse to locate a DO block type. However, do not get confused, e.g., a DO image should usually be prepared to process a PO block, since there are many ProDOS DSK images that are DOS ordered.
  • Enumerates file system errors. The Display trait will print equivalent long message.

Traits

  • Abstract file system interface. Presumed to own an underlying DiskImage. Provides BASIC-like high level commands, block operations, and file image operations.
  • This converts between UTF8+LF/CRLF and the encoding used by the file system

Functions