int file_storage::piece_size(int index) const { TORRENT_ASSERT(index >= 0 && index < num_pieces()); if (index == num_pieces()-1) { size_type size_except_last = num_pieces() - 1; size_except_last *= size_type(piece_length()); size_type size = total_size() - size_except_last; TORRENT_ASSERT(size > 0); TORRENT_ASSERT(size <= piece_length()); return int(size); } else return piece_length(); }
// the number of pieces we want and don't have int num_want_left() const { return num_pieces() - m_num_have - m_num_filtered + m_num_have_filtered; }
bool is_valid() const { return m_files.is_valid() && int(m_piece_hashes.size()) == num_pieces() + (file_at(0).size % PIECE_SIZE == 0); }