Re: directory size
Re: directory size
- Subject: Re: directory size
- From: Frank Fenn <email@hidden>
- Date: Fri, 7 Mar 2003 21:40:53 -0700
On Friday, March 7, 2003, at 04:19 PM, Chris Long wrote:
I am trying to get the size of a directory but I think the
directoryDictionary is storing something other than the directory
size. My values come out very small, like
Try this:
#define MINBLOCK 4096
NSString *file;
NSNumber *fsize;
NSDictionary *fattrs;
NSDirectoryEnumerator *de;
unsigned long size = 0;
de = [[NSFileManager defaultManager]
enumeratorAtPath:@"/Applications"];
while(file = [de nextObject]) {
fattrs = [de fileAttributes];
fsize = [fattrs objectForKey:NSFileSize];
if (![[fattrs valueForKey:NSFileType]
isEqualTo:NSFileTypeDirectory]) {
size += ((([[fattrs valueForKey:NSFileSize] unsignedIntValue] +
MINBLOCK - 1) / MINBLOCK) * MINBLOCK);
}
}
this results in the size of the given directory in bytes.
--
regards
Frank Fenn - Bright Light Software
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.