Important: The information in this document is obsolete and should not be used for new development.
PBRead
You can use thePBRead
function to read any number of bytes from an open file.
FUNCTION PBRead (paramBlock: ParmBlkPtr; async: Boolean): OSErr;
paramBlock
- A pointer to a basic File Manager parameter block.
async
- A Boolean value that specifies asynchronous (
TRUE
) or synchronous (FALSE
) execution.
--> ioCompletion
ProcPtr
A pointer to a completion routine. <-- ioResult
OSErr
The result code of the function. --> ioRefNum
Integer
A file reference number. --> ioBuffer
Ptr
A pointer to a data buffer. --> ioReqCount
LongInt
The number of bytes requested. <-- ioActCount
LongInt
The number of bytes actually read. --> ioPosMode
Integer
The positioning mode. <-> ioPosOffset
LongInt
The positioning offset. DESCRIPTION
ThePBRead
function attempts to readioReqCount
bytes from the open file whose access path is specified in theioRefNum
field and transfer them to the data buffer pointed to by theioBuffer
field. The position of the mark is specified byioPosMode
andioPosOffset
. If your application tries to read past the logical end-of-file,PBRead
reads the data, moves the mark to the end-of-file, and returnseofErr
as its function result. Otherwise,PBRead
moves the file mark to the byte following the last byte read and returnsnoErr
. After the read is completed, the mark is returned inioPosOffset
, and the number of bytes actually read into the buffer is returned inioActCount
.You can specify that
PBRead
read the file data 1 byte at a time until the requested number of bytes have been read or until the end-of-file is reached. To do so, set bit 7 of theioPosMode
field. Similarly, you can specify thatPBRead
should stop reading data when it reaches an application-defined newline character. To do so, place the ASCII code of that character into the high-order byte of theioPosMode
field; you must also set bit 7 of that field to enable newline mode.
- Note
- When reading data in newline mode,
PBRead
returns the newline character as part of the data read and setsioActCount
to the actual number of bytes placed into the buffer (which includes the newline character).ASSEMBLY-LANGUAGE INFORMATION
The trap macro forPBRead
is_Read
.RESULT CODES