Created
May 7, 2010 16:29
-
-
Save nickludlam/393672 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment