use SetFileValidData() on non-sparse files on windows

This commit is contained in:
Arvid Norberg 2009-02-14 04:18:17 +00:00
parent dc4d50b117
commit 7c2d2f6d12
1 changed files with 7 additions and 0 deletions

View File

@ -747,6 +747,13 @@ namespace libtorrent
ec = error_code(GetLastError(), get_system_category()); ec = error_code(GetLastError(), get_system_category());
return false; return false;
} }
if ((mode & sparse) == 0)
{
// if the user has permissions, avoid filling
// the file with zeroes, but just fill it with
// garbage instead
SetFileValidData(m_file_handle, offs.QuadPart);
}
if (::SetEndOfFile(m_file_handle) == FALSE) if (::SetEndOfFile(m_file_handle) == FALSE)
{ {
ec = error_code(GetLastError(), get_system_category()); ec = error_code(GetLastError(), get_system_category());