[comp.sys.mac.programmer] finding amount of free disk space?

mikem@uhccux.uhcc.hawaii.edu (Mike Morton) (10/03/89)

I've got a document open which a user specified with SFGetFile, so all I
have to identify it is a vRefNum and a name.  I'd like to find out how
much free space there is on the drive on which the document is stored
(i.e., how much more can I expand the document?).

It looks like I want to use GetVInfo, which takes a drvNum as a parameter.
If so, how do I map a vRefNum to the drvNum containing it?  If not, what's
the right way?

I bet this is a really easy one, so please email to me and I'll summarize
to the net.  Thanks in advance.

 -- Mike Morton // P.O. Box 11378, Honolulu, HI  96828, (808) 676-6966 HST
      Internet: mikem@uhccux.uhcc.hawaii.edu
    (anagrams): Mr. Machine Tool; Ethical Mormon; Chosen Immortal; etc.

blob@apple.com (Brian Bechtel) (10/09/89)

In article <4995@uhccux.uhcc.hawaii.edu> mikem@uhccux.uhcc.hawaii.edu 
(Mike Morton) writes:
> I've got a document open which a user specified with SFGetFile, so all I
> have to identify it is a vRefNum and a name.  I'd like to find out how
> much free space there is on the drive on which the document is stored
> (i.e., how much more can I expand the document?).
> 
> It looks like I want to use GetVInfo, which takes a drvNum as a 
> parameter. If so, how do I map a vRefNum to the drvNum containing it? 
>  If not, what's the right way?

Call PBHGetVInfo, passing an ioCompletion of NIL, ioNamePtr of NIL, 
ioVRefNum of the vRefNum gotten from SFGetFile, and ioVolIndex of 0.  
You'll get back ioVFrBlk and ioVAlBlkSiz.  Multiply those together to get 
the free bytes on the disk.  Or, if you're lazy, pass ioVDrvInfo to your 
high level call of GetVInfo, and you'll get the multiplication done for 
you.

--Brian Bechtel     blob@apple.com     "My opinion, not Apple's"