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

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!usc!elroy.jpl.nasa.gov!ames!data.nas.nasa.gov!taligent!keith@taligent.com
  3. From: keith@taligent.com (Keith Rollin)
  4. Subject: Re: Is a resource fork already open?
  5. Message-ID: <BuA4CH.9C4@taligent.com>
  6. Sender: usenet@taligent.com (More Bytes Than You Can Read)
  7. Organization: Taligent
  8. References: <39464@imag.imag.fr> <1992Sep8.153520.10687@waikato.ac.nz> <NEERI.92Sep8130709@iis.ethz.ch>
  9. Date: Tue, 8 Sep 1992 21:43:28 GMT
  10. Lines: 41
  11.  
  12. In article <NEERI.92Sep8130709@iis.ethz.ch>, neeri@iis.ethz.ch (Matthias
  13. Neeracher) writes:
  14. > In article <1992Sep8.153520.10687@waikato.ac.nz> ldo@waikato.ac.nz (Lawrence
  15. D'Oliveiro, Waikato University) writes:
  16. > >In article <39464@imag.imag.fr>, cinquin@imag.fr ( Philippe Cinquin) writes:
  17. > >> Sorry if this is a stupid question, but how do you know if the resource
  18. fork of
  19. > >> a file is already open?
  20. > >
  21. > >If a file is already open by somebody else, you'll get an error if you try
  22. > >opening it in a mode that's incompatible with the other person's open mode.
  23. > >
  24. > >But I suspect you're really asking what happens when you open a resource file
  25. > >twice from the same application. The answer is, you will get the same file
  26. > >refnum back the second time. So how do you tell that this is happened? It can
  27. > >be done, without too much low-level messing about.
  28. > >[Low level messing about deleted :-]
  29. > Excuse me, but am I missing something obvious or is there a much simpler way
  30. to
  31. > determine if the resource fork is already open?
  32. > PBGetCatInfo returns a field called ioFlAttrib, and according to
  33. > _Inside Macintosh:Files_, bit 2 of that field is set if the resource
  34. > fork is open.
  35.  
  36. Sometimes you want to know if the resource fork is open in _your_ application.
  37. Calling PBGetCatInfo will tell you if the file is open within _any_ application.
  38. The method Lawrence posted is the proper method.
  39.  
  40. (Another method, which is more fun but which is very likely to break at some
  41. time in the future is to walk the resource chain, pull out refnums, call
  42. GetFCBInfo on them, and see if the file you are interested in is returned.)
  43.  
  44. --
  45. Keith Rollin
  46. Phantom Programmer
  47. Taligent, Inc.
  48.  
  49.