Path: utzoo!attcan!uunet!lll-winken!lll-ncis!helios.ee.lbl.gov!pasteur!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: Open Resource File List Message-ID: <6265@hoptoad.uucp> Date: 12 Jan 89 09:32:37 GMT References: <67009@ti-csl.CSNET> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 46 In article <67009@ti-csl.CSNET> holland@mips.csc.ti.com (Fred Hollander) writes: >I would like to access all opened resource files. I know they are in a linked >list, but I can't find any documentation on how to access it. I've looked >in IM, Tech Notes and MacTutor. Does someone know how to get the head of the >list and the structure of each element? Sure, it's not hard, but accessing undocumented data structures is a good way to assure that you won't be compatible with future system releases. If this is an in-house program you're willing to maintain, fine, but you shouldn't do it if you don't have close control over distributed copies. So, take a look at the low-memory globals. TopMapHndl provides a handle to the top resource map in memory. This is a copy of the resource map from the resource file, the format of which is shown in IMv1 page 129. As you can see, at offset 16 there is a handle which provides the next resource map in the list of open resource files. You can iterate down until you find a next handle of zero; alternately, you can check to see when the current map is SysMapHndl (another low-memory global). At offset 20 in each map, there is a copy of the file reference number, which is probably what you're looking for. >Another resource problem. I need to temporarily change the permission of a >resource file. Right now I CloseResFile and OpenRFPerm, but I'm worried >about the path number changing (especially when Apple implements preemptive >multitasking :). This is inside a patch, so the application may have the path >number stored somewhere. Out of curiousity does anyone know how they come up >with the path number? I would strongly recommend against trying to do this. Why do you want to change the permission? The Mac has no way in the file system of changing the access permission on an open file. If you close and re-open the file, then you may very well wind up with a different reference number. Reference numbers are offsets into the file control block table; when you open a file, the offset to the lowest unused FCB is used. So, if another file has closed since the resource file was opened, you will change the reference number and the application will become confused. Not only that, but if another resource file has opened since your resource file was opened, you are changing the search path order. In my immodest opinion, a patch that does this is a broken patch. Don't. -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "I don't know that atheists should be considered citizens, nor should they be considered patriots. This is one nation under God." -- George Bush in FREE INQUIRY magazine, Fall 1988