Re: glitch in my size code?
Re: glitch in my size code?
- Subject: Re: glitch in my size code?
- From: Glenn Andreas <email@hidden>
- Date: Mon, 10 May 2004 16:46:46 -0500
At 1:23 PM -0700 5/10/04, email@hidden wrote:
ok so this is the directory enumerator code i'm using
NSString *file;
NSDirectoryEnumerator *enumerator = [[NSFileManager
defaultManager] enumeratorAtPath:[object
stringByExpandingTildeInPath]];
while (file = [enumerator nextObject])
{
if (![[[file lastPathComponent] substringToIndex:1]
isEqualToString:@"."])
You could just do:
if (![[file lastPathComponent] hasPrefix: @"."])
{
NSNumber *totalFileSize;
NSDictionary *fileSize = [manager
fileAttributesAtPath:file traverseLink:YES];
if (totalFileSize = [fileSize
objectForKey:NSFileSize])
total += [totalFileSize intValue];
Is total (properly) declared as an "unsigned long long"? File size
is measured in unsigned long long, not int.
You can also use the convience function:
total += [fileSize fileSize];
(and otherwise use [totalFileSize unsignedLongLongValue] since this
is an unsigned long long value here, not an int)
NSLog(@"%@ - Total: %d",file,[totalFileSize
intValue]);
NSLog(@"%@ - Total: %@", file, totalFileSize);
or
NSLog(@"%@ - Total: %uq", file, [totalFileSize
unsignedLongLongValue])
or
NSLog(@"%@ - Total: %uq", file, [fileSize fileSize]);
}
}
and this is what it returns??
So change everything to use unsigned long longs instead of ints for
this and it should work.
--
Glenn Andreas email@hidden
mondo blobbo, Cythera, Theldrow, oh my!
Mad, Bad, and Dangerous to Know
_______________________________________________
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.