[comp.sys.mac.programmer] Launching application returned in an SFReply record.

braun-eric@CS.YALE.EDU (Eric E. Braun) (08/15/90)

Im having difficulty implementing the transfer function...  Works
Fine when I give _launch the full pathname of the application to launch
but when I get the file name from SFGetFile tack a ':' onto the front
of it and then call PBOpenWD (which returns with no err condition) with:
 pb.ioWDDirID  = CurDirStore
 pb.ioRefNum   = SFReply.vRefNum
 pb.ioWDProcID = my application's signature
Launch still gives me the Application missing dialog box as if I hadn't.
Changed directories at all..
What am I missing? Any better Ideas all together on how to implement
this?  Is there any function hidden in IM somplace that returns a full
path name given an SFReply?

Somebody care to help a lost soul?

russotto@eng.umd.edu (Matthew T. Russotto) (08/15/90)

In article <25810@cs.yale.edu> braun-eric@CS.YALE.EDU (Eric E. Braun) writes:
>Im having difficulty implementing the transfer function...  Works
>Fine when I give _launch the full pathname of the application to launch
>but when I get the file name from SFGetFile tack a ':' onto the front
>of it and then call PBOpenWD (which returns with no err condition) with:
> pb.ioWDDirID  = CurDirStore
> pb.ioRefNum   = SFReply.vRefNum
I assume you mean pb.ioVRefnum-- ioRefnum != ioVRefNum
> pb.ioWDProcID = my application's signature

I don't think you are supposed to set ioWDProcID to anything but 'ERIK' any
more, but that isn't your problem.  You need to not only open the directory,
you need to SetVol to it.
--
Matthew T. Russotto	russotto@eng.umd.edu	russotto@wam.umd.edu
][, ][+, ///, ///+, //e, //c, IIGS, //c+ --- Any questions?

nmday@apple.com (Neil) (08/18/90)

-- Is there any function hidden in IM somplace that returns a full
-- path name given an SFReply?

There is no toolbox routine to return a full path name, but doing it 
yourself is fairly easy. 
Here is a C routine to do it (gleaned from some DTS sample code)...

/*
**pathName (dirID,vRefNum,s)
**returns a string containing the full pathname to the current file or 
directory
**this code is snached from the DTS sample code StdFile.c (but slightly 
modified).
**Added support for both files and directories.  Don't give a flying *#@! 
if it 
**breaks under A/UX, thank you very much....
*/
char *pathName(dirID,vRefNum,s)
long dirID;
short vRefNum;
char *s;
{
  OSErr err;            /* error container                    */
  CInfoPBRec block;     /* infoBlock to be used CatInfo calls */
  Str255 directoryName; /* a place to stuff my directory name */

  *s = 0;
  block.dirInfo.ioNamePtr = &directoryName;

  block.dirInfo.ioDrParID = dirID;

  do {
    block.dirInfo.ioFDirIndex = -1; /* Specify vRefNum and DirID for call */
    block.dirInfo.ioVRefNum = vRefNum; /* set the ParamBlock's vRefNum       */
    block.dirInfo.ioDrDirID = block.dirInfo.ioDrParID; /* set the ParamBlock's
DirID         */

    err = PBGetCatInfo (&block,false);/* get information on catalogue       */
    if (err) break;/* get me outta here......            */

    pStrcat (&directoryName,"\p:");/* add a colon to the begining...     */
    pStrcat (&directoryName,s);/* prepose newly found directory name */
    pStrcpy (s,&directoryName);/* swap the two  */

    } while (block.dirInfo.ioDrDirID != fsRtDirID);/* loop till we hit the 
root */

    return (s);/* cough up the result  */
}

Hope that was helpfull.

Neil Day

The oppinions presented above are my own - any resemblance to those of 
Apple Computer are purely coincidental.

topping@anaconda.cis.ohio-state.edu (brian e topping) (08/19/90)

In article <9816@goofy.Apple.COM> nmday@apple.com (Neil) writes:
>
>-- Is there any function hidden in IM somplace that returns a full
>-- path name given an SFReply?
>
>There is no toolbox routine to return a full path name, but doing it 
>yourself is fairly easy. 
>Here is a C routine to do it (gleaned from some DTS sample code)...

Here is the same thing (I think) that I use

short constructPath(cRecPtr,pathName,dirID)
CInfoPBRec	*cRecPtr;
char		*pathName;
long		dirID;

{
char		buffer[32];
short		error;

	if (dirID == 1)
		return(0);
		
	cRecPtr->dirInfo.ioDrDirID = dirID;
	cRecPtr->dirInfo.ioNamePtr = buffer;
	cRecPtr->dirInfo.ioFDirIndex = -1;
	if (error = PBGetCatInfo(cRecPtr,false))
		return(error);
	
	if (error = constructPath(cRecPtr,pathName,cRecPtr->dirInfo.ioDrParID))
		return(error);
	
	BlockMove(&(buffer[1]),&(pathName[pathName[0]+1]),buffer[0]);
	pathName[0] += buffer[0];
	pathName[++pathName[0]] = ':';

	return(0);
}

It basically stacks all the names as it follows up to the root, and copies
on the way back down.  Interesting, I thought (when I think).



>Neil Day

Brian Topping
<topping@cis.ohio-state.edu>