
Get File Size (OS X) With Error Handling
By:
borispio on
Jan 2nd, 2012 | syntax:
Objective C | size: 0.37 KB | hits: 65 | expires: Never
NSError *error = nil;
NSString *path = [NSString stringWithFormat:@"%@/Library/Safari/History.plist", NSHomeDirectory()];
uint64_t fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:path error:&error] fileSize];
if (error != nil) {
NSLog(@"Error: %@", [error localizedDescription]);
} else {
NSLog(@"File Size: %.0llu", fileSize);
}