[comp.sys.mac.programmer] Working Dir's under MF: how do you create & dispose of them?

gft_robert@gsbacd.uchicago.edu (opcode ranger) (03/01/91)

I need to know the 'approved' Apple method for creating working directories
within your app and disposing of them before the app quits.  I know that in
general one should avoid WD's, but in this case I really do need to make one (I
need to interface with a piece of 3rd party software which requires them).

It's relatively simple to create a WD.  The problem is if you're running under
MultiFinder, how do you know if it's your WD to dispose of?  In TN 190 it says:

********************************************************
With MultiFinder...When you call PBOpenWD, the ioWDProcID that you pass in is
ignored. MultiFinder overrides your ioWDProcID with a unique process ID for
your application, and deallocates all working directories that you allocated
when your application terminates. Thus, you cannot use the ioWDProcID to
identify your working directories when running under MultiFinder. 
[...]
Whenever you open a working directory with PBOpenWD, you should pass your
applicationUs signature as the ioWDProcID and close the working directory as
soon as possible with PBCloseWD.
********************************************************

OK, so how do you tell if the WD returned to you from PBOpenWD() is yours to
dispose of I don't want to wait until the app quits to get rid of the WD)? 
Does PBOpenWD() under MF _always_ create a new WD, which you can freely dipose
of?  If not, what is the best way to create and dispose of WD's?

A followup question: if PBOpenWD() doesn't always create new WDRefNum's under
MF, but rather could return one that's already been opened by someone/something
else, how do you know how long this WD's going to stick around?  As long as
your app is open?

Any info much appreciated!

Robert

-- 
============================================================================
= gft_robert@gsbacd.uchicago.edu * generic disclaimer: * "It's more fun to =
=            		         * all my opinions are *  compute"         =
=                                * mine                *  -Kraftwerk       =
============================================================================