Commit 930e0cdc authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

quartz/filesource: Correctly report short reads from IAsyncReader_SyncRead().

parent e2f37558
...@@ -1309,34 +1309,37 @@ static HRESULT WINAPI FileAsyncReader_SyncReadAligned(IAsyncReader * iface, IMed ...@@ -1309,34 +1309,37 @@ static HRESULT WINAPI FileAsyncReader_SyncReadAligned(IAsyncReader * iface, IMed
return hr; return hr;
} }
static HRESULT WINAPI FileAsyncReader_SyncRead(IAsyncReader * iface, LONGLONG llPosition, LONG lLength, BYTE * pBuffer) static HRESULT WINAPI FileAsyncReader_SyncRead(IAsyncReader *iface,
LONGLONG offset, LONG length, BYTE *buffer)
{ {
OVERLAPPED ovl; OVERLAPPED ovl;
HRESULT hr = S_OK; FileAsyncReader *filter = impl_from_IAsyncReader(iface);
FileAsyncReader *This = impl_from_IAsyncReader(iface); DWORD read_len;
HRESULT hr;
BOOL ret;
TRACE("%p->(%s, %d, %p)\n", This, wine_dbgstr_longlong(llPosition), lLength, pBuffer); TRACE("filter %p, offset %s, length %d, buffer %p.\n",
filter, wine_dbgstr_longlong(offset), length, buffer);
ZeroMemory(&ovl, sizeof(ovl)); ZeroMemory(&ovl, sizeof(ovl));
ovl.hEvent = CreateEventW(NULL, 0, 0, NULL); ovl.hEvent = CreateEventW(NULL, 0, 0, NULL);
/* NOTE: llPosition is the actual byte position to start reading from */ /* NOTE: llPosition is the actual byte position to start reading from */
ovl.u.s.Offset = (DWORD) llPosition; ovl.u.s.Offset = (DWORD)offset;
ovl.u.s.OffsetHigh = (DWORD) (llPosition >> (sizeof(DWORD) * 8)); ovl.u.s.OffsetHigh = (DWORD)(offset >> (sizeof(DWORD) * 8));
if (!ReadFile(This->hFile, pBuffer, lLength, NULL, &ovl))
hr = HRESULT_FROM_WIN32(GetLastError());
if (hr == HRESULT_FROM_WIN32(ERROR_IO_PENDING))
hr = S_OK;
if (SUCCEEDED(hr)) ret = ReadFile(filter->hFile, buffer, length, NULL, &ovl);
if (ret || GetLastError() == ERROR_IO_PENDING)
{ {
DWORD dwBytesRead; if (GetOverlappedResult(filter->hFile, &ovl, &read_len, TRUE))
hr = (read_len == length) ? S_OK : S_FALSE;
if (!GetOverlappedResult(This->hFile, &ovl, &dwBytesRead, TRUE)) else
hr = HRESULT_FROM_WIN32(GetLastError()); hr = HRESULT_FROM_WIN32(GetLastError());
} }
else if (GetLastError() == ERROR_HANDLE_EOF)
hr = S_FALSE;
else
hr = HRESULT_FROM_WIN32(GetLastError());
CloseHandle(ovl.hEvent); CloseHandle(ovl.hEvent);
......
...@@ -722,7 +722,6 @@ static void test_async_reader(void) ...@@ -722,7 +722,6 @@ static void test_async_reader(void)
ok(buffer[i] == (10 + i) % 111, "Got wrong byte %02x at %u.\n", buffer[i], i); ok(buffer[i] == (10 + i) % 111, "Got wrong byte %02x at %u.\n", buffer[i], i);
hr = IAsyncReader_SyncRead(reader, 590, 20, buffer); hr = IAsyncReader_SyncRead(reader, 590, 20, buffer);
todo_wine
ok(hr == S_FALSE, "Got hr %#x.\n", hr); ok(hr == S_FALSE, "Got hr %#x.\n", hr);
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
ok(buffer[i] == (590 + i) % 111, "Got wrong byte %02x at %u.\n", buffer[i], i); ok(buffer[i] == (590 + i) % 111, "Got wrong byte %02x at %u.\n", buffer[i], i);
...@@ -731,7 +730,6 @@ todo_wine ...@@ -731,7 +730,6 @@ todo_wine
memset(buffer, 0xcc, sizeof(buffer)); memset(buffer, 0xcc, sizeof(buffer));
hr = IAsyncReader_SyncRead(reader, 600, 10, buffer); hr = IAsyncReader_SyncRead(reader, 600, 10, buffer);
todo_wine
ok(hr == S_FALSE, "Got hr %#x.\n", hr); ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(buffer[0] == 0xcc, "Got wrong byte %02x.\n", buffer[0]); ok(buffer[0] == 0xcc, "Got wrong byte %02x.\n", buffer[0]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment