Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Files /
Chapter 2 - File Manager / File Manager Reference
Low-Level File Access Routines / Reading, Writing, and Closing Files


PBWrite

You can use the PBWrite function to write any number of bytes to an open file.

FUNCTION PBWrite (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.
-->ioCompletionProcPtrA pointer to a completion routine.
<--ioResultOSErrThe result code of the function.
-->ioRefNumIntegerA file reference number.
-->ioBufferPtrA pointer to a data buffer.
-->ioReqCountLongIntThe number of bytes requested.
<--ioActCountLongIntThe number of bytes actually written.
-->ioPosModeIntegerThe positioning mode.
<->ioPosOffsetLongIntThe positioning offset.

DESCRIPTION
The PBWrite function takes ioReqCount bytes from the buffer pointed to by ioBuffer and attempts to write them to the open file whose access path is specified by ioRefNum. The position of the mark is specified by ioPosMode and ioPosOffset. If the write operation completes successfully, PBWrite moves the file mark to the byte following the last byte written and returns noErr. After the write operation is completed, the mark is returned in ioPosOffset and the number of bytes actually written is returned in ioActCount.

If you try to write past the logical end-of-file, PBWrite moves the logical end-of-file. If you try to write past the physical end-of-file, PBWrite adds one or more clumps to the file and moves the physical end-of-file accordingly.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro for PBWrite is _Write.

RESULT CODES
noErr0No error
dskFulErr-34Disk full
ioErr-36I/O error
fnOpnErr-38File not open
posErr -40Attempt to position mark before start of file
wPrErr -44Hardware volume lock
fLckdErr-45File is locked
vLckdErr -46Software volume lock
paramErr-50Negative ioReqCount
rfNumErr-51Bad reference number
wrPermErr-61Read/write permission doesn't allow writing

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996