home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!usc!elroy.jpl.nasa.gov!ames!data.nas.nasa.gov!taligent!keith@taligent.com
- From: keith@taligent.com (Keith Rollin)
- Subject: Re: Is a resource fork already open?
- Message-ID: <BuA4CH.9C4@taligent.com>
- Sender: usenet@taligent.com (More Bytes Than You Can Read)
- Organization: Taligent
- References: <39464@imag.imag.fr> <1992Sep8.153520.10687@waikato.ac.nz> <NEERI.92Sep8130709@iis.ethz.ch>
- Date: Tue, 8 Sep 1992 21:43:28 GMT
- Lines: 41
-
- In article <NEERI.92Sep8130709@iis.ethz.ch>, neeri@iis.ethz.ch (Matthias
- Neeracher) writes:
- >
- > 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.
- >
- > >[Low level messing about deleted :-]
- >
- > Excuse me, but am I missing something obvious or is there a much simpler way
- to
- > determine if the resource fork is already open?
- >
- > PBGetCatInfo returns a field called ioFlAttrib, and according to
- > _Inside Macintosh:Files_, bit 2 of that field is set if the resource
- > fork is open.
-
- Sometimes you want to know if the resource fork is open in _your_ application.
- Calling PBGetCatInfo will tell you if the file is open within _any_ application.
- The method Lawrence posted is the proper method.
-
- (Another method, which is more fun but which is very likely to break at some
- time in the future is to walk the resource chain, pull out refnums, call
- GetFCBInfo on them, and see if the file you are interested in is returned.)
-
- --
- Keith Rollin
- Phantom Programmer
- Taligent, Inc.
-
-