Files of this type and auxiliary type contain other files with their attributes encoded in Binary II format.
Binary II is a widely used and accepted standard for keeping file attributes with files as they are transferred, usually by modem or other form of telecommunication. Files that are known Binary II files should be written to disk with file type $E0 and auxiliary type $8000 as a clear indication to other programs that the file contains files with Binary II specifications.
Binary II was developed by Gary B. Little, author of the Point-To-Point communications product and author of several Apple II reference books. He is also Apple's Product Manager for third-party Development Tools and Languages. Gary welcomes your comments and suggestions on the Binary II standard at the following address:
Gary B. Little
3304 Plateau Drive
Belmont, CA 94002
AppleLink: LITTLE
AppleLink -- Personal Edition: GaryLittle
CompuServe: 70135,1007
GEnie: GARY.LITTLE
Transferring Apple II files in binary form to commercial information services and bulletin boards (referred to in this Note as "hosts") can be, to put it mildly, a frustrating exercise. Although most hosts are able to receive a file's data in binary form (using protocols such as XMODEM), they don't receive the file's all-important attribute bytes. All the common Apple II file system, notably the ProDOS file system, store the attributes inside the disk directory, not inside the file itself.
The ProDOS attributes are the access code, file type code, auxiliary type code, storage type code, date of creation and last modification, time of creation and last modification, the file size, and the name of the file itself. Under GS/OS, the same parameters exist for other file systems as well as file system-specific information and two-forked file information. It is usually not possible to use a ProDOS file's data without knowing the file's attributes (particularly the file type, auxiliary type, and size). Therefore, ProDOS files uploaded in binary format to a host are useless to those who download them. The same is true for DOS 3.3 and Pascal files.
Many Apple II communication programs use special protocols for transferring file attributes during a binary file transfer, but none of these protocols have been implemented by hosts. These programs are only useful for exchanging files with another Apple II running the same program.
Without a standard like Binary II, the only acceptable way to transfer an Apple II file to a host is to convert it into ASCII text before sending it. Such a text file would contain a listing of an AppleSoft program, or a series of Apple II monitor commands (e.g., 300:A4 32). Someone downloading a file can convert it to binary form using the AppleSoft EXEC command.
The main disadvantage of this technique is that the text version of the file is over three times the size of the original binary file, making it expensive (in terms of time and money) to upload and download. It is also awkward, and sometimes impossible, to perform the binary-to-text or text-to-binary conversion.
The solution to the problem is to upload an encoded binary file which contains not just the file's data, but the file's attributes as well. Someone downloading such a file can then use a conversion program to strip the attributes from the file and create a file with the required attributes.
This Note describes such a format: Binary II. The description of the format is detailed for the purpose of allowing software developers to implement it in Apple II communication programs.
Binary II is not an archival or compression standard. It is designed to be a simple method to keep the attributes normally in a disk file's directory entry with the file as it is transferred. Although multiple files may be placed together with Binary II, this is a matter of convenience for telecommunication programs.
A true archival standard must be designed as such, with the capability to manipulate files within the archive as well as linking them together (compressed or uncompressed) for transfer. NuFX (documented in Apple II File Type Note for File Type $E0, Auxiliary Type $8002) is a good example of a robust, full-featured Apple II archival standard.
Binary II is primarily designed to be added to and subtracted from files "on-the-fly" by telecommunication programs. Binary II files should only be found on disks when they are transferred by a telecommunication program that does not have Binary II capabilities, in which case a separate utility (such as Binary Library Utility by Floyd Zink, Jr.) must be used to extract the files. Telecommunication programs should be able to transfer files without Binary II processing, however, they should support Binary II processing as a default.
The Binary II form of a standard file consists of a 128-byte file information header followed by the file's data. The data portion of the file is padded with nulls ($00 bytes), if necessary, to ensure the data length is an even multiple of 128 bytes.
The file information header contains four ID bytes, the attributes of the file (in ProDOS 8 form), and some control information.
The structure of the header is as follows:
If the File Name String is a filename and not a partial pathname, then the following optional parameter may be supplied:
You can put a standard ProDOS filename or a partial pathname in the file information header (but never a complete pathname). Don't use a partial pathname unless you've included, earlier in the Binary II file, file information headers for each of the directories referred to in the partial pathname. Such a header must have its "end of file position" bytes set to zero, and no data blocks for the subdirectory file must follow it.
For example, if you want to send a file whose partial pathname is HELP/GS/READ.ME, first send a file information header defining the HELP/ subdirectory, then one defining the HELP/GS/ subdirectory. If you don't, someone downloading the Binary II file won't be able to convert it because the necessary subdirectories will not exist.
Note: GS/OS communication programs must use the slash (/) as the pathname's separator in any partial pathname it puts in the header. Since GS/OS's standard separator is the colon (:), a conversion may be necessary.
Whenever a file is sent to a host, the host asks the sender to provide a name for it. If it's a file in Binary II form, the name provided should end in .BNY so its special form will be apparent to anyone viewing a list of filenames. If the file is compacted (using the public-domain Squeeze algorithm) before being converted to Binary II form, use a .BQY suffix instead. If the file is a NuFX archive, use the suffix .BXY.
You can determine, while transferring, if a file is in Binary II form by examining the ID bytes at offsets +000, +001, +002 and +018 from the beginning of the file. They must be $0A, $47, $4C and $02, respectively.
Once Binary II files are identified, you can use the data in the file information header to create and open a ProDOS file with the correct name and attributes, transfer the file data in the Binary II file to the ProDOS file, set the ProDOS file size, then close the ProDOS file. You would repeat this for each file contained inside the Binary II file.
Note: The number of 128-byte blocks following the file information header must be derived from the EOF attribute for the file. Calculate the number by dividing the EOF by 128 and adding one to the result if EOF is not 0 or an exact multiple of 128. However, if the file information header defines a subdirectory (the file type is $0F), simple create the subdirectory file. Do not open it and do not try to set its size.
Ideally, all this conversion work will be done automatically by a communication program during file transfer. If not, a separate conversion program (such as the previously mentioned Binary Library Utility, or BLU) must be used to do this for you.
GS/OS will return, when asked, an option_list for files on many file calls. The option_list consists of a Word buffer length (which must be at least $2E), followed by a Word number of bytes GS/OS put in the buffer, a Word GS/OS file system identification, and the given number of bytes of FST-specific information (minus two; the count GS/OS returns includes the file system identifier).
Option_list values are FST specific and contain values important to the native file system but not important to GS/OS. For AppleShare, the option_list contains Finder Information, parent directory identification, and access privileges. This information should be transferred with files.
Binary II uses a phantom file with identifier $01 $00 to indicate an option_list. When this phantom file is seen, the contents should be used as the option_list for the file that immediately follows this file in the Binary II file. The other attributes of the phantom file must be set to the same values as those for the file immediately following (the file for which the phantom file contains the option_list). The EOF for the phantom file must be the size of the option_list + 2, and the file size must be adjusted accordingly to account for the phantom file ID bytes.
When receiving a Binary II file, the contents of this phantom file should be used as option_list input on a GS/OS SetFileInfo call.
If the GS/OS option_list returns a total of two bytes (just the file_sys_ID), there is no FST-specific information, and the option_list phantom file may safely be omitted.
The format of the option_list phantom file is as follows:
Extended files contain two logical segments: a data fork and a resource fork. These files can be created and manipulated by GS/OS, but not by ProDOS 8 or any other Apple II operating system.
When a GS/OS-based communication program sends an extended file, it must send it in the AppleSingle file format, preceded by a Binary II file information header. (Such a program could easily convert an extended file to AppleSingle format on the fly.) The Binary II header must contain the attributes of the AppleSingle file (including a file type of $E0 and an auxiliary type of $0001) and the "storage type code" field must be $01. (The EOF positions for the data fork and resource fork of the extended file appear in an entry in the AppleSingle file header, not in the Binary II header.)
The AppleSingle format is described in Apple II File Type Note for File Type $E0, Auxiliary Type $0001.
A GS/OS-based communication program that receives an AppleSingle file can easily convert it on the fly to the extended file it defines. ProDOS 8-based communication programs can only save the AppleSingle file to disk because it's not possible (nor is it encouraged to attempt) to create extended files with ProDOS 8 (without using block-level calls); a GS/OS based utility program is needed to convert the AppleSingle file to its extended form.
With a little extra effort, you can also convert DOS 3.3 files to Binary II form. This involves translating the DOS 3.3 file attributes to the corresponding ProDOS attributes so that you can build a proper file information header.
DOS 3.3 ProDOS ProDOS ProDOS File Type File Type Auxiliary Type Access __________________________________________________ $00 (T) $04 $0000 $E3 $80 (*T) $04 $0000 $21 $01 (I) $FA $0C00 $E3 $81 (*I) $FA $0C00 $21 $02 (A) $FC * $E3 $82 (*A) $FC * $21 $04 (B) $06 ** $E3 $84 (*B) $06 ** $21 $08 (S) $06 $0000 $E3 $88 (*S) $06 $0000 $21 $10 (R) $FE $0000 $E3 $90 (*R) $FE $0000 $21 $20 (A) $06 $0000 $E3 $A0 (*A) $06 $0000 $E3 $40 (B) $06 $0000 $E3 $C0 (*B) $06 $0000 $21 __________________________________________________ * Set the auxiliary type for an A file to the memory address from which the program was saved. This is usually $0801. ** Set the auxiliary type for a B file to the value stored in the first two bytes of the the file (this is the default load address).
Attribute bytes inside a DOS 3.3 file (if any) must not be included in the data portion of the Binary II file. This includes the first four bytes of a B (Binary) file, and the first two bytes of an A (AppleSoft) or I (Integer BASIC) file.
This and all of the other Apple II Technical Notes have been converted to HTML by Aaron Heiss as a public service to the Apple II community, with permission by Apple Computer, Inc. Any and all trademarks, registered and otherwise, are properties of their owners.