[comp.sys.mac.programmer] Keeping resource files open

evans@neon.stanford.edu (John S. Evans) (07/26/90)

I am writing an init that needs to load in a resource file and have it 
remain open (for at least reading...) after the init finishes.  Basically, 
I want to add this resource file to the chain of open resource files.  I 
think that suitcase must do this somehow, because those files "load" 
without copying all of their data to the system.

Does anyone out there know how to accomplish this?  Any help would be 
tremendously appreciated!

You can post the replies.  I read this group regularly...

--------------------------------------------------------
John S. Evans
MSCS Student
Stanford University 

Disclaimer:  these opinions are mine.  So there.

chewy@apple.com (Paul Snively) (07/27/90)

In article <9423@goofy.Apple.COM> evans@neon.stanford.edu (John S. Evans) 
writes:
> I am writing an init that needs to load in a resource file and have it 
> remain open (for at least reading...) after the init finishes.  
Basically, 
> I want to add this resource file to the chain of open resource files.  I 
> think that suitcase must do this somehow, because those files "load" 
> without copying all of their data to the system.

Right you are.

> Does anyone out there know how to accomplish this?  Any help would be 
> tremendously appreciated!

No problem.  Once upon a time I had assembler source to do this, but 
failing that, here goes:

You must do two things: a) use HandToHand to copy the resource map for the 
file from the application heap to the system heap so that InitApplZone 
won't trash the map, and b) futz with the resource map chain so that your 
open file appears in the resource chain _AFTER_ the System file (otherwise 
InitApplZone will close the file for you, no questions asked).

That's it.  If you also want to keep the INIT file itself open, you must 
patch CloseResFile in a really contorted way.  The _first_ time through 
the patch, the patch must do _nothing_ out of the ordinary.  The second 
time through it must behave as a NOP (that is, blow off closing the file) 
and the patch must remove itself.  (Of course, you must also go through 
the above mentioned contortions to keep the INIT file's map from being 
blown away).

Hope this helps!

__________________________________________________________________________
                                Paul Snively
                      Macintosh Developer Technical Support
                             Apple Computer, Inc.

chewy@apple.com

Just because I work for Apple Computer, Inc. doesn't mean that I believe 
what they believe, or vice-versa.
__________________________________________________________________________