Path: utzoo!attcan!uunet!yale!cmcl2!ccnysci!alexis From: alexis@ccnysci.UUCP (Alexis Rosen) Newsgroups: comp.sys.mac.programmer Subject: Re: Toolbox Gotchas (LONG) Message-ID: <1600@ccnysci.UUCP> Date: 16 Apr 89 09:40:14 GMT References: <10050096@accuvax.nwu.edu> <10050098@accuvax.nwu.edu> Reply-To: alexis@ccnysci.UUCP (Alexis Rosen) Organization: City College of New York Lines: 38 John discusses the complete lack of sanity checking when you call OpenResFile. The Apple Answer is, rewrite the appropriate parts of RezDet and put them in your code. This is pretty terrible. As John says, damaged resource forks are not so rare. Crashing when you open a bad resource file is very very unfriendly. But having to write all that code to protect yourself is an awful lot of work. I can't think of many people outside of Apple, except maybe Steve Brecher, who could do this without extensive sessions with Inside Mac. This already makes that solution problematic. Of course the real problem is much worse. Apple specifically warns us, many times, that the format of the Resource Map will change in the future. It is my guess that such a change will come with System 7.0, and certainly no later than System 8.0. Guaranteeing that your application will crash on a future system just to protect yourself now is a miserable tradeoff. I suggest that Apple provide us with the tools to do this properly. There are two decent ways to do this that I can think of. First, the simplest way is to provide a trap that checks the file. The second, slightly more involved way is a little micer because it's more automatic. When you call OpenResFile, the first thing it does is write a dirty bit in the header somewhere. It then reads in the resource map. If everything is OK, the last thing is does before it returns is clear the dirty bit. When it opens a res file, before it writes the bit it reads it, and if it's set it knows that the last time it opened this resource fork it crashed. So it's a good bet that the res fork is damaged, and needs to be checked carefully. It would then call the sanity checker, and if it failed it would return an error. Anyone have any idea what the new resource manager is going to be like? --- Alexis Rosen alexis@ccnysci.{uucp,bitnet} alexis@rascal.ics.utexas.edu (last resort)