file EOF fix for windows

This commit is contained in:
Arvid Norberg 2009-01-16 18:51:54 +00:00
parent 97d8685066
commit a35d516b68
1 changed files with 11 additions and 1 deletions

View File

@ -352,7 +352,17 @@ namespace libtorrent
if (ReadFileScatter(m_file_handle, segment_array, size, 0, &ol) == 0)
{
DWORD last_error = GetLastError();
if (last_error != ERROR_IO_PENDING && last_error != ERROR_HANDLE_EOF)
if (last_error == ERROR_HANDLE_EOF)
{
LARGE_INTEGER file_size;
if (!GetFileSizeEx(m_file_handle, &file_size))
{
ec = error_code(GetLastError(), get_system_category());
return -1;
}
return file_size.QuadPart - file_offset;
}
if (last_error != ERROR_IO_PENDING)
{
ec = error_code(GetLastError(), get_system_category());
CloseHandle(ol.hEvent);