views:

867

answers:

1

I am looking for a way to determine how much free disk space there is available to my application.

I have tried using NSFileManager's fileSystemAttributesAtPath with NSFileSystemFreeSize, but this is giving me the total free space on the iPhone and not what is available to my application by the Sandbox.

I believe applications are limited to using 2 Gig of space, and need to show how much of the 2G is still available.

+1  A: 

You can use statfs(2) and check the f_bavail field. This is the amount of space available at the moment to an unprivileged application, so it should give you the modified space that your application is permitted to use.

You can see the iPhone version of the man page here.

Jason Coco