SHARE
TWEET

Get File Size (OS X) With Error Handling

borispio Jan 2nd, 2012 100 Never
  1. NSError *error = nil;
  2.    
  3. NSString *path = [NSString stringWithFormat:@"%@/Library/Safari/History.plist", NSHomeDirectory()];
  4.    
  5. uint64_t fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:path error:&error] fileSize];
  6.    
  7. if (error != nil) {
  8.         NSLog(@"Error: %@", [error localizedDescription]);
  9. } else {
  10.         NSLog(@"File Size: %.0llu", fileSize);
  11. }
RAW Paste Data
Top