开发者

Testing out of space conditions in iPhone

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜