ios如何取得iphone/ipad的磁盘空间

ios如何取得iphone/ipad的磁盘空间

02.08.2012, Iphone, by H_z, 320 views.
本文转自:http://www.wangdg.com/?p=597 代码如下:
#include <sys/param.h>   
#include <sys/mount.h>
long long freeSpace() {
    struct statfs buf;
    long long freespace = -1;
    if(statfs("/", &amp;buf) &gt;= 0){
        freespace = (long long)buf.f_bsize * buf.f_bfree;
    }
 
    return freespace;
}
 
+(float)getTotalDiskSpaceInBytes {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    struct statfs tStats;
    statfs([[paths lastObject] cString], &amp;tStats);
    float totalSpace = (float)(tStats.f_blocks * tStats.f_bsize);   
 
    return totalSpace;
}

你可能感兴趣的:(ios,struct,iPhone,float,磁盘)