[comp.sys.mac.programmer] PBHGetVInfo returns noErr but volRefNum=-1

gft_robert@gsbacd.uchicago.edu (05/08/90)

Well, I have for the first time delved into the PB calls, and am having some
problems.  At one point in my program I'm trying to convert a volume name to a
vol ref num and I do the following:
        
    volName := concat(volName, ':');
    paramBlock := HParmBlkPtr(NewPtr(SIZEOF(HParamBlockRec)));
    if paramBlock <> nil then
     begin
      paramBlock^.ioCompletion := nil;
      paramBlock^.ioNamePtr := @volName;
      paramBlock^.ioVRefNum := 0;
      paramBlock^.ioVolIndex := -1;
      theOSErr := PBHGetVInfo(paramBLock, FALSE);

      etc.

I get noErr (0) for theOSErr, but ioVRefNum comes back as -1.  What am I doing
wrong?  

Any info much appreciated! (BTW, is there a clearer exposition of the PB calls
in general than in IM IV?  I've re-read it a couple of times, and though it's
well-written, it could be a bit more explicit at times.)

Robert

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

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

In article <9166@tank.uchicago.edu> gft_robert@gsbacd.uchicago.edu writes:
>I get noErr (0) for theOSErr, but ioVRefNum comes back as -1.  What am I doing
>wrong?  
>
>Any info much appreciated! (BTW, is there a clearer exposition of the PB calls
>in general than in IM IV?  I've re-read it a couple of times, and though it's
>well-written, it could be a bit more explicit at times.)

You did NOTHING, repeat NOTHING wrong.  -1 is the correct value for
the ioVRefNum for the first volume mounted!!
--
Matthew T. Russotto	russotto@eng.umd.edu	russotto@wam.umd.edu
][, ][+, ///, ///+, //e, //c, IIGS, //c+ --- Any questions?

kk@mcnc.org (Krzysztof Kozminski) (05/08/90)

In article <9166@tank.uchicago.edu> gft_robert@gsbacd.uchicago.edu writes:
>Well, I have for the first time delved into the PB calls, and am having some
>problems.  At one point in my program I'm trying to convert a volume name to a
>vol ref num and I do the following:
> [OK code deleted]
>I get noErr (0) for theOSErr, but ioVRefNum comes back as -1.  What am I doing
>wrong?  

Nothing wrong, -1 is a correct result. volRefNums are small negative
numbers.  Perhaps you're thinking about path reference numbers (like
those returned by the standard file dialogs) to be used with things
like FSOpen and such.  To get a large negative number you expect (I
think) you'll need to make a working directory.  Or, alternately, use
hierarchical versions of the file routines (see TN 218).

>Any info much appreciated! (BTW, is there a clearer exposition of the PB calls
>in general than in IM IV?  I've re-read it a couple of times, and though it's
>well-written, it could be a bit more explicit at times.)

Technical Notes can clarify some things, and some sample code therein
is quite informative...

KK
-- 
Kris Kozminski   kk@mcnc.org
"The party was a masquerade; the guests were all wearing their faces."

tim@hoptoad.uucp (Tim Maroney) (05/09/90)

In article <9166@tank.uchicago.edu> gft_robert@gsbacd.uchicago.edu writes:
>Well, I have for the first time delved into the PB calls, and am having some
>problems.  At one point in my program I'm trying to convert a volume name to a
>vol ref num and I do the following:
>        
>I get noErr (0) for theOSErr, but ioVRefNum comes back as -1.  What am I doing
>wrong?  

Nothing.  -1 is a perfectly valid volume reference number.  Volume
reference numbers are small negative integers.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"Americans will buy anything, as long as it doesn't cross the thin line
 between cute and demonic." -- Ian Shoales