[comp.sys.mac.programmer] Working Directory Questions

west@turing.toronto.edu (Tom West) (11/17/90)

  I have a problem with Working Directories.  In fact, I may have several
problems.  Perhaps those more knowledgeable than I could help.

  My program requires that I open a WD every so often.  Being a good
person, I close it as soon as possible.  Unfortunately, the user may have
used SFGetFile and selected a number of files in the directory that I
opened.  The nasty part comes when I close it.  Under Finder, closing my
WD doesn't close the WD associated with the files opened SFGetFile.  
However, under Multifinder, there appears to be only one WD and closing the 
WD that I opened also makes all the WD used by SFGetFile worthless!!

(1)  Is there any way to get around this behaviour.  I want (under Multifinder)
to disassociate the WDs that I open and close from the ones opened with 
SFGetFile by the user.  Is there anyway to do this.  (I currently open my
WD with the signature of the file, rather than ERIK.  Is this a bad thing?

(2)  When will the Mac close the WD's created by SFGetFile?  Does it ever?  If
not, does this mean that the user has a maximum of 20 or so different
directories that he can use from SFGetFiles over the course of one program.
This seems like a pretty unpleasant limitation.  (20 at once I could 
understand, 20 total over the running of the program is not so good.)

(3)  What signature do you give to opening WDs.  TN 77 says ERIK, TN 190
says your programs signature.

  Unfortunately, I have to use WDs, since the user can specify a partial
pathname, full path name or just a file name with a specified directory
as the base directory.  At the moment, I feed the path name and the WD of
the base directory to get a path reference number.

  Thanks in advance.  I will read either mail or postings.

				Tom West
				west@turing.toronto.edu
				tomwest@gpu.utcs.utoronto.ca
				west@hsa.on.ca

ech@cbnewsk.att.com (ned.horvath) (11/17/90)

From article <1990Nov16.130543.18925@jarvis.csri.toronto.edu>, by west@turing.toronto.edu (Tom West):

>   I have a problem with Working Directories...

So does anyone else who needs to "remember" a directory.

>   Unfortunately, I have to use WDs, since the user can specify a partial
> pathname, full path name or just a file name with a specified directory
> as the base directory...

Fortunately, you don't.  Feed the WDRefNum returned by standard file as the
ioVRefNum parameter to PBGetWDInfo.  Make sure you set ioNamePtr,
ioWDIndex, and ioWDProcID to zero.  Save the results returned in ioWDVRefNum
and ioWDDirID.  Later, you can supply those to PBHOpen (NOT PBOpen) as the
ioVRefNum and ioDirID, respectively.  Partial pathnames in the ioNamePtr
argument to PBHOpen are cool.

Oh, yeah: the ioWDVRefNum is only valid until the volume is dismounted.
If you need to remember the volume across dismounts (this include, but
is not limited to, reboots), you should pass the address of a Str255 in
the ioNamePtr argument to PBGetWDInfo, and cache that as well.  Later,
you can use PBGetVolInfo to get the correct ioVRefNum for that volume.

Hope that helps.

=Ned Horvath=