#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; }
ios如何取得iphone/ipad的磁盘空间
最新推荐文章于 2024-08-13 10:30:40 发布