Ignore:
Timestamp:
Mar 31, 2009, 10:13:43 PM (13 years ago)
Author:
charles
Message:

(trunk rpc) added "fileStats" to rpc s.t. there's a simple interface for getting all the torrent's stat fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/rpcimpl.c

    r8111 r8121  
    288288****
    289289***/
     290
     291static void
     292addFileStats( const tr_torrent * tor, tr_benc * list )
     293{
     294    tr_file_index_t i;
     295    tr_file_index_t n;
     296    const tr_info * info = tr_torrentInfo( tor );
     297    tr_file_stat * files = tr_torrentFiles( tor, &n );
     298
     299    for( i = 0; i < info->fileCount; ++i )
     300    {
     301        const tr_file * file = &info->files[i];
     302        tr_benc * d = tr_bencListAddDict( list, 3 );
     303        tr_bencDictAddInt( d, "bytesCompleted", files[i].bytesCompleted );
     304        tr_bencDictAddInt( d, "priority", file->priority );
     305        tr_bencDictAddBool( d, "wanted", !file->dnd );
     306    }
     307
     308    tr_torrentFilesFree( files, n );
     309}
    290310
    291311static void
     
    416436    else if( !strcmp( key, "files" ) )
    417437        addFiles( tor, tr_bencDictAddList( d, key, inf->fileCount ) );
     438    else if( !strcmp( key, "fileStats" ) )
     439        addFileStats( tor, tr_bencDictAddList( d, key, inf->fileCount ) );
    418440    else if( !strcmp( key, "hashString" ) )
    419441        tr_bencDictAddStr( d, key, tor->info.hashString );
Note: See TracChangeset for help on using the changeset viewer.