[comp.sys.mac.programmer] Is AppFile.vRefNum always WDRefNum???

gft_robert@gsbacd.uchicago.edu (opcode ranger) (02/05/91)

-- 

I have a question regarding the vRefNum field in the AppFile data type: under
HFS is this actually a WDRefNum?  Is it guaranteed to be a WDRefNum?

My problem is this: I need to get the dirID (parent dir id) for each file I get
AppFile information for (i.e. for each file which is opened from the Finder
with the application).  If I know this field is a WDRefNum I can call
PBGetWDInfo() on it and find the dirID.  If it's not always a WDRefNum I'm not
sure if this call will work.

Any help greatly appreciated!

Robert


============================================================================
= gft_robert@gsbacd.uchicago.edu * generic disclaimer: * "It's more fun to =
=            		         * all my opinions are *  compute"         =
=                                * mine                *  -Kraftwerk       =
============================================================================

mneerach@iiic.ethz.ch (Matthias Ulrich Neeracher) (02/07/91)

In article <1991Feb4.190115.1@gsbacd.uchicago.edu>, gft_robert@gsbacd.uchicago.edu (opcode ranger) writes:
|> I have a question regarding the vRefNum field in the AppFile data type: under
|> HFS is this actually a WDRefNum?  Is it guaranteed to be a WDRefNum?

No. It is certainly not a WDRefNum for a file residing on a MFS volume, and
I believe also that it's no WDRefNum for files on the 'root' level of a HFS
volume.

|> My problem is this: I need to get the dirID (parent dir id) for each file I get
|> AppFile information for (i.e. for each file which is opened from the Finder
|> with the application).  If I know this field is a WDRefNum I can call
|> PBGetWDInfo() on it and find the dirID.  If it's not always a WDRefNum I'm not
|> sure if this call will work.

There is a Technote which describes a technique to determine whether a vRefNum
is a WDRefNum: WDRefNums are given numbers -32768, -32767, -32766 or, if you
prefer hex, $8000, $8001, $8002. Normal vRefNums have numbers 'close to zero'.

Matthias

-- 
Matthias Neeracher                                   mneerach@iiic.ethz.ch
   "These days, though, you have to be pretty technical before you can 
    even aspire to crudeness." -- William Gibson, _Johnny Mnemonic_

gft_robert@gsbacd.uchicago.edu (opcode ranger) (02/09/91)

---
In article <24152@neptune.inf.ethz.ch>, mneerach@iiic.ethz.ch (Matthias Ulrich Neeracher) writes:
> In article <1991Feb4.190115.1@gsbacd.uchicago.edu>, gft_robert@gsbacd.uchicago.edu (opcode ranger) writes:
[...]
> |> My problem is this: I need to get the dirID (parent dir id) for each file I get
> |> AppFile information for (i.e. for each file which is opened from the Finder
> |> with the application).  If I know this field is a WDRefNum I can call
> |> PBGetWDInfo() on it and find the dirID.  If it's not always a WDRefNum I'm not
> |> sure if this call will work.
> 
> There is a Technote which describes a technique to determine whether a vRefNum
> is a WDRefNum: WDRefNums are given numbers -32768, -32767, -32766 or, if you
> prefer hex, $8000, $8001, $8002. Normal vRefNums have numbers 'close to zero'.


I did some empirical tests.  Actually if you pass PBGetWDInfo() the vRefNum of
the root of the volume (or whatever is included in the AppFile.vRefNum field
when you launch a file on the root level), PBGetWDInfo() seems to return the
correct information.  So I just pass it whatever I get in AppFile.vRefNum and I
can get back the true vRefNum and the dirID.  Of course this won't work on MFS
volumes, but I'm prepared to limit the users in that regard.

Is there some call in Sys7 which takes a WDRefNum and file name and returns a
FSSpec?  I wrote my own, but if there's a ToolBox call that would be nice too.

Robert



============================================================================
= gft_robert@gsbacd.uchicago.edu * generic disclaimer: * "It's more fun to =
=            		         * all my opinions are *  compute"         =
=                                * mine                *  -Kraftwerk       =
============================================================================

keith@Apple.COM (Keith Rollin) (02/10/91)

In article <1991Feb8.204505.1@gsbacd.uchicago.edu> gft_robert@gsbacd.uchicago.edu (opcode ranger) writes:
>
>Is there some call in Sys7 which takes a WDRefNum and file name and returns a
>FSSpec?  I wrote my own, but if there's a ToolBox call that would be nice too.

Um...it's in IM VI, and in the MPW and THINK headers, which you should
have if you have System 7.0. The routine you are looking for is
FSMakeFSSpec. It takes any combination of vRefNum (which could also be
a WD), dirID, and string (which could be a full or partial pathname),
and fills out an FSSpec record.

It is recommended that the only way you fill out an FSSpec is by 
calling this routine.

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions