wininet: Added support for urlcache file name generating.
This commit is contained in:
parent
ee47def0ad
commit
e4a0281679
|
@ -2861,13 +2861,13 @@ BOOL WINAPI CreateUrlCacheEntryW(
|
||||||
BYTE CacheDir;
|
BYTE CacheDir;
|
||||||
LONG lBufferSize;
|
LONG lBufferSize;
|
||||||
BOOL bFound = FALSE;
|
BOOL bFound = FALSE;
|
||||||
|
BOOL generate_name = FALSE;
|
||||||
int count;
|
int count;
|
||||||
DWORD error;
|
DWORD error;
|
||||||
HANDLE hFile;
|
HANDLE hFile;
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
|
|
||||||
static const WCHAR szWWW[] = {'w','w','w',0};
|
static const WCHAR szWWW[] = {'w','w','w',0};
|
||||||
static const WCHAR fmt[] = {'%','0','8','X','%','s',0};
|
|
||||||
|
|
||||||
TRACE("(%s, 0x%08x, %s, %p, 0x%08x)\n",
|
TRACE("(%s, 0x%08x, %s, %p, 0x%08x)\n",
|
||||||
debugstr_w(lpszUrlName),
|
debugstr_w(lpszUrlName),
|
||||||
|
@ -2917,14 +2917,14 @@ BOOL WINAPI CreateUrlCacheEntryW(
|
||||||
while(len && szFile[--len] == '/') szFile[len] = '\0';
|
while(len && szFile[--len] == '/') szFile[len] = '\0';
|
||||||
|
|
||||||
/* FIXME: get rid of illegal characters like \, / and : */
|
/* FIXME: get rid of illegal characters like \, / and : */
|
||||||
|
TRACE("File name: %s\n", debugstr_a(szFile));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FIXME("need to generate a random filename\n");
|
generate_name = TRUE;
|
||||||
|
szFile[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("File name: %s\n", debugstr_a(szFile));
|
|
||||||
|
|
||||||
error = URLCacheContainers_FindContainerW(lpszUrlName, &pContainer);
|
error = URLCacheContainers_FindContainerW(lpszUrlName, &pContainer);
|
||||||
if (error != ERROR_SUCCESS)
|
if (error != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -2978,7 +2978,7 @@ BOOL WINAPI CreateUrlCacheEntryW(
|
||||||
lstrcpyW(szExtension+1, lpszFileExtension);
|
lstrcpyW(szExtension+1, lpszFileExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 255; i++)
|
for (i = 0; i<255 && !generate_name; i++)
|
||||||
{
|
{
|
||||||
static const WCHAR szFormat[] = {'[','%','u',']','%','s',0};
|
static const WCHAR szFormat[] = {'[','%','u',']','%','s',0};
|
||||||
WCHAR *p;
|
WCHAR *p;
|
||||||
|
@ -3008,8 +3008,24 @@ BOOL WINAPI CreateUrlCacheEntryW(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Try to generate random name */
|
||||||
GetSystemTimeAsFileTime(&ft);
|
GetSystemTimeAsFileTime(&ft);
|
||||||
wsprintfW(lpszFileNameNoPath + countnoextension, fmt, ft.dwLowDateTime, szExtension);
|
strcpyW(lpszFileNameNoPath+countnoextension+8, szExtension);
|
||||||
|
|
||||||
|
for(i=0; i<255; i++)
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
ULONGLONG n = ft.dwHighDateTime;
|
||||||
|
n <<= 32;
|
||||||
|
n += ft.dwLowDateTime;
|
||||||
|
n ^= (ULONGLONG)i<<48;
|
||||||
|
|
||||||
|
for(j=0; j<8; j++)
|
||||||
|
{
|
||||||
|
int r = (n % 36);
|
||||||
|
n /= 37;
|
||||||
|
lpszFileNameNoPath[countnoextension+j] = (r < 10 ? '0' + r : 'A' + r - 10);
|
||||||
|
}
|
||||||
|
|
||||||
TRACE("Trying: %s\n", debugstr_w(lpszFileName));
|
TRACE("Trying: %s\n", debugstr_w(lpszFileName));
|
||||||
hFile = CreateFileW(lpszFileName, GENERIC_READ, 0, NULL, CREATE_NEW, 0, NULL);
|
hFile = CreateFileW(lpszFileName, GENERIC_READ, 0, NULL, CREATE_NEW, 0, NULL);
|
||||||
|
@ -3018,6 +3034,7 @@ BOOL WINAPI CreateUrlCacheEntryW(
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WARN("Could not find a unique filename\n");
|
WARN("Could not find a unique filename\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Reference in New Issue