Changeset 2346


Ignore:
Timestamp:
Jul 15, 2007, 3:26:22 AM (14 years ago)
Author:
charles
Message:

add tr_torrentGetFileStatus() for BentMyWookie?

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r2343 r2346  
    12661266    tr_torrentWriterUnlock( tor );
    12671267}
     1268
     1269cp_status_t
     1270tr_torrentGetFileStatus( const tr_torrent_t * tor, int fileIndex )
     1271{
     1272    int i;
     1273    int isComplete;
     1274    const tr_file_t * file;
     1275
     1276    assert( tor != NULL );
     1277    assert( 0<=fileIndex );
     1278    assert( fileIndex<tor->info.fileCount );
     1279
     1280    file = &tor->info.files[fileIndex];
     1281
     1282    isComplete = TRUE;
     1283    for( i=file->firstPiece; isComplete && i<=file->lastPiece; ++i )
     1284        if( !tr_cpPieceIsComplete( tor->completion, i ) )
     1285            isComplete = FALSE;
     1286
     1287    if( isComplete )
     1288        return TR_CP_COMPLETE;
     1289
     1290    if( file->dnd )
     1291        return TR_CP_DONE;
     1292
     1293    return TR_CP_INCOMPLETE;
     1294}
  • trunk/libtransmission/transmission.h

    r2333 r2346  
    247247
    248248
     249typedef 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}
     255cp_status_t;
     256
     257cp_status_t tr_torrentGetFileStatus( const tr_torrent_t  * tor,
     258                                     int                   fileIndex );
     259
     260
    249261/***********************************************************************
    250262 * tr_torrentRates
     
    537549typedef enum
    538550{
    539     TR_CP_INCOMPLETE,   /* doesn't have all the desired pieces */
    540     TR_CP_DONE,         /* has all the pieces but the DND ones */
    541     TR_CP_COMPLETE      /* has every piece */
    542 }
    543 cp_status_t;
    544 
    545 typedef enum
    546 {
    547551    TR_STATUS_CHECK_WAIT   = (1<<0), /* Waiting in queue to check files */
    548552    TR_STATUS_CHECK        = (1<<1), /* Checking files */
Note: See TracChangeset for help on using the changeset viewer.