• 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: glitch in my size code?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: glitch in my size code?
      • From: Scott Anguish <email@hidden>
References: 
 >glitch in my size code? (From: email@hidden)

  • Prev by Date: Re: Handling Undo/Redo in KVC To-Many Accessors
  • Next by Date: Re: window with a lot of controllers
  • Previous by thread: Re: glitch in my size code?
  • Next by thread: Re: glitch in my size code?
  • Index(es):
    • Date
    • Thread