jackiw@cs.swarthmore.edu (Nick Jackiw) (10/30/89)
Last time, I asked. This time, I'll beg. PLEASE PLEASE PLEEEEZE reply
if you have the answer.
You can't SetVol(...) to the working directory returned by SFGetFile
under HFS. Even if you GetWDInfo and translate the wdRef into a volRef+
DirID, you can SetVol(...) to the volume (root directory) but not to
the DirID.
So how can you set the current default directory used by "Create", "Open",
and "OpenResFile" knowing only the SFReply.vRefnum?
Ideally, the technique should work transparently with non-HFS systems,
too (where it's trivial; you have no WDs).
THANK YOU THANK YOU THANK YOU Really, I mean it.
--
_ _|\____ Nick Jackiw | Visual Geometry Project | Math Department
/ /_/ O> \ ------------+-------------------------+ Swarthmore College
| O> | 215-328-8225| jackiw@cs.swarthmore.edu| Swarthmore PA 19081
\_Guernica_/ ------------+-------------------------+ USA
6600pete@hub.UUCP (10/31/89)
From article <3260@carthage.cs.swarthmore.edu>, by jackiw@cs.swarthmore.edu (Nick Jackiw): > You can't SetVol(...) to the working directory returned by SFGetFile > under HFS. Sure you can. I've done it lots. What error code are you getting back? -------------------------------------------------------------------- Pete Gontier, pete@cavevax.ucsb.edu; outgoing .UUCP addresses bounce This kid is looking for a job: Mac, DOS, C, Pascal, some 68000, 8088 excellent communication skills
blob@apple.com (Brian Bechtel) (10/31/89)
In article <3260@carthage.cs.swarthmore.edu> jackiw@cs.swarthmore.edu (Nick Jackiw) writes: > You can't SetVol(...) to the working directory returned by SFGetFile > under HFS. Even if you GetWDInfo and translate the wdRef into a volRef+ > DirID, you can SetVol(...) to the volume (root directory) but not to > the DirID. > > So how can you set the current default directory used by "Create", > "Open", and "OpenResFile" knowing only the SFReply.vRefnum? You use PBGetWDInfo (Inside Macintosh, page IV-159) to get the volume name (in ioNamePtr) and DirID (in ioWDDirID). To get the ioVRefNum given the name of the volume, the DirID, and the name of the file, use PBOpenWD (Inside Macintosh, page IV-158). --Brian Bechtel blob@apple.com "My opinion, not Apple's"
jackiw@cs.swarthmore.edu (Nick Jackiw) (11/01/89)
In article <2802@hub.UUCP> 6600pete@hub.UUCP writes: > From article <3260@carthage.cs.swarthmore.edu>, by jackiw@cs.swarthmore.edu (Nick Jackiw): > > You can't SetVol(...) to the working directory returned by SFGetFile > > under HFS. > > Sure you can. I've done it lots. What error code are you getting back? > -------------------------------------------------------------------- > Pete Gontier, pete@cavevax.ucsb.edu; outgoing .UUCP addresses bounce No error. Just no results. Seems to me the following program, which calls SFGetFile thrice, should on the last instance bring up the GetFile dialog in the same directory/volume as a file was chosen in on the first instance. Got that? (Default:=SFGetfile1; RememberFirstDir:=Default; NewDefault:=SFGetFile2; SET_VOL(RememberFirstDir); now SFGetFile3. I'd think that SFGetFile3 would show up in RememberFirstDir, but it doesn't; it comes up in whatever Dir you left it in at the end of SFGetFile2. Here's the code: ------------------------- program SetVolTest; var where: point; types: SFTypeList; reply: SFReply; oldDir: integer; theErr: OSerr; begin types[0] := 'TEXT'; SetPt(where, 100, 150); SFGetFile(where, '', nil, 1, types, nil, reply); {Get first directory} oldDir := reply.vRefNum; {Remember its WDrefnum} SFGetFile(where, '', nil, 1, types, nil, reply); {Allow user to move to 2nd directory} theErr := SetVol(nil, oldDir); {Attempt to go back to first} SFGetFile(where, '', nil, 1, types, nil, reply) end. ------------------------- My lightbulb remains perpetually dim. Thanks for any assistance, Nick -- _ _|\____ Nick Jackiw | Visual Geometry Project | Math Department / /_/ O> \ ------------+-------------------------+ Swarthmore College | O> | 215-328-8225| jackiw@cs.swarthmore.edu| Swarthmore PA 19081 \_Guernica_/ ------------+-------------------------+ USA
tim@hoptoad.uucp (Tim Maroney) (11/02/89)
From article <3260@carthage.cs.swarthmore.edu>, by jackiw@cs.swarthmore.edu (Nick Jackiw): > You can't SetVol(...) to the working directory returned by SFGetFile > under HFS. In article <2802@hub.UUCP> 6600pete@hub.UUCP writes: > Sure you can. I've done it lots. What error code are you getting back? In article <3273@carthage.cs.swarthmore.edu> jackiw@carthage (Nick Jackiw) writes: >No error. Just no results. Seems to me the following program, which >calls SFGetFile thrice, should on the last instance bring up the GetFile >dialog in the same directory/volume as a file was chosen in on the first >instance. Got that? Ah-hah! This once again goes to show how important it is to list your symptoms in detail. If you'd said this, you would have been besieged by messages pointing out that Standard File and the current HFS directory have almost nothing to do with each other. If you have to set the directory for Standard File (and this *is* sometimes a valid operation, though indiscriminate use can confuse the user -- remember that power users in particularly frequently "blind type" to Standard File and expect it to work predictably) you do it with a pair of low-memory globals called SFSaveDisk (negative of volume reference number) and CurDirStore (directory id). I demonstrated this technique in the code I just posted on hacking Standard File to select folders. It's more or less documented in Inside Mac IV, chapter 15. Set these globals to the necessary values before your call to Standard File. To do this with a working directory reference number, like the one you get from Standard File, you have to convert the working directory into a volume/folder pair. You do this like so: SFVolDir(wd, volume, folder) short wd, *volume; long *folder; { WDPBRec pb; char name[72]; pb.ioNamePtr = (StringPtr)name; pb.ioVRefNum = wd; pb.ioWDIndex = 0; pb.ioWDProcID = 0; pb.ioWDVRefNum = 0; PBGetWDInfo(&pb, false); if (pb.ioResult) return pb.ioResult; *volume = pb.ioWDVRefNum; *folder = pb.ioWDDirID; return noErr; } -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "Now hear a plain fact: Swedenborg has not written one new truth: Now hear another: he has written all the old falshoods. And now hear the reason. He conversed with Angels who are all religious, & conversed not with Devils who all hate religion..." - Blake, "The Marriage of Heaven and Hell"
Alex.Maluta@f135.n102.z1.FIDONET.ORG (Alex Maluta) (11/04/89)
You CAN use SetVol() with the working directory returned by SFGetFile(). I do this all the time, then use standard pascal reset() and rewrite() procedures. However, remember that this is only a working directory and the system has a limit (40 I think) of them. Using the working directory number right after a call to SFGetFile() should be no problem, but you may run into problems if you hold onto the WDRefNum for a while (such as placing it into a queue) since the system may clear a working directory on you. If you need to make a working directory permanent, call GetWDInfo() to get a dirID, then use the HSetVol() procedure. . By the way, passing the working directory from SFGetFile() to SetVol() is the primary way compatability was maintained from MFS to HFS. . At least that's the way I understand it ... . Alex Maluta -- Alex Maluta via cmhGate - Net 226 fido<=>uucp gateway Col, OH UUCP: ...!osu-cis!n8emr!cmhgate!102!135!Alex.Maluta INET: Alex.Maluta@f135.n102.z1.FIDONET.ORG