home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / mac / programm / 15168 < prev    next >
Encoding:
Text File  |  1992-09-08  |  2.7 KB  |  62 lines

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