diff --git a/doc/apple2.sgml b/doc/apple2.sgml index 3089a04c4..fe5c98767 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -511,6 +511,104 @@ url="ca65.html" name="assembler manual">.

+Specifying ProDOS File Types

+ + + + Problem Explanation + + ProDOS associates a file type and an auxiliary type with each file. + These type specifications are separate from the file's name, unlike + Windows and UNIX-like systems which use the file name's suffix (a.k.a. + extension) to specify the file type. For example, .exe, .doc, or .bat. + The ProDOS low-level + Machine-Language Interface (MLI) functions for creating and opening + files require these types to be specified. And if they don't match + with the file being opened, the operation may fail. + + In contrast, the ISO C function Solution + + There are two global variables provided that allow the file type + and auxiliary type to be specified before a call to + + extern unsigned char _filetype; /* Default: PRODOS_T_BIN */ + extern unsigned int _auxtype; /* Default: 0 */ + + + + The header file Example + + A text file cannot be created with just the + standard C functions because they default to the binary type + + + #include + #include + #include + #include + void main() + { + FILE *out; + char *name = "MY.FAVS"; + + _filetype = PRODOS_T_TXT; + _auxtype = PRODOS_AUX_T_TXT_SEQ; + + if ((out = fopen(name, "w")) != NULL) { + fputs("Jorah Mormont\r", out); + fputs("Brienne of Tarth\r", out); + fputs("Daenerys Targaryen\r", out); + fputs("Sandor Clegane\r", out); + if (fclose(out) == EOF) { + fprintf(stderr, "fclose failed for %s: %s", name, strerror(errno)); + } + } + else { + fprintf(stderr, "fopen failed for %s: %s", name, strerror(errno)); + } + } + + + +

+ License