[comp.sys.mac.programmer] Opening Working Directories

tomc@mntgfx.mentor.com (Tom Carstensen) (04/14/88)

How many working directories can be opened?  If it is 
limited, what happens after you've opened a file up,
got a working directory reference number to access
that file, and then you close that working directory.
It that reference number no longer valid.  If so, what
can you do if OpenWD returns too many working dirs?

I can't just go closing that last one I opened, it may 
have a file in it that I opened.

:------------------------------------------------------------:
: Tom Carstensen         Usenet: tomc@mntgfx.MENTOR.COM      :
: Mentor Graphics                Delphi: CARSTENSEN          :
:                                GEnie:  XPC23637            :
:                                                            :
:     . . .  AAhh!  I see you have a machine that goes PING! :
:                                       - Monty Python       :
:------------------------------------------------------------:

darin@Apple.COM (Darin Adler) (04/15/88)

In article <1988Apr13.115044.1591@mntgfx.mentor.com> tomc@mntgfx.mentor.com (Tom Carstensen) writes:
> I can't just go closing that last one I opened, it may 
> have a file in it that I opened.

Once you have opened a file, the working directory no longer needs to be open.
HFS extracts the volume and directory information from the WDRefNum when the
Open call is made. You should always open working directories for as short a
time as possible, closing them after using them. As a matter of fact, you can
avoid opening working directories at all by using the PBH calls, which take
vRefNums and dirIDs to specify the directory and volume a file is in.
-- 
Darin Adler, Apple Computer                          AppleLink:Adler4
UUCP: {sun,voder,nsc,mtxinu,dual}!apple!darin  CSNET: darin@Apple.com