Advertisement
borispio

Get File Size (OS X) With Error Handling

Jan 2nd, 2012
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement