home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!camex!sunfs3!kent
- From: kent@sunfs3.Camex.COM (Kent Borg)
- Subject: Re: Is a resource fork already open?
- Message-ID: <1992Sep08.160946.11522@sunfs3.Camex.COM>
- Organization: Camex Inc., Boston MA
- References: <39464@imag.imag.fr> <1992Sep8.153520.10687@waikato.ac.nz>
- Date: Tue, 08 Sep 1992 16:09:46 EDT
- Lines: 51
-
- In article <1992Sep8.153520.10687@waikato.ac.nz> ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes:
- >In article <39464@imag.imag.fr>, cinquin@imag.fr ( Philippe Cinquin) writes:
- >> Sorry if this is a stupid question, but how do you know if the resource fork of
- >> a file is already open?
- >
- >If a file is already open by somebody else, you'll get an error if you try
- >opening it in a mode that's incompatible with the other person's open mode.
- >
- >But I suspect you're really asking what happens when you open a resource file
- >twice from the same application. The answer is, you will get the same file
- >refnum back the second time. So how do you tell that this is happened? It can
- >be done, without too much low-level messing about.
- >
- >The Resource Manager maintains a chain of currently-open resource files.
- >It loads the "resource map" structure from each file into memory, and fills
- >in a link field to chain all the resource maps together. There are two
- >important low-memory globals that are used for this:
- >
- > TopMapHndl -- handle to the first resource map in the chain
- > CurMap -- refnum of the "current" resource file (returned by
- > CurResFile, can be changed with UseResFile to point anywhere
- > along the chain).
-
- Um, when the obvious stares me in the face but is missed by the likes
- of Lawrence D'Oliveiro, I tend to assume I am wrong. However, I just
- did this and if my solution is busted I want to know about it, so it
- is limb climbing time.
-
- If you want to know whether a file is already open, why not ask by
- calling PBGetFInfo()? II-115: "If the file is open, the reference
- number of the first access path found is returned in ioFRefNum...".
-
- On further critical reading, the phrase "first access path found"
- makes me wonder. Might it be the same as the "first resource file in
- the chain". No, because PBGetFInfo() doesn't know which interests
- me--or does it?
-
- Is it what I need? If a different application has the file open, do I
- get that app's refnum?
-
- OK, Lawrence, please explain this to me, and now that I have done my
- best to confuse the net.world, explain it to them too.
-
- Thanks bunches.
-
-
- --
- Kent Borg kent@camex.com or (when it is *working*) kentborg@aol.com
- H:(617) 776-6899 W:(617) 426-3577
- As always, things look better when some costs are left out.
- -Economist 3-28-92 p. 94
-