[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Resource Manager - please help!



In <1993May18.234048.16806@gallant.apple.com> dlyons@apple.com (David A Lyons) writes:

>The strategy of setting the current resource app to get access to an
>application's resource search path and then read its rVersion(1) resource
>is a SHAKY to begin with, because there could be extra resource files
>open in that path.  You might get the rVersion(1) from the wrong file, or
>even from Sys.Resources.  I don't think there is a guaranteeable way to
>find the application's resource fork in there, even if it's open.

I know what this is like.  I've had a couple of programs do incredibly
bizarre things because it was (for some reason) reading its resources from
Sys.Resources.  I would be told that my application (version 0.2d1) is
version 6.0, and would get other bizarre behavior... :)

>I still recommend the method in my previous post--open the application's
>resource fork in your own search path (works unless the fork is already
>open as read/write).

I think a useful addition to the System Software would be a way to get the
resource file ID and/or resource app of any open file.  This would be
especially useful in a switching environment (in cases just like this).
Then this problem could be solved with code like this:

oldApp=GetCurResourceApp()
SetCurResourceApp(GetOpenFileResourceApp(refnum));
oldFile=GetCurResourceFile();	/* get other app's cur. fileID */
SetCurResourceFile(GetOpenFileID(refnum));
...
SetCurResourceFile(oldFile);	/* make sure to restore other's file */
SetCurResourceApp(oldApp);	/* and switch ourselves back in */

Hmmm... looking this over, it could probably be simplified, but I think
the general idea gets across.

--
Eric D. Shepherd                   | Apple II Alliance Charter Member
InterNet: uerics@mcl.mcl.ucsb.edu  |           ACM Member
FidoNet:  1:206/2713 Eric Shepherd | Programming Law #2: If it works
AOL:      Sheppy                   | the first time, something's wrong.