What'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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With