Re: Calculating volume free space
Re: Calculating volume free space
- Subject: Re: Calculating volume free space
- From: glenn andreas <email@hidden>
- Date: Sun, 15 Jan 2006 17:59:01 -0600
On Jan 15, 2006, at 5:53 PM, email@hidden wrote:
I would like to calculate the volume free space (a la Finder's Get
Info)
but I am not getting the results I expected. I have code similar
to the
following:
if(-1 == statfs(tmpDir, &buf)) {
// handle error
}
bytesFree = buf.f_bsize * buf.f_bfree;
The value I get for bytesFree is something strange; df shows I have
84226328 available (about 40GB, which checks with Finder) but the
bytesFree in the above calculation comes out to 438489088 (about
418 MB).
Obviously I am doing something incorrectly here.
Since both f_bsize and f_bfree are declared as longs, the
multiplication here will be long * long = long, i.e., 32 bits, which
can't hold 40GB.
You need to make sure that you are using the long long multiplication.
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
Widgetarium | the quickest path to widgets
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden