file EOF fix for windows
This commit is contained in:
parent
97d8685066
commit
a35d516b68
12
src/file.cpp
12
src/file.cpp
|
@ -352,7 +352,17 @@ namespace libtorrent
|
||||||
if (ReadFileScatter(m_file_handle, segment_array, size, 0, &ol) == 0)
|
if (ReadFileScatter(m_file_handle, segment_array, size, 0, &ol) == 0)
|
||||||
{
|
{
|
||||||
DWORD last_error = GetLastError();
|
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());
|
ec = error_code(GetLastError(), get_system_category());
|
||||||
CloseHandle(ol.hEvent);
|
CloseHandle(ol.hEvent);
|
||||||
|
|
Loading…
Reference in New Issue