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

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

Recently I asked:

> 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?).

I got helpful answers from several people (thanks especially to Jim
Matthews@Dartmouth).  If I understand the situation right,

1) You can pass a vRefNum instead of a drvNum to GetVInfo.  It'll
figure out which drive you mean.

2) You don't want to do this, because GetVInfo can return bogus info
under HFS.  So can PBGetVInfo.  Tech Note 157 describes this, and gives
MPW Pascal and MPW C code to call PBHGetVInfo for the right answer.  I
ported the MPW C code to Think C without any trouble.

Incidentally, if you want to give the user the free space in Kbytes,
divide by 1,024 (not 1000) to match the Finder's results.

 -- 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.