Changeset 2364


Ignore:
Timestamp:
Jul 15, 2007, 10:14:03 PM (15 years ago)
Author:
livings124
Message:

add a second file completion method for single files

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Torrent.h

    r2363 r2364  
    207207//methods require fileStats to have been updated recently to be accurate
    208208- (float) fileProgress: (int) index;
     209- (BOOL) canChangeDownloadCheckForFile: (int) index;
     210- (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet;
    209211- (int) checkForFiles: (NSIndexSet *) indexSet;
    210 - (BOOL) canChangeDownloadCheckForFiles: (NSIndexSet *) indexSet;
    211212- (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet;
    212213- (void) setFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
  • trunk/macosx/Torrent.m

    r2363 r2364  
    13021302}
    13031303
    1304 - (int) checkForFiles: (NSIndexSet *) indexSet
    1305 {
    1306     BOOL onState = NO, offState = NO;
    1307     int index;
    1308     for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
    1309     {
    1310         if (tr_torrentGetFileDL(fHandle, index) || ![self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]])
    1311             onState = YES;
    1312         else
    1313             offState = YES;
    1314        
    1315         if (onState == offState)
    1316             return NSMixedState;
    1317     }
    1318     return onState ? NSOnState : NSOffState;
     1304- (BOOL) canChangeDownloadCheckForFile: (int) index
     1305{
     1306    return [self fileCount] > 1 && fileStat[index].completionStatus != TR_CP_COMPLETE;
    13191307}
    13201308
     
    13341322}
    13351323
     1324- (int) checkForFiles: (NSIndexSet *) indexSet
     1325{
     1326    BOOL onState = NO, offState = NO;
     1327    int index;
     1328    for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
     1329    {
     1330        if (tr_torrentGetFileDL(fHandle, index) || ![self canChangeDownloadCheckForFile: index])
     1331            onState = YES;
     1332        else
     1333            offState = YES;
     1334       
     1335        if (onState == offState)
     1336            return NSMixedState;
     1337    }
     1338    return onState ? NSOnState : NSOffState;
     1339}
     1340
    13361341- (void) setFileCheckState: (int) state forIndexes: (NSIndexSet *) indexSet
    13371342{
     
    13701375    int index;
    13711376    for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
    1372         if (priority == tr_torrentGetFilePriority(fHandle, index)
    1373                 && [self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]])
     1377        if (priority == tr_torrentGetFilePriority(fHandle, index) && [self canChangeDownloadCheckForFile: index])
    13741378            return YES;
    13751379    return NO;
     
    13841388    for (index = [indexSet firstIndex]; index != NSNotFound; index = [indexSet indexGreaterThanIndex: index])
    13851389    {
    1386         if (![self canChangeDownloadCheckForFiles: [NSIndexSet indexSetWithIndex: index]])
     1390        if (![self canChangeDownloadCheckForFile: index])
    13871391            continue;
    13881392       
Note: See TracChangeset for help on using the changeset viewer.