Path: utzoo!mnetor!uunet!husc6!bbn!uwmcsd1!ig!jade!ucbvax!hoptoad!tim
From: tim@hoptoad.uucp (Tim Maroney)
Newsgroups: comp.sys.mac
Subject: Re: Reading a full pathname in HFS
Message-ID: <3551@hoptoad.uucp>
Date: 9 Dec 87 04:28:15 GMT
References: <1062@oakhill.UUCP>
Reply-To: tim@hoptoad.UUCP (Tim Maroney)
Organization: Sun Microsystems, TOPS Division, Berkeley
Lines: 26

In article <1062@oakhill.UUCP> jayn@oakhill.UUCP (Jay Norwood) writes:
>
>Can anyone tell me how to reconstruct the entire pathname of a file that
>has been selected with the SFGetFile function?  Lets say the file
>has a full pathname hd:csource:hello.c.  Calling SFGetfile only returns
>a string that says "hello.c".  Where can I get the rest of the pathname?
>Thanks for any help.
>Jay Norwood

It's pretty easy, provided all the magic numbers involved are clear to you.
If not, I'm not going to explain them here, but briefly, there are volume
reference numbers, directory ids, and working directory reference numbers.
Standard File returns a working directory reference number, which you can
convert to a (volume, directory) pair by using PBGetWDInfo, or just grabbing
CurDirStore and the other Standard File global (damn, that's embarassing) if
you're lazy.

Once you have the (volume, directory) pair, you can call PBGetCatInfo to
find out what the folder they refer to is named.  Then just concatenate that
with your reply.fName, and you've got a full pathname.  Two HFS traps and a
little trivial string twiddling, and it's party time in Mac City.

Make sure you're running HFS before you do any of this junk....
-- 
Tim Maroney, {ihnp4,sun,well,ptsfa,lll-crg}!hoptoad!tim (uucp)
hoptoad!tim@lll-crg (arpa)