I am using following code to get the available disk space of the startup disk.
NSFileManager *fm = [NSFileManager defaultManager];
double freeSpace = 0.0;
NSDictionary *attr = [[NSFileManager defaultManager] attributesOfFileSystemForPath:@"/" error:nil];
if (!error) {
freeSpace = [[attr objectForKey:NSFileSystemFreeSize] doubleValue];
}
//Convert from bytes to GB.
freeSpace = freeSpace/(1024*1024*1024);
But for MacOS 10.6 and above, it is giving the wrong size. After a while, I found out that for 10.5, we need to divide it by (1024*1024*1024) to get the correct available size. And for 10.6 and above, I have to divide it by (1000*1000*1000) to get correct size (which is displayed in Finder when we do right click on HardDisk -> Get Info). Now, I don't think dividing by 1000 instead of 1024 is the correct way for converting from KB to MB or whatever. So why is it like this in Mac 10.6 and above?
Is there any other function through which I can get available startup disk space correct upto 2 decimal points?