workaround for sparse files issue on Windows vista

This commit is contained in:
Arvid Norberg
2009-01-05 01:08:09 +00:00
parent f1d229aae6
commit d07ccaf6b8
9 changed files with 110 additions and 1 deletions

View File

@@ -65,6 +65,7 @@ namespace libtorrent
, m_num_have(0)
, m_cursor(0)
, m_reverse_cursor(0)
, m_sparse_regions(1)
, m_dirty(false)
{
#ifdef TORRENT_PICKER_LOG
@@ -1073,6 +1074,28 @@ namespace libtorrent
, has_index(index)) == m_downloads.end());
if (p.have()) return;
// maintain sparse_regions
if (index == 0)
{
if (index == m_piece_map.size() - 1
|| m_piece_map[index + 1].have())
--m_sparse_regions;
}
else if (index == int(m_piece_map.size() - 1))
{
if (index == 0
|| m_piece_map[index - 1].have())
--m_sparse_regions;
}
else
{
bool have_before = m_piece_map[index-1].have();
bool have_after = m_piece_map[index+1].have();
if (have_after && have_before) --m_sparse_regions;
else if (!have_after && !have_before) ++m_sparse_regions;
}
if (p.filtered())
{
--m_num_filtered;