[comp.sys.mac.programmer] Need help with SFGetFile

bjb@pyramid.pyramid.com (Bruce Beare) (05/22/89)

I am trying to put a button "SELECT CURRENT DIRECTORY" into a
customized SFPGetFile dialog box. The problem is that I can't seem to
get a vRefNum for the current folder at the time that the new
button is hit.

How can I get a handle into the "current working folder" from one of
the "hook" functions that SFPGetfile provides??

Any help would be appreciated.

Thank you,

Bruce Beare

tim@hoptoad.uucp (Tim Maroney) (05/24/89)

In article <71073@pyramid.pyramid.com> bjb@pyramid.pyramid.com (Bruce Beare)
writes:
>I am trying to put a button "SELECT CURRENT DIRECTORY" into a
>customized SFPGetFile dialog box. The problem is that I can't seem to
>get a vRefNum for the current folder at the time that the new
>button is hit.
>
>How can I get a handle into the "current working folder" from one of
>the "hook" functions that SFPGetfile provides??

Questions about selecting folders in standard file have to be among the
most common here; if this "USENET Mac Programmer's Guide" is real, I
hope it will contain an SFGetFile that does this.

Anyway, the answer to your question is to use low-memory globals.
CurDirStore and SFSaveDisk, documented in Inside Mac volume IV, track
the current position of the standard file dialog as it goes.  They
don't contain a working directory; that's only made when the user
clicks OK.  SFSaveDisk is the negative of the volume reference number,
and CurDirStore is the current directory ID.  When a folder is
selected, its dirID is stored in the fType field of the reply record.
You can use that plus -SFSaveDisk to find out what folder is selected;
using -SFSaveDisk with CurDirStore shows you which folder has been
descended into instead.  If you need a working directory at this level,
you will have to build it yourself using the volume reference number
and directory ID.
-- 
Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim
"I see little divinity about them or you.  You talk to me of Christianity
 when you are in the act of hanging your enemies.  Was there ever such
 blasphemous nonsense!" - Shaw, "The Devil's Disciple"