Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Check that you have a minimum amount of disk space free on an iPhoneOS device
- - (BOOL)hasDiskSpaceAvailable {
- NSUInteger minimumDiskSpace = 400 * 1024 * 1024; // 400MB limit
- NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
- struct statfs tStats;
- statfs([[paths lastObject] cString], &tStats);
- NSUInteger availableDisk = tStats.f_bavail * tStats.f_bsize;
- NSLog(@"Available disk is %d", availableDisk);
- if (availableDisk < minimumDiskSpace) { // availableDisk is less than 400MB
- return NO;
- } else {
- return YES;
- }
- }
Add Comment
Please, Sign In to add comment