[futurebasic] Hard disk free space?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2008 : Group Archive : Group : All Groups

From: Joe Lertola <joefb@...>
Date: Wed, 2 Jan 2008 01:27:20 -0500
I would like to get the free space on a hard disk so I can have my  
program refuse to save a file if there is not enough space on the hard  
disk for it to fit. I have been using the function below but I just  
noticed that it reports only 2 gb free when there is actually 65 gb  
available. Does any one know how to find the actual free space?
Thanks,
-Joe

'-----------------------------------------------------------
CLEAR LOCAL
DIM pbBlk.128, 63 vName$
LOCAL FN GetVolFreeSizes&(VCurDir)
dim as long freeBytes&, IoVAlBlkSiz&, IoVNmAlBlks&, IoVFrBlk&,  
IoTotalBytes&, IoTotalFree&
dim as int osErr%

freeBytes&=-1
pbBlk.ioNamePtr&      = @vName$'pointer to volume name

DO

INC WORD (@pbBlk.ioVolIndex%)'look for next mounted volume
osErr% = FN HGETVINFO (@pbBlk)'get original volume info

LONG IF osErr% = _noErr AND VCurDir = pbBlk.ioVRefNum%
'
'       --------- Get default < 2 Gig Drive sizes ----------
'
IoVAlBlkSiz& = pbBlk.ioVAlBlkSiz&'get block size
IoVNmAlBlks& = pbBlk.ioVNmAlBlks% AND &FFFF'calc size from unsigned  
integer
IoVFrBlk&    = pbBlk.ioVFrBlk%    AND &FFFF'get # free blocks on disk
IoTotalBytes& = IoVNmAlBlks& * IoVAlBlkSiz&
IoTotalFree&  = IoVFrBlk&    * IoVAlBlkSiz&
freeBytes&=IoTotalFree&
exit do'were done
END IF

UNTIL osErr%

END FN = freeBytes&