Changeset 2152
- Timestamp:
- Jun 18, 2007, 5:05:16 AM (15 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/torrent.c
r2149 r2152 617 617 } 618 618 619 size_t619 uint64_t 620 620 tr_torrentFileBytesCompleted ( const tr_torrent_t * tor, int fileIndex ) 621 621 { 622 const tr_file_t * file = &tor->info.files[fileIndex];623 const int firstBlock = file->offset / tor->blockSize;624 const int firstBlockOffset = file->offset % tor->blockSize;625 const int lastOffset = file->length ? file->length-1: 0;626 const int lastBlock = (file->offset + lastOffset) / tor->blockSize;627 const int lastBlockOffset = (file->offset + lastOffset) % tor->blockSize;628 size_t haveBytes = 0;622 const tr_file_t * file = &tor->info.files[fileIndex]; 623 const uint64_t firstBlock = file->offset / tor->blockSize; 624 const uint64_t firstBlockOffset = file->offset % tor->blockSize; 625 const uint64_t lastOffset = file->length ? (file->length-1) : 0; 626 const uint64_t lastBlock = (file->offset + lastOffset) / tor->blockSize; 627 const uint64_t lastBlockOffset = (file->offset + lastOffset) % tor->blockSize; 628 uint64_t haveBytes = 0; 629 629 630 630 assert( tor != NULL ); 631 631 assert( 0<=fileIndex && fileIndex<tor->info.fileCount ); 632 632 assert( file->offset + file->length <= tor->info.totalSize ); 633 assert( 0<=firstBlock && firstBlock<tor->blockCount );634 assert( 0<=lastBlock && lastBlock<tor->blockCount );633 assert( (int)firstBlock < tor->blockCount ); 634 assert( (int)lastBlock < tor->blockCount ); 635 635 assert( firstBlock <= lastBlock ); 636 636 assert( tr_blockPiece( firstBlock ) == file->firstPiece ); … … 644 644 else 645 645 { 646 int i;646 uint64_t i; 647 647 648 648 if( tr_cpBlockIsComplete( tor->completion, firstBlock ) ) … … 663 663 tr_torrentFileCompletion ( const tr_torrent_t * tor, int fileIndex ) 664 664 { 665 const size_t c = tr_torrentFileBytesCompleted ( tor, fileIndex );666 return ( float)c / tor->info.files[fileIndex].length;665 const uint64_t c = tr_torrentFileBytesCompleted ( tor, fileIndex ); 666 return (double)c / tor->info.files[fileIndex].length; 667 667 } 668 668 -
trunk/libtransmission/transmission.h
r2149 r2152 399 399 float tr_torrentFileCompletion( const tr_torrent_t *, int fileIndex ); 400 400 401 size_t tr_torrentFileBytesCompleted( const tr_torrent_t *, int fileIndex );401 uint64_t tr_torrentFileBytesCompleted( const tr_torrent_t *, int fileIndex ); 402 402 403 403
Note: See TracChangeset
for help on using the changeset viewer.