[comp.sys.mac.programmer] Pathname to wd ?

ews00461@uxa.cso.uiuc.edu (06/05/90)

This seems trivial...

How can I convert a full path name to a working directory refnum ?

I know how to go  the other way around...

Eric W Sink

enwall@apple.com (Tim Enwall) (06/07/90)

In article <1234600036@uxa.cso.uiuc.edu> ews00461@uxa.cso.uiuc.edu writes:
> How can I convert a full path name to a working directory refnum ?

Eric,

I don't know off-hand how to accomplish this.  Pretty much there are only 
a few routines I know of which RETURN a wdRefNum.  Most now return the 
real vRefNum.

I will say this though: in general, I and most people here in DTS, stay as 
far away from wdRefNums as possible.  True, StandardFile does return a 
wdRefNum (and there are others which do too), but I convert the wdRefNum 
to the real vRefNum/dirID pair with PBGetWDInfo.  And then I don't have to 
worry about the wdRefNum.  The whole Working Directory "thang" is there 
purely for compatibility with MFS directory structures, and is almost 
obsolete.

You CAN get the vRefNum and the dirID with the full pathname (I think 
PBGetCatInfo will work, or one of those).

Anyway, hope this helps.  (BTW: MPW provides some routines like 
PBHOpenResFile which return vRefNum/dirID pairs rather than wdRefNums.  
Those can be very useful).

Tim Enwall,
Developer Technical Support neophyte.

mxmora@unix.SRI.COM (Matt Mora) (06/07/90)

In article <8572@goofy.Apple.COM> enwall@apple.com (Tim Enwall) writes:
>In article <1234600036@uxa.cso.uiuc.edu> ews00461@uxa.cso.uiuc.edu writes:
>> How can I convert a full path name to a working directory refnum ?
>
>Eric,
>
>I don't know off-hand how to accomplish this.  Pretty much there are only 
>a few routines I know of which RETURN a wdRefNum.  Most now return the 
>real vRefNum.
>
 [stuff deleted]

>Tim Enwall,

This might help a bit but might not be exactly what you want.
Its from page 118 of UMPG

The original posting was from Tim Maroney.


And on the theory that you might want to convert the name back some day,
 here's a routine I use for that.  Notice that it will actually create the
 directory if it doesn't exist now.  If this isn't what you want, throw away
 the error recovery code.


FullToFolder(StringPtr name, short *volume, long *folder)
{	CInfoPBRec dirInfo; HVolumeParam hvp; short i;
	dirInfo.dirInfo.ioNamePtr = name;
	dirInfo.dirInfo.ioDrDirID = 0;
	dirInfo.dirInfo.ioVRefN.dirInfo.ioResult == dirNFErr)
	{	dirInfo.dirInfo.ioNamePtr = (StringPtr)name;
		dirInfo.dirInfo.ioDrDirID = 0;
		dirInfo.dirInfo.ioVRefNum = 0;
		if (PBDirCreate((HParmBlkPtr)&dirInfo, false) == = dirInfo.dirInfo.ioDrDirID;
		}
		else {	*volume = 0, *folder = 0;
			return dirInfo.dirInfo.ioResult;
		}
	}
	else	{ *volume = 0, *folder = 0; return dirInfo.dirInfo.ioResult; }
	return noErr;
}
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com



-- 
___________________________________________________________
Matthew Mora
SRI International                       mxmora@unix.sri.com
___________________________________________________________