зеркало из https://github.com/mozilla/gecko-dev.git
reverting to the old way to get windows directories since the function I am using does not work on windows systems without IE4. a=nhotta@netscape.com
This commit is contained in:
Родитель
13a03e0325
Коммит
8b43f9100e
|
@ -174,23 +174,43 @@ static char* MakeUpperCase(char* aPath)
|
|||
static void GetWindowsFolder(int folder, nsFileSpec& outDirectory)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
TCHAR path[MAX_PATH+1];
|
||||
HRESULT result = SHGetSpecialFolderPath(NULL, path, folder, true);
|
||||
|
||||
if (!SUCCEEDED(result))
|
||||
LPMALLOC pMalloc = NULL;
|
||||
LPSTR pBuffer = NULL;
|
||||
LPITEMIDLIST pItemIDList = NULL;
|
||||
int len;
|
||||
|
||||
// Get the shell's allocator.
|
||||
if (!SUCCEEDED(SHGetMalloc(&pMalloc)))
|
||||
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
|
||||
int len = PL_strlen(path);
|
||||
if (len>1 && path[len-1] != '\\')
|
||||
{
|
||||
path[len] = '\\';
|
||||
path[len + 1] = '\0';
|
||||
}
|
||||
len = PL_strlen(pBuffer);
|
||||
pBuffer[len] = '\\';
|
||||
pBuffer[len + 1] = '\0';
|
||||
|
||||
// Assign the directory
|
||||
outDirectory = path;
|
||||
outDirectory = pBuffer;
|
||||
|
||||
Clean:
|
||||
// Clean up.
|
||||
if (pItemIDList)
|
||||
pMalloc->Free(pItemIDList);
|
||||
if (pBuffer)
|
||||
pMalloc->Free(pBuffer);
|
||||
|
||||
pMalloc->Release();
|
||||
} // GetWindowsFolder
|
||||
#endif // XP_WIN
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче