From: Bill Chatfield Date: Fri, 28 Jul 2017 21:44:13 +0000 (-0400) Subject: Documented _filetype and _auxtype X-Git-Tag: V2.17~109^2~3 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2c7b757b4caf152e26f9bb0bbb3fb0dba0b69f6c;p=cc65 Documented _filetype and _auxtype --- 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