Changeset 5910


Ignore:
Timestamp:
May 22, 2008, 9:06:56 PM (14 years ago)
Author:
livings124
Message:

streamline FileListNode?.m, moving asserts to more appropriate locations

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FileListNode.h

    r5909 r5910  
    4141
    4242- (void) insertChild: (FileListNode *) child;
    43 - (void) insertIndex: (NSUInteger) index;
     43- (void) insertIndex: (NSUInteger) index withSize: (uint64_t) size;
    4444
    4545- (BOOL) isFolder;
  • trunk/macosx/FileListNode.m

    r5909 r5910  
    3838    {
    3939        fChildren = [[NSMutableArray alloc] init];
     40        fSize = 0;
    4041    }
    4142   
     
    5657- (void) insertChild: (FileListNode *) child
    5758{
     59    NSAssert(fIsFolder, @"method can only be invoked on files");
     60   
    5861    [fChildren addObject: child];
    5962}
    6063
    61 - (void) insertIndex: (NSUInteger) index
     64- (void) insertIndex: (NSUInteger) index withSize: (uint64_t) size
    6265{
     66    NSAssert(fIsFolder, @"method can only be invoked on files");
     67   
    6368    [fIndexes addIndex: index];
     69    fSize += size;
    6470}
    6571
    6672- (id) copyWithZone: (NSZone *) zone
    6773{
     74    //this object is essentially immutable after initial setup
    6875    return [self retain];
    6976}
     
    104111- (uint64_t) size
    105112{
    106     NSAssert(!fIsFolder, @"method can only be invoked on files currently");
    107    
    108113    return fSize;
    109114}
     
    111116- (NSImage *) icon
    112117{
    113     NSAssert(!fIsFolder, @"method can only be invoked on files currently");
    114    
    115     if (!fIcon)
     118    if (!fIsFolder && !fIcon)
    116119    {
    117120        fIcon = [[[NSWorkspace sharedWorkspace] iconForFileType: [fName pathExtension]] retain];
     
    123126- (NSArray *) children
    124127{
    125     NSAssert(fIsFolder, @"method can only be invoked on folders");
    126    
    127128    return fChildren;
    128129}
  • trunk/macosx/Torrent.m

    r5908 r5910  
    16651665            if ([pathComponents count] > 0)
    16661666            {
    1667                 //determine if node already exists
     1667                //determine if folder node already exists
    16681668                NSEnumerator * enumerator = [fileList objectEnumerator];
    16691669                FileListNode * node;
    16701670                while ((node = [enumerator nextObject]))
    1671                     if ([[node name] isEqualToString: name])
     1671                    if ([[node name] isEqualToString: name] && [node isFolder])
    16721672                        break;
    16731673               
     
    16791679                }
    16801680               
    1681                 [node insertIndex: i];
     1681                [node insertIndex: i withSize: file->length];
    16821682                [self insertPath: pathComponents forParent: node fileSize: file->length index: i];
    16831683            }
     
    17301730    if (isFolder)
    17311731    {
    1732         [node insertIndex: index];
     1732        [node insertIndex: index withSize: size];
    17331733       
    17341734        [components removeObjectAtIndex: 0];
Note: See TracChangeset for help on using the changeset viewer.