iOS 获取手机存储空间的大小

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

@import Darwin.sys.mount;

int main(int argc, char * argv[]) {
    @autoreleasepool {
        struct statfs buf;
        long long freespace = 0;
        if (statfs("/", &buf) >= 0) {
            freespace = (long long)buf.f_bsize * buf.f_blocks;
        }
        if (statfs("/private/var", &buf) >= 0) {
            freespace += (long long)buf.f_bsize * buf.f_blocks;
        }
        printf("%lld\n",freespace);
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}