Path: utzoo!attcan!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!decwrl!nsc!voder!apple!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Writing resources to a file Message-ID: <11022@apple.Apple.Com> Date: 25 May 88 22:31:32 GMT References: <51379@sun.uucp> <600@kinetics.UUCP> <23980@ucbvax.BERKELEY.EDU> Reply-To: lsr@apple.UUCP (Larry Rosenstein) Distribution: na Organization: Advanced Technology Group, Apple Computer Lines: 23 In article <23980@ucbvax.BERKELEY.EDU> oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) writes: >In article <600@kinetics.UUCP> markw@kinetics.UUCP (Mark Wittenberg) writes: >>1. How do you tell if a resource file is already open? >Well, one easy way to do it is, before opening the file with >OpenResFile(), try opening it with PBOpenRF(). If it is already open, >since you are opening it for read/write you get back the vRef of the >existing access path and an "already open" error code. Close the file in Tech Note 185 mentions a problem with this under MultiFinder. The the file is opened by another process and you ask for read/write permission (or use OpenResFile) then you will get back -1 as the refnum and ResError will be -49. You need to check for this case as well. I think you can also do a PBGetFInfo, since that returns the refnum of an access path if the file is open. (I don't think it distinguishes the data and resource forks.) Also, on 64K ROMs, I think you have to zero the refnum field before the call. -- Larry Rosenstein, Object Specialist Apple Computer, Inc. 20525 Mariani Ave, MS 27-AJ Cupertino, CA 95014 AppleLink:Rosenstein1 domain:lsr@Apple.COM UUCP:{sun,voder,nsc,decwrl}!apple!lsr