This commit is contained in:
dougt%netscape.com 2001-10-16 23:33:08 +00:00
Родитель 768a355fc3
Коммит cf7a0ceb11
1 изменённых файлов: 11 добавлений и 31 удалений

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

@ -174,43 +174,23 @@ static char* MakeUpperCase(char* aPath)
static void GetWindowsFolder(int folder, nsFileSpec& outDirectory)
//----------------------------------------------------------------------------------------
{
LPMALLOC pMalloc = NULL;
LPSTR pBuffer = NULL;
LPITEMIDLIST pItemIDList = NULL;
int len;
// Get the shell's allocator.
if (!SUCCEEDED(SHGetMalloc(&pMalloc)))
TCHAR path[MAX_PATH+1];
HRESULT result = SHGetSpecialFolderPath(NULL, path, folder, true);
if (!SUCCEEDED(result))
return;
// Allocate a buffer
if ((pBuffer = (LPSTR) pMalloc->Alloc(MAX_PATH + 2)) == NULL)
return;
// Get the PIDL for the folder.
if (!SUCCEEDED(SHGetSpecialFolderLocation(
NULL, folder, &pItemIDList)))
goto Clean;
if (!SUCCEEDED(SHGetPathFromIDList(pItemIDList, pBuffer)))
goto Clean;
// Append the trailing slash
len = PL_strlen(pBuffer);
pBuffer[len] = '\\';
pBuffer[len + 1] = '\0';
int len = PL_strlen(path);
if (len>1 && path[len-1] != '\\')
{
path[len] = '\\';
path[len + 1] = '\0';
}
// Assign the directory
outDirectory = pBuffer;
outDirectory = path;
Clean:
// Clean up.
if (pItemIDList)
pMalloc->Free(pItemIDList);
if (pBuffer)
pMalloc->Free(pBuffer);
pMalloc->Release();
} // GetWindowsFolder
#endif // XP_WIN