urlmon: URLDownloadToFileA code clean up.

This commit is contained in:
Jacek Caban 2008-02-18 01:03:54 +01:00 committed by Alexandre Julliard
parent 5ca20089c4
commit d2243989ca
3 changed files with 48 additions and 47 deletions

View File

@ -368,3 +368,38 @@ HRESULT WINAPI URLDownloadToFileW(LPUNKNOWN pCaller, LPCWSTR szURL, LPCWSTR szFi
return hres == MK_S_ASYNCHRONOUS ? S_OK : hres;
}
/***********************************************************************
* URLDownloadToFileA (URLMON.@)
*
* Downloads URL szURL to rile szFileName and call lpfnCB callback to
* report progress.
*
* PARAMS
* pCaller [I] controlling IUnknown interface.
* szURL [I] URL of the file to download
* szFileName [I] file name to store the content of the URL
* dwReserved [I] reserved - set to 0
* lpfnCB [I] callback for progress report
*
* RETURNS
* S_OK on success
*/
HRESULT WINAPI URLDownloadToFileA(LPUNKNOWN pCaller, LPCSTR szURL, LPCSTR szFileName, DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB)
{
LPWSTR urlW, file_nameW;
HRESULT hres;
TRACE("(%p %s %s %d %p)\n", pCaller, debugstr_a(szURL), debugstr_a(szFileName), dwReserved, lpfnCB);
urlW = heap_strdupAtoW(szURL);
file_nameW = heap_strdupAtoW(szFileName);
hres = URLDownloadToFileW(pCaller, urlW, file_nameW, dwReserved, lpfnCB);
heap_free(urlW);
heap_free(file_nameW);
return hres;
}

View File

@ -1206,53 +1206,6 @@ HRESULT WINAPI MkParseDisplayNameEx(IBindCtx *pbc, LPCWSTR szDisplayName, ULONG
}
/***********************************************************************
* URLDownloadToFileA (URLMON.@)
*
* Downloads URL szURL to rile szFileName and call lpfnCB callback to
* report progress.
*
* PARAMS
* pCaller [I] controlling IUnknown interface.
* szURL [I] URL of the file to download
* szFileName [I] file name to store the content of the URL
* dwReserved [I] reserved - set to 0
* lpfnCB [I] callback for progress report
*
* RETURNS
* S_OK on success
* E_OUTOFMEMORY when going out of memory
*/
HRESULT WINAPI URLDownloadToFileA(LPUNKNOWN pCaller,
LPCSTR szURL,
LPCSTR szFileName,
DWORD dwReserved,
LPBINDSTATUSCALLBACK lpfnCB)
{
UNICODE_STRING szURL_w, szFileName_w;
if ((szURL == NULL) || (szFileName == NULL)) {
FIXME("(%p,%s,%s,%08x,%p) cannot accept NULL strings !\n", pCaller, debugstr_a(szURL), debugstr_a(szFileName), dwReserved, lpfnCB);
return E_INVALIDARG; /* The error code is not specified in this case... */
}
if (RtlCreateUnicodeStringFromAsciiz(&szURL_w, szURL)) {
if (RtlCreateUnicodeStringFromAsciiz(&szFileName_w, szFileName)) {
HRESULT ret = URLDownloadToFileW(pCaller, szURL_w.Buffer, szFileName_w.Buffer, dwReserved, lpfnCB);
RtlFreeUnicodeString(&szURL_w);
RtlFreeUnicodeString(&szFileName_w);
return ret;
} else {
RtlFreeUnicodeString(&szURL_w);
}
}
FIXME("(%p,%s,%s,%08x,%p) could not allocate W strings !\n", pCaller, szURL, szFileName, dwReserved, lpfnCB);
return E_OUTOFMEMORY;
}
/***********************************************************************
* URLDownloadToCacheFileA (URLMON.@)
*/

View File

@ -110,4 +110,17 @@ static inline LPWSTR heap_strdupW(LPCWSTR str)
return ret;
}
static inline LPWSTR heap_strdupAtoW(const char *str)
{
LPWSTR ret = NULL;
if(str) {
DWORD len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
ret = heap_alloc(len*sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
}
return ret;
}
#endif /* __WINE_URLMON_MAIN_H */