• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: directory size
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >directory size (From: Chris Long <email@hidden>)

  • Prev by Date: Re: Cocoa/Java - NSNotification not received.
  • Next by Date: Error when compiling in regex.h
  • Previous by thread: directory size
  • Next by thread: directory size
  • Index(es):
    • Date
    • Thread