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 onFSSpec
records, you can call theGestalt
function with thegestaltFSAttr
selector code, as illustrated in Listing 1-2.Listing 1-2 Testing for the availability of routines that operate on
FSSpec
records
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 routinesStandardGetFile
andStandardPutFile
are available. You can do this by passingGestalt
thegestaltStandardFileAttr
selector and verifying that the bitgestaltStandardFile58
is set in the response value. Also, before using theFindFolder
function (as shown, for example, in
Listing 1-10 on page 1-25), you should call theGestalt
function with thegestaltFindFolderAttr
selector and verify that thegestaltFindFolderPresent
bit is set; this indicates that theFindFolder
function is available.If the routines that operate on
FSSpec
records 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 themySpec
parameter 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 withFSSpec
records.
- Note
- One notable exception concerns the Standard File Package procedures
SFGetFile
andSFPutFile
. ThevRefNum
field 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 theGetWDInfo
function. See the
chapter "File Manager" in this book for details on working directory reference numbers.