Re: Calculating volume free space
Re: Calculating volume free space
- Subject: Re: Calculating volume free space
- From: Will Mason <email@hidden>
- Date: Sun, 15 Jan 2006 16:04:42 -0800 (PST)
What is the type of bytesFree? If it's unsigned int, then you're suffering an overflow problem. Your best bet would be to max out by using unsigned long long.
Hope that's the problem,
Will
----- Original Message ----
From: email@hidden
To: email@hidden
Sent: Sun Jan 15 17:53:17 2006
Subject: Calculating volume free space
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.
Is there another API I should be using besides statfs? I couldn't find
anything appropriate in NSWorkspace or NSFileManager.
_______________________________________________
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