• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Calculating volume free space
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Calculating volume free space (From: email@hidden)

  • Prev by Date: DND & CoreData just a small blow of hand?
  • Next by Date: Re: Question regarding NSArrayController, KVO and Core Data
  • Previous by thread: Calculating volume free space
  • Next by thread: Re: Calculating volume free space
  • Index(es):
    • Date
    • Thread