Exemplo n.º 1
0
	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();
	}
Exemplo n.º 2
0
		// 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; }
Exemplo n.º 3
0
 bool is_valid() const
 {
     return m_files.is_valid() &&
            int(m_piece_hashes.size()) == num_pieces() + (file_at(0).size % PIECE_SIZE == 0);
 }