From c527c7611a169986d65d3f14c31009e6ce690c36 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Fri, 19 Oct 2007 10:22:43 -0700 Subject: [PATCH] wininet: Implement DeleteUrlCacheEntryW. --- dlls/wininet/urlcache.c | 50 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c index 4d0ceabbdb0..9887994e547 100644 --- a/dlls/wininet/urlcache.c +++ b/dlls/wininet/urlcache.c @@ -2528,7 +2528,55 @@ BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR lpszUrlName) */ BOOL WINAPI DeleteUrlCacheEntryW(LPCWSTR lpszUrlName) { - FIXME("(%s) stub\n", debugstr_w(lpszUrlName)); + URLCACHECONTAINER * pContainer; + LPURLCACHE_HEADER pHeader; + CACHEFILE_ENTRY * pEntry; + LPSTR urlA; + int url_len; + + TRACE("(%s)\n", debugstr_w(lpszUrlName)); + + url_len = WideCharToMultiByte(CP_ACP, 0, lpszUrlName, -1, NULL, 0, NULL, NULL); + urlA = HeapAlloc(GetProcessHeap(), 0, url_len * sizeof(CHAR)); + if (!urlA) + { + SetLastError(ERROR_OUTOFMEMORY); + return FALSE; + } + WideCharToMultiByte(CP_ACP, 0, lpszUrlName, -1, urlA, url_len, NULL, NULL); + + if (!URLCacheContainers_FindContainerW(lpszUrlName, &pContainer)) + { + HeapFree(GetProcessHeap(), 0, urlA); + return FALSE; + } + if (!URLCacheContainer_OpenIndex(pContainer)) + { + HeapFree(GetProcessHeap(), 0, urlA); + return FALSE; + } + if (!(pHeader = URLCacheContainer_LockIndex(pContainer))) + { + HeapFree(GetProcessHeap(), 0, urlA); + return FALSE; + } + + if (!URLCache_FindEntryInHash(pHeader, urlA, &pEntry)) + { + URLCacheContainer_UnlockIndex(pContainer, pHeader); + TRACE("entry %s not found!\n", debugstr_a(urlA)); + HeapFree(GetProcessHeap(), 0, urlA); + SetLastError(ERROR_FILE_NOT_FOUND); + return FALSE; + } + + URLCache_DeleteEntry(pHeader, pEntry); + + URLCache_DeleteEntryFromHash(pHeader, urlA); + + URLCacheContainer_UnlockIndex(pContainer, pHeader); + + HeapFree(GetProcessHeap(), 0, urlA); return TRUE; }