CiderPress II

DOS 3.2/3.3

The Apple II Disk Operating System (DOS) filesystem stores files as a series of 256-byte sectors, with one of eight file types. Some aspects of the filesystem require special handling.

Files with types I (Integer BASIC), A (Applesoft BASIC), and B (binary data) have a 16-bit file length stored at the start of the file. In most cases the length is only used to tell how much of the last sector is actually used, but through various means it's possible to extend or truncate the length to be very different. For example, some programs were distributed as type B with a short "fast loader" program at the start. The DOS BRUN command would stop at the embedded length, which only spanned the loader; the loader would then load the rest of the file into memory.

File with type T (text) can be sequential or random-access. Sequential text files end when the first $00 is encountered, but random-access text files can be filled with zeroes. DOS provides different mechanisms for reading these files, but no way to distinguish them from each other.

The remaining file types — S, R, AA, BB — are simply defined by the list of sectors allocated to the file. Such files are thus always a multiple of 256 bytes long.

When viewing or extracting files from a DOS disk, it's necessary to specify whether the file should be accessed in "normal" or "raw" mode. In "normal" mode, the length of T/I/A/B files is determined by examining their headers or, for text files, scanning the entire file for the first $00. In "raw" mode, the file type is ignored, and files are always handled as a collection of sectors.

One situation where accessing a file in raw mode is necessary is when viewing random-access text files. These are files of type T with fixed-length records. In the file viewer, you need to enable "raw" mode, and specify a length. (The length can be determined by examining the BASIC program that reads the file, or by trying to guess the interval from the hex dump.)

DOS file types are converted to ProDOS equivalents in certain situations, e.g. when extracting files with preservation enabled. The conversion map is: