Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!isgate!krafla!aries From: aries@rhi.hi.is (Reynir Hugason) Newsgroups: comp.sys.mac.programmer Subject: Re: Resource path: getting the really most recently opened file? Message-ID: <1637@krafla.rhi.hi.is> Date: 14 Apr 90 22:30:13 GMT References: <11098@hoptoad.uucp> Organization: University of Iceland Lines: 43 > So where is this information stored? It's not stored in TopMapHndl, at > least not in any obvious way. TopMapHndl is the map currently at the > start of the search path, not the file at the beginning of the total > search path. And the RM code in the ROM doesn't reference any low > memory globals other than the documented ones, which don't contain > this information. topMapHandle is the front most resource map of all currently open resource files in the system. UseResFile does _not_ modify this linked-list _ever_. It simply tells where it should start the search in it, you supply it with a refNum and it locates that refNum in the list and starts there, slow but neat. Consider the following diagram for a more picturesque view of UseResFile. 1. OpenResFile('R0..R3'); 2. UseResFile(R2); topMapHandle contains topMapHandle contains (..previously opened files..) (..previously opened files..) R0 R0 R1 R1 R2 R2 <- CurResFile R3 <- CurResFile R3 So as you can see it never modifies the list, and _RsrcZoneInit can simply walk the list from left to right with-out worrying about what the current search order is. Post scriptum: If you need to keep your resource files open in between application launches (e.g. some INIT doing really niffty stuff) you can do so by hiding your resource map behind the system resource map. You will have to NIL your handle fields though, but that's not too though ;-) ============================================================================== Mimir R. (aries@rhi.hi.is) | A program is like a nose. Taeknigardur, Dunhaga 5 | Sometimes it runs, sometimes it blows. IS-105, Reykjavik | ICELAND | DISCLAIMER: Who me?! ==============================================================================