urlmon: URLDownloadToFileA code clean up.
This commit is contained in:
parent
5ca20089c4
commit
d2243989ca
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.@)
|
||||
*/
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue