ar4@sage.cc.purdue.edu (Piper Keairnes) (03/28/90)
Does anyone notice anything wrong with this code??? It works when the ThinkC
debugger is running, but it does nothing when run alone. Also, sometimes, I
get a periodic crash with error #12... ideas?
SFPPutFile(where, "\p", "\pgarbage", NIL, &reply, SELECT_DIALOG, NIL);
if (reply.good) {
pb.fileParam.ioCompletion = NIL;
pb.fileParam.ioNamePtr = (StringPtr) "\pHowdy!";
pb.fileParam.ioVRefNum = reply.vRefNum;
err = PBDirCreate(&pb, FALSE);
}
What I want this to do is create the folder named "Howdy!" inside the directory
that is returned when I press my button called 'Select' in the folder (just the
renamed OK button, and the text fields are hidden from view in the dialog.
Also, this works in the debugger without the ioDirID field filled. But when I
specify the ioDirID as reply.vRefNum... it says folder not found.
-----
Piper Keairnes
ar4@sage.cc.purdue.edu
chrisj@netcom.UUCP (Christopher T. Jewell) (03/28/90)
In article <3895@sage.cc.purdue.edu> ar4@sage.cc.purdue.edu (Piper Keairnes) writes >Does anyone notice anything wrong with this code??? It works when the ThinkC >debugger is running, but it does nothing when run alone. Also, sometimes, I >get a periodic crash with error #12... ideas? > > > SFPPutFile(where, "\p", "\pgarbage", NIL, &reply, SELECT_DIALOG, NIL); > > if (reply.good) { > pb.fileParam.ioCompletion = NIL; > pb.fileParam.ioNamePtr = (StringPtr) "\pHowdy!"; > pb.fileParam.ioVRefNum = reply.vRefNum; > > err = PBDirCreate(&pb, FALSE); > } > > >What I want this to do is create the folder named "Howdy!" inside the directory >that is returned when I press my button called 'Select' in the folder (just the >renamed OK button, and the text fields are hidden from view in the dialog. > >Also, this works in the debugger without the ioDirID field filled. But when I >specify the ioDirID as reply.vRefNum... it says folder not found. The vRefNum returned by SFPPutFile is a working directory refnum, a *short* integer which stands *temporarily* for a particular directory on a particular disk. By itself, a wdRefNum is enough to specify both the volume and the directory, but only temporarily. If you reboot your machine, or just do a CloseWD and then run some other program, you may find that the same wdRefNum now refers to a different directory on the same or a different volume. A directory ID, on the other hand, is a *long* integer which is assigned when the directory is created, and is never reassigned to another file or directory on the same volume until you reformat the volume. If you reboot your machine and then go look at the directory, it will have the same dirID as before. (Directory id's and file id's are assigned sequentially, sort of like serial numbers for all the files and directories which have ever been created on this volume since it was formatted.) PBDirCreate wants to know the directory ID of the parent directory in which the new directory is to be created, but Piper gave it a wdRefNum instead. You can find out the dirID associated with a wdRefNum (in this case, pb.fileParam.ioVRefNum) by calling to PBGetWDInfo (IM IV-159). If the ioDirID is passed in to PBDirCreate as 0, the new directory gets created at the root level. (IM IV-146) This is probably what happened when Piper ran under the debugger and it seemed to work ok. The value 2 would have the same effect, since the root directory always has a dirId of 2. (IM IV-92) -- Chris (Christopher T. Jewell) chrisj@netcom.uucp apple!netcom!chrisj