Bug 415761. Support Unicode file names in GetHIconFromFile. r=vlad

--HG--
extra : rebase_source : 855aeee93d123575f1f98c3d9833d31510feae1e
This commit is contained in:
Kyle Huey 2009-06-24 17:50:36 -04:00
Родитель e104dd4bd5
Коммит c2e65659f8
1 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@ -328,13 +328,14 @@ nsresult nsIconChannel::GetHIconFromFile(HICON *hIcon)
PRBool fileExists = PR_FALSE;
nsCAutoString filePath(fileExt);
nsAutoString filePath;
CopyASCIItoUTF16(fileExt, filePath);
if (localFile)
{
rv = localFile->Normalize();
NS_ENSURE_SUCCESS(rv, rv);
localFile->GetNativePath(filePath);
localFile->GetPath(filePath);
if (filePath.Length() < 2 || filePath[1] != ':')
return NS_ERROR_MALFORMED_URI; // UNC
@ -343,7 +344,7 @@ nsresult nsIconChannel::GetHIconFromFile(HICON *hIcon)
else {
localFile->Exists(&fileExists);
if (!fileExists)
localFile->GetNativeLeafName(filePath);
localFile->GetLeafName(filePath);
}
}
@ -364,7 +365,7 @@ nsresult nsIconChannel::GetHIconFromFile(HICON *hIcon)
// If the mime service does not know about this mime type, we show
// the generic icon.
// In any case, we need to insert a '.' before the extension.
filePath = NS_LITERAL_CSTRING(".") + defFileExt;
filePath = NS_LITERAL_STRING(".") + NS_ConvertUTF8toUTF16(defFileExt);
}
// Is this the "Desktop" folder?
@ -381,7 +382,7 @@ nsresult nsIconChannel::GetHIconFromFile(HICON *hIcon)
// Not a special folder, or something else failed above.
if (!shellResult)
shellResult = ::SHGetFileInfoW(NS_ConvertUTF8toUTF16(filePath).get(),
shellResult = ::SHGetFileInfoW(filePath.get(),
FILE_ATTRIBUTE_ARCHIVE, &sfi, sizeof(sfi), infoFlags);
if (shellResult && sfi.hIcon)