FSRead
You can use the FSRead function to read data from an open driver into a data buffer.
pascal OSErr FSRead(short refNum, long *count, void *buffPtr);
refNum
- The driver reference number.
count
- The number of bytes to read.
buffPtr
- A pointer to a buffer to hold the data.
DESCRIPTION
Before calling the FSRead function, your application should allocate a data buffer large enough to hold the data to be read. The FSRead function attempts to read the number of bytes indicated by the count parameter and transfer them to the data buffer pointed to by the buffPtr parameter. The refNum parameter identifies the device driver. After the transfer is complete, the count parameter indicates the number of bytes actually read.
- WARNING
- Be sure your buffer is large enough to hold the number of bytes specified by the
count parameter, or this function may corrupt memory.
The FSRead function is a high-level synchronous version of the low-level PBRead function. Use the PBRead function when you want to request asynchronous reading or need to specify a drive number or a positioning mode and offset. See the next section, which describes the PBRead function.
SPECIAL CONSIDERATIONS
Do not call the FSRead function at interrupt time. Synchronous requests at interrupt time may block other pending I/O requests and cause the Device Manager to loop indefinitely while it waits for the device driver to complete the interrupted requests.
RESULT CODES
| noErr | 0 | No error |
| readErr | -19 | Driver does not respond to read requests |
| badUnitErr | -21 | Driver reference number does not match unit table |
| unitEmptyErr | -22 | Driver reference number specifies a nil handle in unit table |
| abortErr | -27 | Request aborted by KillIO |
| notOpenErr | -28 | Driver not open |
SEE ALSO
For information about the low-level function for reading from device drivers, see the next section, which describes the PBRead function.