PBCloseSync
PBClose Close an open device driver
#include <Devices.h> Device Manager
OSErr PBClose(pb, async );
ParmBlkPtr pb ; address of a 50-byte IOParam structure
Boolean async ; 0=await completion; 1=immediate return
returns Error Code; 0=no error
PBClose is used by the File Manager and the Device Manager.
File Manager Usage
PBClose flushes the file buffer to the volume and removes the file's access
path (i.e., invalidates its file reference number).
Device Manager Usage
PBClose closes the device driver referenced in the ioRefNum parameter
after completing any pending I/O's and releases whatever memory the driver
obtained.
pb is the address of a 50-byte IOParam structure. The relevant fields
are as follows:
Out-In Name Type Size Offset Description
-> ioCompletion ProcPtr 4 12 Completion routine address (if async =TRUE)
-> ioRefNum short 2 24 Device reference number of driver to close
<- ioResult OSErr 2 16 Error Code (0=no error, 1=not done yet)
async is a Boolean value. Use FALSE for normal (synchronous) operation
or TRUE to enqueue the request and resume control immediately. See
Async I/O.
File MgrReturns: an operating system Error Code. It will be one of:
noErr (0) No error
badUnitErr (-21) refNum doesn't match unit table
unitEmptyErr (-22) refNum specifies NIL handle in unit table
dRemoveErr (-25) Can't remove open driver
Device Mgr Returns: an operating system Error Code. It will be one of:
noErr (0) No error
extFSErr (-58) External file system
fnfErr (-43) File not found
fnOpnErr (-38) File not open
ioErr (-36) I/O error
nsvErr (-35) No such volume
rfNumErr (-51) Bad ioRefNum

File Mgr Notes:
DO NOT close a file if already closed. It is possible to wipe out a disk if you
do so. A safe suggestion is to set your file reference number to 0 (an
invalid value) after you close a file; then if you close the file again, you'll
get an error, rather than a catastrophe.
Closing a file does not necessarily flush all related data to disk. To ensure
data integrity, you should use PBFlushVol directly after closing.
Device Mgr Notes:
This is the low-level equivalent of CloseDriver. The Device Manager
and the File Manager share the same parameter block data structure, but
file-specific aspects don't apply to Device Manager calls.