在下载文件之前检查 iphone 设备上的足够空间 [英] check enough space on iphone device before downloading files

查看:27
本文介绍了在下载文件之前检查 iphone 设备上的足够空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我可以成功下载远程文件了,

right now i am able to download remote files successfully,

但这仅当用户选择多个文件名并按下下载时用户可以选择一个文件.因此,在下载文件之前,我想检查 iPhone 上是否有足够的空间,如果是,则下载,如果没有,则用户可以看到消息框空间不足",他将取消选中几个文件名,然后他可以从服务器下载文件...

but this is only if user can select one file if user select multiple file names and press download. So before downloading files i want to check is there enough space on iphone if yes then download and if not then user can see message box "not enough space" and he will uncheck few filename and then he can download files from server...

有没有办法在下载前检查可用空间?

is there any way to check free space before downloading?

先谢谢你

推荐答案

使用这个功能:

#include <sys/param.h>  
#include <sys/mount.h>  

+(float) diskSpace {  
    NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);  
    struct statfs tStats;  
    statfs([[paths lastObject] cString], &tStats);  
    float total_space = (float)(tStats.f_blocks * tStats.f_bsize);  

    return total_space;  

    // for freespace:
    // float free_space = (float)(tStats.f_bavail * tStats.f_bsize);
    // return free_space
}

这篇关于在下载文件之前检查 iphone 设备上的足够空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆