• 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
File Size Code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

File Size Code


  • Subject: File Size Code
  • From: email@hidden
  • Date: Sat, 8 May 2004 21:40:16 -0700

ok here's my code to add the file size of files/directories

- (void) queryFileSize;
{
NSFileManager *manager = [NSFileManager defaultManager];
NSDictionary *rule = [NSDictionary
dictionaryWithDictionary:[itemArray objectAtIndex:[backupTable
selectedRow]]];
NSArray *pathArray = [[rule objectForKey:@"path"]
componentsSeparatedByString:@":"];

NSEnumerator *e = [pathArray objectEnumerator];
id object;

int total = 0;
BOOL isDir;

while(object = [e nextObject])
{
if ([manager fileExistsAtPath:[object
stringByExpandingTildeInPath] isDirectory:&isDir] && isDir)
{
NSString *file;
NSDirectoryEnumerator *enumerator = [[NSFileManager
defaultManager] enumeratorAtPath:[object
stringByExpandingTildeInPath]];
//NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]
init];
while (file = [enumerator nextObject])
{
NSDictionary *fileSize = [manager
fileAttributesAtPath:file traverseLink:NO];
NSNumber *totalFileSize = [fileSize
objectForKey:NSFileSize];
total += [totalFileSize intValue];
}
//[pool release];
}
else
{
NSDictionary *fileSize = [manager
fileAttributesAtPath:[object stringByExpandingTildeInPath]
traverseLink:NO];
NSNumber *totalFileSize = [fileSize
objectForKey:NSFileSize];
total += [totalFileSize intValue];
}
}
NSLog(@"%d",total);
}


my problem is, its not reading the size for some reason it will on 1
file and then the rest come up as zero?
_______________________________________________
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.


  • Follow-Ups:
    • Re: File Size Code
      • From: Scott Ahten <email@hidden>
  • Prev by Date: Re: Pre-defined methods - documentation?
  • Next by Date: Re: [semi-OT] Apple's Help Viewer: a note to the frustrated
  • Previous by thread: Re: Retrieving file/folder sizes
  • Next by thread: Re: File Size Code
  • Index(es):
    • Date
    • Thread