Ilya Suzdalnitski
Ilya Suzdalnitski

Reputation: 53540

iPhone: available disk space

I am creating an audio-recording application and I need to know how much disk space is available (not ram).

How can I retrieve it?

Thanks.

Upvotes: 3

Views: 1657

Answers (3)

Matt Connolly
Matt Connolly

Reputation: 9857

Best solution for me is to use the NSFileManager method:

- (NSDictionary *)attributesOfFileSystemForPath:(NSString *)path error:(NSError **)error

on the directory where you want to save your data. This is a wrapper around the statfs system call, as is mentioned in the docs. But if you're already using NSFileManager, this would be the way to go.

Upvotes: 4

Gordon Potter
Gordon Potter

Reputation: 5862

This is probably a useful example.

http://kdbdallas.com/2008/12/27/maciphone-show-availble-useable-diskspace/

Upvotes: 2

frankodwyer
frankodwyer

Reputation: 14048

I haven't tried this, but since the iPhone is a UNIX based OS you should be able to get the free space on the flash file system using the statfs system call (see link for documentation).

Just use as parameter the path to the app directory that you plan to write to.

Upvotes: 5

Related Questions