[Coco] Are the files in the /dd/SYS directory always ASCII ?
Bill Pierce
ooogalapasooo at aol.com
Fri Sep 25 07:57:38 EDT 2020
FWIW, you can "sorta" ID OS-9 files by looking at the file descriptor and the file header.
In the file descriptor (the first 32 bytes in the sector pointed to by the last 3 bytes of the 32 byte directory entry, which is also followed by the FAT for the file), you'll find the file attributes (which can distinguish if it's executable or read/write only and also flag directory entries), file creation date, file last modified date, calculate file size, and determine the owner of the file.
The header can identify the file type as "Program/Object", "P-Code" (pascal), "I-Code" (basic09), "C-Code" (never seen this used in Coco OS-9), and "Data" (rare), as well as the version/revision. The file ID bytes at the beginning (first 2 bytes of any file) of the header can help as well. If the first 2 bytes are "$87 $CD", then it is some sort of executable module. If they are "62 $CD", then the file is an ROF (relocatable object file) for use in compiling C code (it can also be a C library file which is nothing but a merged ROF). There may be other OS-9 defined ID bytes, but those are the only 2 I've seen used in Coco OS-9. Basically, if the 2nd byte is NOT $CD, then it is most likely a text file or raw binary data file.
There are a few utilities out there (with sources) that can access this info (ident, id, attr, vfy, verify, etc.).
Bob Devries wrote a nice utility to read the file descriptor "fileinfo", in which the C source explains how to read the file descriptor.
I used these sources (and more) to help write my file identification routines in my MShell project.
Bill
More information about the Coco
mailing list