What is the equivalent for kFSVolInfoFileCount on OS X 10.8 and later?

Xcode complains that FSGetVolumeInfo(catalogInfo.volume, 0, NULL, kFSVolInfoFileCount, &volumeInfo, NULL, NULL); is deprecated.


Problem:


The NSURLVolumeResourceCountKey key that would seem to provide the same piece of information using the -[NSURL getResourceValue:forKey:error:]; API does not return the same number of items. Maybe this explains why it says Resource instead of Files.


Question:


What is the equivalent for kFSVolInfoFileCount on OS X 10.8 and later?

Replies

The official answer is that:


- there's no exact replacement for this option in NSURL.


- NSURLVolumeResourceCountKey returns the number of files and folders.


- to obtain the number of files on a volumes (at least for a file system that supports this), it is recommended to use the Posix/BSD APIs: statfs or getattrlist with the ATTR_VOL_FILECOUNT attribute.