From 9cd7545c00ecb46ebe0a0f9f5d2bc7829374a942 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Fri, 4 Mar 2011 12:08:38 -0800 Subject: [PATCH] wininet: Implement RetrieveUrlCacheEntryStreamW. --- dlls/wininet/urlcache.c | 48 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c index 6ec08de9f62..100a10340ae 100644 --- a/dlls/wininet/urlcache.c +++ b/dlls/wininet/urlcache.c @@ -2868,9 +2868,53 @@ HANDLE WINAPI RetrieveUrlCacheEntryStreamW( IN DWORD dwReserved ) { - FIXME( "(%s, %p, %p, %x, 0x%08x)\n", debugstr_w(lpszUrlName), lpCacheEntryInfo, + DWORD size; + int url_len; + /* NOTE: this is not the same as the way that the native + * version allocates 'stream' handles. I did it this way + * as it is much easier and no applications should depend + * on this behaviour. (Native version appears to allocate + * indices into a table) + */ + STREAM_HANDLE * pStream; + HANDLE hFile; + + TRACE( "(%s, %p, %p, %x, 0x%08x)\n", debugstr_w(lpszUrlName), lpCacheEntryInfo, lpdwCacheEntryInfoBufferSize, fRandomRead, dwReserved ); - return NULL; + + if (!RetrieveUrlCacheEntryFileW(lpszUrlName, + lpCacheEntryInfo, + lpdwCacheEntryInfoBufferSize, + dwReserved)) + { + return NULL; + } + + hFile = CreateFileW(lpCacheEntryInfo->lpszLocalFileName, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + fRandomRead ? FILE_FLAG_RANDOM_ACCESS : 0, + NULL); + if (hFile == INVALID_HANDLE_VALUE) + return FALSE; + + /* allocate handle storage space */ + size = sizeof(STREAM_HANDLE); + url_len = WideCharToMultiByte(CP_ACP, 0, lpszUrlName, -1, NULL, 0, NULL, NULL); + size += url_len; + pStream = HeapAlloc(GetProcessHeap(), 0, size); + if (!pStream) + { + CloseHandle(hFile); + SetLastError(ERROR_OUTOFMEMORY); + return FALSE; + } + + pStream->hFile = hFile; + WideCharToMultiByte(CP_ACP, 0, lpszUrlName, -1, pStream->lpszUrl, url_len, NULL, NULL); + return pStream; } /***********************************************************************