开发者

Testing out of space conditions in iPhone

开发者 https://www.devze.com 2022-12-29 10:49 出处:网络
What\'开发者_StackOverflow社区s the easiest way to simulate or create out of space conditions in iPhone, both on the simulator and on an actual device?

What'开发者_StackOverflow社区s the easiest way to simulate or create out of space conditions in iPhone, both on the simulator and on an actual device?

I would like to test the code that handles such situations.


Here is the code sample to calculate space:

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

+(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;  

}

Please note this is running perfectly for 3.x device. I am not sure for 2.x devices.


Thanks,
Jim.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号