Summer 91 - MACINTOSH Q & A
MACINTOSH Q & A
MACINTOSH DEVLOPER TECHNICAL SUPPORT
Q Why would using OpenResFile(fileName) cause a crash when I try to open a
Macintosh font file that's already open?
A The problem stems from the fact that OpenResFile doesn't deal effectively with cases
where the resource file is already open. Luckily, there are some relatively new
Resource Manager calls that you can and should use instead. They're all documented in
the Resource Manager chapter of Inside Macintosh Volume VI and in Macintosh
Technical Note #214, New Resource Manager Calls.
The call of interest in your case is HOpenResFile. To use it, break down the vRefNum
(actually WDRefNum) returned by Standard File into a real vRefNum and dirID by
calling PBGetWDInfo, and pass those to HOpenResFile along with the file name. The
important part, however, is the permissions byte. If you expect to modify the file,
pass fsRdWrPerm in that field. If there's an error of any kind, expect HOpenResFile to
return -1, which should serve as a signal that you need to call ResError to find out
what went wrong.
Q My application, which has several units and objects, compiles under MPW 3.1 but
not under MPW 3.2. Do forward references to objects work differently with MPW
3.2?
A MPW 3.2 has a new syntax for forward references to objects. Objects must be
declared as externals, as follows:
TYPE
TObjB = OBJECT; external; { MPW 3.2 requires this }
TObjA = OBJECT(TObject)
fFwdRef: TObjB;
{methods}
END;