iPhone 取得磁盘的全部和剩余空间

 

这段代码示范怎么取得iphone的剩馀磁碟空间,还有全部磁碟空间。#include <sys/param.h> #include <sys/mount.h> long long freeSpace() { struct statfs buf; long long freespace = -1; if(statfs("/", &buf) >= 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], &tStats); float totalSpace = (float)(tStats.f_blocks * tStats.f_bsize); return totalSpace; }  

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