Important: The information in this document is obsolete and should not be used for new development.
Testing for File Management Routines
To determine the availability of the routines that operate onFSSpecrecords, you can call theGestaltfunction with thegestaltFSAttrselector code, as illustrated in Listing 1-2.Listing 1-2 Testing for the availability of routines that operate on
FSSpecrecords
FUNCTION FSSpecRoutinesAvail: Boolean; VAR myErr: OSErr; {Gestalt result code} myFeature: LongInt; {Gestalt response} BEGIN FSSpecRoutinesAvail := FALSE; IF gHasGestalt THEN {if Gestalt is available} BEGIN myErr := Gestalt(gestaltFSAttr, myFeature); IF myErr = noErr THEN IF BTst(myFeature, gestaltHasFSSpecCalls) THEN FSSpecRoutinesAvail := TRUE; END; END;To use the procedures defined in the following sections to open and save files, you
also need to make sure that the routinesStandardGetFileandStandardPutFileare available. You can do this by passingGestaltthegestaltStandardFileAttrselector and verifying that the bitgestaltStandardFile58is set in the response value. Also, before using theFindFolderfunction (as shown, for example, in
Listing 1-10 on page 1-25), you should call theGestaltfunction with thegestaltFindFolderAttrselector and verify that thegestaltFindFolderPresentbit is set; this indicates that theFindFolderfunction is available.If the routines that operate on
FSSpecrecords are not available, you can use corresponding File Manager and Standard File Package routines. For example, if
you cannot callFSpOpenDF, you can callHOpenDF. That is, instead of writing
myErr := FSpOpenDF(mySpec, fsCurPerm, myFile);you can write something like
myErr := HOpenDF(myVol, myDirID, myName, fsCurPerm, myFile);The only difference is that themySpecparameter is replaced by three parameters specifying the volume reference number, the parent directory ID, and the filename. With only a few exceptions, all of the techniques presented in this chapter can be easily adapted to work with high-level HFS routines in place of the routines that work withFSSpecrecords.
- Note
- One notable exception concerns the Standard File Package procedures
SFGetFileandSFPutFile. ThevRefNumfield of the reply
record passed to both these functions contains a working directory reference number, which encodes both the directory ID and the
volume reference number. In general, you should avoid using this number; instead you can turn it into the corresponding directory ID and volume reference number by calling theGetWDInfofunction. See the
chapter "File Manager" in this book for details on working directory reference numbers.![]()