Changeset 2361


Ignore:
Timestamp:
Jul 15, 2007, 8:05:32 PM (15 years ago)
Author:
charles
Message:

replace tr_torrentGetFileStatus() with tr_torrentFiles() for BMW

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r2360 r2361  
    630630    return s;
    631631}
     632
     633/***
     634****
     635***/
     636
     637tr_file_stat_t *
     638tr_torrentFiles( const tr_torrent_t * tor, int * fileCount )
     639{
     640    int i;
     641    const int n = tor->info.fileCount;
     642    tr_file_stat_t * files = tr_new0( tr_file_stat_t, n );
     643    tr_file_stat_t * walk = files;
     644
     645    for( i=0; i<n; ++i, ++walk )
     646    {
     647        const uint64_t length = tor->info.files[i].length;
     648        cp_status_t cp;
     649
     650        walk->bytesCompleted = tr_torrentFileBytesCompleted( tor, i );
     651
     652        walk->progress = walk->bytesCompleted / (float)length;
     653
     654        if( walk->bytesCompleted >= length )
     655            cp = TR_CP_COMPLETE;
     656        else if( tor->info.files[i].dnd )
     657            cp = TR_CP_DONE;
     658        else
     659            cp = TR_CP_INCOMPLETE;
     660
     661        walk->completionStatus = cp;
     662    }
     663
     664    *fileCount = n;
     665
     666    return files;
     667}
     668
     669void
     670tr_torrentFilesFree( tr_file_stat_t * files, int fileCount UNUSED )
     671{
     672    tr_free( files );
     673}
     674
     675/***
     676****
     677***/
    632678
    633679tr_peer_stat_t *
     
    12821328    tr_torrentWriterUnlock( tor );
    12831329}
    1284 
    1285 cp_status_t
    1286 tr_torrentGetFileStatus( const tr_torrent_t * tor, int fileIndex )
    1287 {
    1288     const uint64_t bytes = tr_torrentFileBytesCompleted( tor, fileIndex );
    1289     const tr_file_t * file = &tor->info.files[fileIndex];
    1290 
    1291     if( bytes >= file->length )
    1292         return TR_CP_COMPLETE;
    1293 
    1294     if( file->dnd )
    1295         return TR_CP_DONE;
    1296 
    1297     return TR_CP_INCOMPLETE;
    1298 }
  • trunk/libtransmission/transmission.h

    r2360 r2361  
    246246void tr_torrentSetFileDL( tr_torrent_t *, int file, int do_download );
    247247
    248 
    249 typedef enum
    250 {
    251     TR_CP_INCOMPLETE,   /* doesn't have all the desired pieces */
    252     TR_CP_DONE,         /* has all the pieces but the DND ones */
    253     TR_CP_COMPLETE      /* has every piece */
    254 }
    255 cp_status_t;
    256 
    257 cp_status_t tr_torrentGetFileStatus( const tr_torrent_t  * tor,
    258                                      int                   fileIndex );
    259 
    260 
    261248/***********************************************************************
    262249 * tr_torrentRates
     
    435422void tr_torrentPeersFree( tr_peer_stat_t *, int peerCount );
    436423
     424typedef struct tr_file_stat_s tr_file_stat_t;
     425tr_file_stat_t * tr_torrentFiles( const tr_torrent_t *, int * fileCount );
     426void tr_torrentFilesFree( tr_file_stat_t *, int fileCount );
     427
     428
    437429/***********************************************************************
    438430 * tr_torrentAvailability
     
    562554#define TR_STATUS_INACTIVE \
    563555    (TR_STATUS_STOPPING|TR_STATUS_STOPPED)
     556
     557typedef enum
     558{
     559    TR_CP_INCOMPLETE,   /* doesn't have all the desired pieces */
     560    TR_CP_DONE,         /* has all the pieces but the DND ones */
     561    TR_CP_COMPLETE      /* has every piece */
     562}
     563cp_status_t;
    564564
    565565/***********************************************************************
     
    604604};
    605605
     606struct tr_file_stat_s
     607{
     608    uint64_t bytesCompleted;
     609    float progress;
     610    cp_status_t completionStatus;
     611};
     612
    606613struct tr_peer_stat_s
    607614{
Note: See TracChangeset for help on using the changeset viewer.