简体   繁体   English

iPhone:可用磁盘空间

[英]iPhone: available disk space

I am creating an audio-recording application and I need to know how much disk space is available (not ram). 我正在创建一个录音应用程序,我需要知道有多少磁盘空间可用(而不是ram)。

How can I retrieve it? 我怎样才能找回它?

Thanks. 谢谢。

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). 我没试过这个,但由于iPhone是基于UNIX的操作系统,你应该能够使用statfs系统调用获得flash文件系统上的可用空间(参见文档链接)。

Just use as parameter the path to the app directory that you plan to write to. 只需将您计划写入的app目录的路径用作参数即可。

Best solution for me is to use the NSFileManager method: 对我来说最好的解决方案是使用NSFileManager方法:

- (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. 这是statfs系统调用的包装器,如文档中所述。 But if you're already using NSFileManager, this would be the way to go. 但是如果你已经在使用NSFileManager,那么这就是你要走的路。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM