wininet: Use short path name when container path can't be converted to CP_ACP.

This commit is contained in:
Piotr Caban 2013-04-01 13:12:30 +02:00 committed by Alexandre Julliard
parent e4e79e7183
commit 96fb659ba9
1 changed files with 15 additions and 0 deletions

View File

@ -770,6 +770,7 @@ static void cache_containers_init(void)
WCHAR wszCachePath[MAX_PATH];
WCHAR wszMutexName[MAX_PATH];
int path_len, suffix_len;
BOOL def_char;
if (!SHGetSpecialFolderPathW(NULL, wszCachePath, DefaultContainerData[i].nFolder, TRUE))
{
@ -797,6 +798,20 @@ static void cache_containers_init(void)
wszCachePath[path_len + suffix_len + 2] = '\0';
}
if (!WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, wszCachePath, path_len,
NULL, 0, NULL, &def_char) || def_char)
{
WCHAR tmp[MAX_PATH];
/* cannot convert path to ANSI code page */
if (!(path_len = GetShortPathNameW(wszCachePath, tmp, MAX_PATH)) ||
!WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, tmp, path_len,
NULL, 0, NULL, &def_char) || def_char)
ERR("Can't create container path accessible by ANSI functions\n");
else
memcpy(wszCachePath, tmp, (path_len+1)*sizeof(WCHAR));
}
cache_containers_add(DefaultContainerData[i].cache_prefix, wszCachePath,
DefaultContainerData[i].default_entry_type, wszMutexName);
}