Important: The information in this document is obsolete and should not be used for new development.
PBLockRange
You can use thePBLockRangefunction to lock a portion of a file.
FUNCTION PBLockRange (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. --> ioReqCountLongIntThe number of bytes in the range. --> ioPosModeIntegerThe positioning mode. --> ioPosOffsetLongIntThe positioning offset. DESCRIPTION
ThePBLockRangefunction locks a portion of a file that was opened with shared
read/write permission. The beginning of the range to be locked is determined by theioPosModeandioPosOffsetfields. The end of the range to be locked is determined by the beginning of the range and theioReqCountfield. For example, to lock the
first 50 bytes in a file, setioReqCountto 50,ioPosModetofsFromStart, andioPosOffsetto 0. SetioReqCountto -1 to lock the maximum number of bytes from the position specified inioPosOffset.The
PBLockRangefunction uses the same parameters as bothPBReadandPBWrite; by calling it immediately beforePBRead, you can use the information in the parameter block for thePBReadcall.When you're finished with the data (typically after a call to
PBWrite), be sure to callPBUnlockRangeto free that portion of the file for subsequentPBReadcalls.SPECIAL CONSIDERATIONS
ThePBLockRangefunction does nothing if the file specified in theioRefNumfield is open with shared read/write permission but is not located on a remote server volume
or is not located under a share point on a sharable local volume. See "Locking and Unlocking File Ranges" on page 2-50 for a simple way to determine whether callingPBLockRangeon an open file would in fact lock a range of bytes.
- WARNING
- In system software versions 6.0.7 and earlier, specifying
ioPosModeasfsFromLEOFresults in the wrong byte range being locked.![]()
ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector forPBLockRangeare
Trap macro Selector _HFSDispatch $0010 RESULT CODES
noErr 0 No error ioErr -36 I/O error fnOpnErr -38 File not open eofErr -39 Logical end-of-file reached fLckdErr -45 File is locked by another user paramErr -50 Negative ioReqCountrfNumErr -51 Bad reference number extFSErr -58 External file system volGoneErr -124 Server volume has been disconnected afpNoMoreLocks -5015 No more ranges can be locked afpRangeOverlap -5021 Part of range is already locked