Changeset 2070
- Timestamp:
- Jun 13, 2007, 7:53:10 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/file_selection/libtransmission/torrent.c
r2065 r2070 604 604 { 605 605 const tr_file_t * file = &tor->info.files[fileIndex]; 606 int firstBlock = file->offset / tor->blockSize;607 int firstBlockOffset = file->offset % tor->blockSize;608 int lastBlock = (file->offset + file->length ) / tor->blockSize;609 int lastBlockOffset = (file->offset + file->length ) % tor->blockSize;606 int firstBlock = file->offset / tor->blockSize; 607 int firstBlockOffset = file->offset % tor->blockSize; 608 int lastBlock = (file->offset + file->length - 1) / tor->blockSize; 609 int lastBlockOffset = (file->offset + file->length - 1) % tor->blockSize; 610 610 size_t haveBytes = 0; 611 611 612 assert( tor != NULL ); 613 assert( 0<=fileIndex && fileIndex<tor->info.fileCount ); 614 assert( file->offset + file->length <= tor->info.totalSize ); 615 assert( 0<=firstBlock && firstBlock<tor->blockCount ); 616 assert( 0<=lastBlock && lastBlock<tor->blockCount ); 617 assert( firstBlock <= lastBlock ); 612 618 assert( tr_blockPiece( firstBlock ) == file->firstPiece ); 613 619 assert( tr_blockPiece( lastBlock ) == file->lastPiece ); … … 1068 1074 file = &info->files[fileIndex]; 1069 1075 firstByte = file->offset; 1070 lastByte = firstByte + file->length ;1076 lastByte = firstByte + file->length - 1; 1071 1077 file->firstPiece = getBytePiece( info, firstByte ); 1072 1078 file->lastPiece = getBytePiece( info, lastByte );
Note: See TracChangeset
for help on using the changeset viewer.