[net.micro.mac] Directory name from DirID?

grzm@zyx.UUCP (Gunnar Blomberg) (06/12/86)

	Is there a way to get the directory name from the directory id,
without searching through the directory tree or going to disk yourself?
If so, how is it done?

					Thanks in advance.

grzm@zyx.UUCP (06/13/86)

In article <157@zyx.UUCP> grzm@zyx.UUCP (me) writes:
>
>	Is there a way to get the directory name from the directory id,
>without searching through the directory tree or going to disk yourself?

	Yes, well, I just found out how to do it (after some serious
macsbugging...).  It seems that if you pass -1 as the FDirIndex to
_GetCatInfo it will ignore the filename you gave it and give back info
about the directory (including the name, of course...).  Is this documented
anywhere?
	Sorry to have bothered you all, but I was rather desperate (not
to mention tired...).
-- 
Gunnar Blomberg, ZYX, +46 8 653205, ...mcvax!enea!zyx!grzm

olson@endor.harvard.edu (Eric Olson) (06/13/86)

In article <157@zyx.UUCP> grzm@zyx.UUCP (Gunnar Blomberg) writes:
>
>	Is there a way to get the directory name from the directory id,
>without searching through the directory tree or going to disk yourself?
>If so, how is it done?

I believe there are not any system calls that will do this for you.
I had to do this, and ended up using the recursive hierarchical search-
all-files described in Apple Tech Note 68.  Note that you must check
the directory bit, and IF IT IS SET, ioDrDirID will be the directory ID
(which you match against) and ioNamePtr will be the name.  If the directory
bit is not set, ioDrDirID will be a File Number.  In either case, you MUST
reset ioDrDirID to the directory you are searching, since it is modified
by the call to reflect the file number of dirID of a directory.

The other alternative is to search the Catalog Tree file, but its format
is very hairy and subject to change.

-Eric

olson@harvard.UUCP (06/16/86)

In article <158@zyx.UUCP> grzm@zyx.UUCP (Gunnar Blomberg) writes:
>In article <157@zyx.UUCP> grzm@zyx.UUCP (me) writes:
>>
>>	Is there a way to get the directory name from the directory id,
>>without searching through the directory tree or going to disk yourself?
>
>	Yes, well, I just found out how to do it (after some serious
>macsbugging...).  It seems that if you pass -1 as the FDirIndex to
>_GetCatInfo it will ignore the filename you gave it and give back info
>about the directory (including the name, of course...).  Is this documented
>anywhere?
>	Sorry to have bothered you all, but I was rather desperate (not
>to mention tired...).
>-- 
>Gunnar Blomberg, ZYX, +46 8 653205, ...mcvax!enea!zyx!grzm

Unfortunately, this only works if you are referencing the directory with
a WDRefNum (essentially, a VRefNum-like number that refers to a volume AND
a directory).  That is to say:

	fname[0]=0;
	pb.ioCompletion=NIL;
	pb.ioNamePtr=fname;
	pb.ioVRefNum= <a WDRefNum, such as returned by SFGetFile>;
	pb.ioFDirIndex=-1;
	pb.ioDirID=0;

	PBGetCatInfo(&pb,FALSE);

will stuff the name of the directory referred to by the WD/VRefNum into
fname, it's DirID into ioDirID, and it's parent directory's DirID into
ioParID.

It will not, however, give you a directory's name from it's DirID.

-Eric

grzm@zyx.UUCP (Gunnar Blomberg) (06/20/86)

In article <20@harvard.UUCP> olson@endor.UUCP (Eric Olson) writes:
>In article <158@zyx.UUCP> grzm@zyx.UUCP (me) writes:
>>In article <157@zyx.UUCP> grzm@zyx.UUCP (me) writes:
>>>
>>>	Is there a way to get the directory name from the directory id,
>>>without searching through the directory tree or going to disk yourself?
>>
>>	Yes, well, I just found out how to do it (after some serious
>>macsbugging...).  It seems that if you pass -1 as the FDirIndex to [...]
>
>Unfortunately, this only works if you are referencing the directory with
>a WDRefNum (essentially, a VRefNum-like number that refers to a volume AND
>a directory).  [...]
>
>-Eric

	Well, it works for me...  Also, I have since gotten my hands onto
Tech Note 69, which explicitly says it should work.

					/Grzm
-- 
Gunnar Blomberg, ZYX, +46 8 653205, ...mcvax!enea!zyx!grzm