Changeset 7307


Ignore:
Timestamp:
Dec 7, 2008, 2:36:26 AM (12 years ago)
Author:
livings124
Message:

store a flat (non-nested) list of files for each transfer

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/FileListNode.h

    r7153 r7307  
    5353- (NSArray *) children;
    5454
    55 - (BOOL) containsPath: (NSString *) fullPath;
    56 
    5755@end
  • trunk/macosx/FileListNode.m

    r7153 r7307  
    129129}
    130130
    131 - (BOOL) containsPath: (NSString *) fullPath
    132 {
    133     if ([fullPath isEqualToString: fPath])
    134         return YES;
    135    
    136     if (fIsFolder && [fullPath hasPrefix: fPath])
    137     {
    138         NSEnumerator * enumerator = [fChildren objectEnumerator];
    139         FileListNode * node;
    140         while ((node = [enumerator nextObject]))
    141             if ([node containsPath: fullPath])
    142                 return YES;
    143     }
    144    
    145     return NO;
    146 }
    147 
    148131@end
    149132
  • trunk/macosx/Torrent.h

    r7016 r7307  
    6161   
    6262    tr_file_stat * fFileStat;
    63     NSArray * fFileList;
     63    NSArray * fFileList, * fFlatFileList;
    6464   
    6565    NSIndexSet * fPreviousFinishedIndexes;
     
    241241- (NSInteger) fileCount;
    242242- (void) updateFileStat;
     243- (NSArray *) flatFileList;
    243244
    244245//methods require fileStats to have been updated recently to be accurate
  • trunk/macosx/Torrent.m

    r7246 r7307  
    4444
    4545- (void) createFileList;
    46 - (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size index: (NSInteger) index;
     46- (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size
     47    index: (NSInteger) index flatList: (NSMutableArray *) flatFileList;
    4748
    4849- (void) completenessChange: (NSNumber *) status;
     
    189190   
    190191    [fFileList release];
     192    [fFlatFileList release];
    191193   
    192194    [fQuickPauseDict release];
     
    461463            BOOL isExtra = YES;
    462464       
    463             NSEnumerator * nodeEnumerator = [fFileList objectEnumerator];
     465            NSEnumerator * nodeEnumerator = [fFlatFileList objectEnumerator];
    464466            FileListNode * node;
    465467            while ((node = [nodeEnumerator nextObject]))
    466468            {
    467                 if ([node containsPath: file])
     469                if ([[node fullPath] hasPrefix: file])
    468470                {
    469471                    isExtra = NO;
     
    14881490}
    14891491
     1492- (NSArray *) flatFileList
     1493{
     1494    return fFlatFileList;
     1495}
     1496
    14901497- (BOOL) canChangeDownloadCheckForFile: (NSInteger) index
    14911498{
     
    17761783    {
    17771784        NSInteger count = [self fileCount];
    1778         NSMutableArray * fileList = [[NSMutableArray alloc] initWithCapacity: count];
     1785        NSMutableArray * fileList = [[NSMutableArray alloc] initWithCapacity: count],
     1786                    * flatFileList = [[NSMutableArray alloc] initWithCapacity: count];
    17791787       
    17801788        for (NSInteger i = 0; i < count; i++)
     
    18041812               
    18051813                [node insertIndex: i withSize: file->length];
    1806                 [self insertPath: pathComponents forParent: node fileSize: file->length index: i];
     1814                [self insertPath: pathComponents forParent: node fileSize: file->length index: i flatList: flatFileList];
    18071815            }
    18081816            else
     
    18101818                FileListNode * node = [[FileListNode alloc] initWithFileName: name path: path size: file->length index: i];
    18111819                [fileList addObject: node];
     1820                [flatFileList addObject: node];
    18121821                [node release];
    18131822            }
     
    18181827        fFileList = [[NSArray alloc] initWithArray: fileList];
    18191828        [fileList release];
     1829       
     1830        fFlatFileList = [[NSArray alloc] initWithArray: flatFileList];
     1831        [flatFileList release];
    18201832    }
    18211833    else
     
    18231835        FileListNode * node = [[FileListNode alloc] initWithFileName: [self name] path: @"" size: [self size] index: 0];
    18241836        fFileList = [[NSArray arrayWithObject: node] retain];
     1837        fFlatFileList = [fFileList copy];
    18251838        [node release];
    18261839    }
    18271840}
    18281841
    1829 - (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size index: (NSInteger) index
     1842- (void) insertPath: (NSMutableArray *) components forParent: (FileListNode *) parent fileSize: (uint64_t) size
     1843    index: (NSInteger) index flatList: (NSMutableArray *) flatFileList
    18301844{
    18311845    NSString * name = [components objectAtIndex: 0];
     
    18471861            node = [[FileListNode alloc] initWithFolderName: name path: [parent fullPath]];
    18481862        else
     1863        {
    18491864            node = [[FileListNode alloc] initWithFileName: name path: [parent fullPath] size: size index: index];
     1865            [flatFileList addObject: node];
     1866        }
    18501867       
    18511868        [parent insertChild: node];
     
    18581875       
    18591876        [components removeObjectAtIndex: 0];
    1860         [self insertPath: components forParent: node fileSize: size index: index];
     1877        [self insertPath: components forParent: node fileSize: size index: index flatList: flatFileList];
    18611878    }
    18621879}
Note: See TracChangeset for help on using the changeset viewer.