Important: The information in this document is obsolete and should not be used for new development.
Determining the Features of the File Manager
Some of the capabilities provided by the File Manager depend on the version of system software that is running, and some others depend on the characteristics of the target volume. For example, the routines that acceptFSSpecrecords as file or directory specifications were introduced in system software version 7.0 and are unavailable in earlier system software versions--unless your software development system provides "glue" that allows you to call those routines when running in earlier system software versions (or unless some system extension provides those routines). Similarly, some volumes support features that other volumes do not; a volume that has local file
sharing enabled, for instance, allows you to lock byte ranges in any files on a volume
that is sharable.Before using any of the File Manager features that are not universally available in all system software versions and on all volumes, you should check for that feature's availability by calling either the
Gestaltfunction or thePBHGetVolParmsfunction, according to whether the feature's presence depends on the system software or the characteristics of the volume.You can use
Gestaltto determine whether or not you can call the functions that accept and supportFSSpecrecords. CallGestaltwith thegestaltFSAttrselector to check for File Manager features. Theresponseparameter currently has two relevant bits:
CONST gestaltFullExtFSDispatching = 0; {exports HFSDispatch traps} gestaltHasFSSpecCalls = 1; {supports FSSpec records}Constant descriptions
The chapter "Introduction to File Management" in this book illustrates how to use the
gestaltFullExtFSDispatching
If set, all of the routines selected through the_HFSDispatchtrap are available to external file systems. If this bit is clear, the File Manager checks the selector passed to_HFSDispatchand ensures that it is valid; if the selector is invalid, the result codeparamErris returned to the caller. If this bit is set, no such validity checking is performed.gestaltHasFSSpecCalls
If set, the operating environment provides the file system specification versions of the basic file-manipulation functions, plus theFSMakeFSSpecfunction.Gestaltfunction to determine whether the operating environment supports the routines that acceptFSSpecrecords. For a complete description of theGestaltfunction, see the chapter "Gestalt Manager" in Inside Macintosh: Operating System Utilities.To test for the availability of the features that depend on the volume, you can call the low-level function
PBHGetVolParms. Listing 2-1 illustrates how you can determine whether thePBCatSearchfunction is available before using it to search a volume's catalog. Note that the SupportsCatSearch function defined in Listing 2-1 first callsGestaltto determine whether the File Manager supportsPBCatSearch. If it does, the SupportsCatSearch function callsPBHGetVolParmsto see if the indicated volume also supportsPBCatSearch.Listing 2-1 Testing for
PBCatSearch
FUNCTION SupportsCatSearch (vRefNum: Integer): Boolean; VAR myHPB: HParamBlockRec; infoBuffer: GetVolParmsInfoBuffer; attrib: LongInt; BEGIN SupportsCatSearch := FALSE; {assume no PBCatSearch support} IF gHasGestalt THEN {set this somewhere else} IF Gestalt(gestaltFSAttr, attrib) = noErr THEN IF BTst(attrib, gestaltFullExtFSDispatching) THEN BEGIN {this File Mgr has PBCatSearch} WITH myHPB DO BEGIN ioNamePtr := NIL; ioVRefNum := vRefNum; ioBuffer := @infoBuffer; ioReqCount := SIZEOF(infoBuffer); END; IF PBHGetVolParms(@myHPB, FALSE) = noErr THEN IF BTST(infoBuffer.vMAttrib, bHasCatSearch) THEN SupportsCatSearch := TRUE; END; END;TheSupportsCatSearchfunction callsPBHGetVolParmsfor the volume whose reference number is passed as a parameter toSupportsCatSearch. ThePBHGetVolParmsfunction returns information about a volume in a record of typeGetVolParmsInfoBuffer. ThevMAttribfield of that record contains a number of bits that encode information about the capabilities of the target volume. In particular, the bitbHasCatSearchis set if the specified volume supports thePBCatSearchfunction.
- Note
- Some features of volumes might change dynamically during the execution of your application. For example, the user can turn File Sharing on and off, thereby changing the capabilities of volumes. See "Locking and Unlocking File Ranges" on page 2-50 for more details.
![]()