MacVAX XFC (system) Calls
File I/O
The following sys routines handle input and output to Macintosh files.
- XFC #OPEN_MAC_FILE (8)
- Puts up a Standard File Open dialogue box, and waits for the user to select a file. A file
descriptor, used to refer to the file in all subsequent file i/o calls, is returned in r0. A
value of 0 in r0 indicates the Cancel button was clicked, or an error occurred while
trying to open the file.
- XFC #CREATE_MAC_FILE (9)
- Puts up a Standard File Put dialogue box, and waits for the user to type in a file name.
A pointer to a buffer for the new file's name must be passed in r1. The file descriptor is
returned in r0. A value of 0 in r0 indicates the Cancel button was clicked, or an error
occurred while trying to create the file.
- XFC #CLOSE_MAC_FILE (10)
- Closes the file described by the file descriptor passed in r0. If the file was closed
successfully, 0 will be returned in r0. If an error occurred, r0 will be set to -1.
- XFC #READ_MAC_FILE (11)
- Reads the number of bytes indicated by r2 into a string buffer pointed to by r1. The file
to be read from is given by the file descriptor passed in r0. The current file position is
shifted by the number of bytes read. The number of bytes actually read is returned in r2.
- XFC #WRITE_MAC_FILE (12)
- Writes the number of bytes indicated by r2 from a string buffer pointed to by r1 at the
current file position. The file to be written is selected by the file descriptor passed in r0.
The current file position is shifted by the number of bytes written. The number of bytes
actually written is returned in r2.
- XFC #SEEK_MAC_FILE (13)
- Moves the current file position to the position passed in r1 according to the mode
passed in r2. The file is selected using the file descriptor passed in r0. The mode has
three possible values:
- 0
- Seek from beginning of file
- 1
- Seek relative to current position
- 2
- Seek from end of file
On return, r1 contains the new current file position.
Filename Structure
The Following File IO calls use a Filename Structure.
A filename structure is a VAX word, to hold a directory reference number, followed by a pascal string for the filename.
ie.
struct
{
word directory_refnum;
pascal_string filename;
}
- XFC #OPEN_NAMED_FILE (29)
- OPEN_NAMED_FILE opens a file given its name and directory reference number. The directory reference number can be obtained from one of GET_CDIR_ID, GET_ADIR_ID, GET_DIR_ID, GET_FILENAME or the FIND_FILE xfc's. A pointer to a filename structure is passed in R1. A file descriptor is returned in R0. A value of 0 in R0 indicates an error occurred while trying to open the file.
- XFC #GET_FILENAME_FD (30)
- GET_FILENAME returns the directory reference number and name of an open file associated with the given file descriptor. The file descriptor of the open file is passed in R0 and a pointer to a filename structure to return the result in, should be passed in R1.
- XFC #FIND_FILE (31)
- FIND_FILE displays a Standard Macintosh File Dialog Box. The user selects a file and the directory reference number and name of the selected file are returned in the filename structure pointed to by R1.
R0 contains a 0 if the user selected a file and -1 if they cancelled.
- XFC #GET_DIR_ID (32)
- GET_DIR_ID is currently unimplemented.
GET_DIR_ID returns the directory reference number of the directory passed as a pascal string pointer in R1. The directory reference number
is returned in R0.
- XFC #GET_ADIR_ID (33)
- GET_ADIR_ID returns the directory reference number of MacVAX's directory (ie the folder the MacVAX application was launched from).
This might be useful to boot code wishing to open a file in the MacVAX folder. The reference number is returned in R0.
- XFC #GET_CDIR_ID (34)
- GET_CDIR_ID returns the directory reference number of the last folder a file was opened in. The reference number is returned in R0.