Hello, I was wondering what was the best way to calucate folder size with cocoa? I was able to do this but it does not include resource forks:
#import <Foundation/Foundation.h> int main() { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *path = [@"/Folder" stringByExpandingTildeInPath]; NSDirectoryEnumerator *e = [[NSFileManager defaultManager] enumeratorAtPath :path]; NSString *file; unsigned long long totalSize = 0; while ((file = [e nextObject])) { NSDictionary *attributes = [e fileAttributes]; NSNumber *fileSize = [attributes objectForKey:NSFileSize]; totalSize += [fileSize longLongValue]; } printf("Total size: %lld\n", totalSize); [pool release]; } or from the example in documentation - (IBAction)calculateSize:(id)sender { NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *path = @"/Folder"; NSDictionary *fileAttributes = [fileManager fileAttributesAtPath:path traverseLink:YES]; if (fileAttributes != nil) { NSNumber *fileSize; if (fileSize = [fileAttributes objectForKey:NSFileSize]) { NSLog(@"File size: %qi\n", [fileSize unsignedLongLongValue]); [label setIntValue:[fileSize unsignedLongLongValue]]; } } But I was unsure on how to traverse the entire file tree within that directory, and give the same size results as the finder. Thanks, -Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]