From a35d516b688d9448534b7db8a091b2391d569ece Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 16 Jan 2009 18:51:54 +0000 Subject: [PATCH] file EOF fix for windows --- src/file.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/file.cpp b/src/file.cpp index b2a4f4033..95d1d95f6 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -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);