Bug 465783: Fennec default download location inaccessible to users. r=sdwilsh sr=bsmedberg

This commit is contained in:
Antonio Gomes (tonikitoo) 2009-02-25 03:26:45 -04:00
parent 65d0af3965
commit f2a9697470
2 changed files with 111 additions and 82 deletions

View File

@ -68,7 +68,7 @@
#include "nsEmbedCID.h" #include "nsEmbedCID.h"
#include "nsToolkitCompsCID.h" #include "nsToolkitCompsCID.h"
#if defined(XP_WIN) && !defined(WINCE) #if defined(XP_WIN) && !defined(WINCE)
#include <shlobj.h> #include <shlobj.h>
#ifdef DOWNLOAD_SCANNER #ifdef DOWNLOAD_SCANNER
#include "nsDownloadScanner.h" #include "nsDownloadScanner.h"
@ -229,7 +229,7 @@ nsresult
nsDownloadManager::RemoveDownloadsForURI(nsIURI *aURI) nsDownloadManager::RemoveDownloadsForURI(nsIURI *aURI)
{ {
mozStorageStatementScoper scope(mGetIdsForURIStatement); mozStorageStatementScoper scope(mGetIdsForURIStatement);
nsCAutoString source; nsCAutoString source;
nsresult rv = aURI->GetSpec(source); nsresult rv = aURI->GetSpec(source);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -615,7 +615,7 @@ nsDownloadManager::RestoreDatabaseState()
"SET state = ?1 " "SET state = ?1 "
"WHERE state = ?2"), getter_AddRefs(stmt)); "WHERE state = ?2"), getter_AddRefs(stmt));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
PRInt32 i = 0; PRInt32 i = 0;
rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_FINISHED); rv = stmt->BindInt32Parameter(i++, nsIDownloadManager::DOWNLOAD_FINISHED);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -923,9 +923,9 @@ nsDownloadManager::GetQuitBehavior()
PRInt32 val; PRInt32 val;
rv = pref->GetIntPref(PREF_BDM_QUITBEHAVIOR, &val); rv = pref->GetIntPref(PREF_BDM_QUITBEHAVIOR, &val);
NS_ENSURE_SUCCESS(rv, QUIT_AND_RESUME); NS_ENSURE_SUCCESS(rv, QUIT_AND_RESUME);
switch (val) { switch (val) {
case 1: case 1:
return QUIT_AND_PAUSE; return QUIT_AND_PAUSE;
case 2: case 2:
return QUIT_AND_CANCEL; return QUIT_AND_CANCEL;
@ -1156,6 +1156,16 @@ nsDownloadManager::GetDefaultDownloadsDirectory(nsILocalFile **aResult)
} }
} }
#elif defined(XP_UNIX) #elif defined(XP_UNIX)
#if defined(NS_OSSO)
// As maemo does not follow the XDG "standard" (as usually desktop
// Linux distros do) neither has a working $HOME/Desktop folder
// for us to fallback into, "$HOME/MyDocs/.documents/" is the folder
// we found most apropriate to be the default target folder for downloads
// on the platform.
rv = dirService->Get(NS_UNIX_XDG_DOCUMENTS_DIR,
NS_GET_IID(nsILocalFile),
getter_AddRefs(downloadDir));
#else
rv = dirService->Get(NS_UNIX_DEFAULT_DOWNLOAD_DIR, rv = dirService->Get(NS_UNIX_DEFAULT_DOWNLOAD_DIR,
NS_GET_IID(nsILocalFile), NS_GET_IID(nsILocalFile),
getter_AddRefs(downloadDir)); getter_AddRefs(downloadDir));
@ -1168,6 +1178,7 @@ nsDownloadManager::GetDefaultDownloadsDirectory(nsILocalFile **aResult)
rv = downloadDir->Append(folderName); rv = downloadDir->Append(folderName);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
} }
#endif
#else #else
rv = dirService->Get(NS_OS_HOME_DIR, rv = dirService->Get(NS_OS_HOME_DIR,
NS_GET_IID(nsILocalFile), NS_GET_IID(nsILocalFile),
@ -2175,7 +2186,7 @@ nsDownload::SetState(DownloadState aState)
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mTarget); nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mTarget);
nsCOMPtr<nsIFile> file; nsCOMPtr<nsIFile> file;
nsAutoString path; nsAutoString path;
if (fileURL && if (fileURL &&
NS_SUCCEEDED(fileURL->GetFile(getter_AddRefs(file))) && NS_SUCCEEDED(fileURL->GetFile(getter_AddRefs(file))) &&
file && file &&
@ -2438,7 +2449,7 @@ nsDownload::OnStateChange(nsIWebProgress *aWebProgress,
} else if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_NETWORK) && } else if ((aStateFlags & STATE_STOP) && (aStateFlags & STATE_IS_NETWORK) &&
IsFinishable()) { IsFinishable()) {
// We got both STOP and NETWORK so that means the whole request is done // We got both STOP and NETWORK so that means the whole request is done
// (and not just a single file if there are multiple files) // (and not just a single file if there are multiple files)
if (NS_SUCCEEDED(aStatus)) { if (NS_SUCCEEDED(aStatus)) {
// We can't completely trust the bytes we've added up because we might be // We can't completely trust the bytes we've added up because we might be
// missing on some/all of the progress updates (especially from cache). // missing on some/all of the progress updates (especially from cache).

View File

@ -53,7 +53,7 @@
#include <string.h> #include <string.h>
#include <direct.h> #include <direct.h>
// These are not defined by VC6. // These are not defined by VC6.
#ifndef CSIDL_LOCAL_APPDATA #ifndef CSIDL_LOCAL_APPDATA
#define CSIDL_LOCAL_APPDATA 0x001C #define CSIDL_LOCAL_APPDATA 0x001C
#endif #endif
@ -133,7 +133,7 @@ NS_COM void StartupSpecialSystemDirectory()
gShell32DLLInst = LoadLibraryW(L"shell32.dll"); gShell32DLLInst = LoadLibraryW(L"shell32.dll");
if(gShell32DLLInst) if(gShell32DLLInst)
{ {
gGetKnownFolderPath = (nsGetKnownFolderPath) gGetKnownFolderPath = (nsGetKnownFolderPath)
GetProcAddress(gShell32DLLInst, "SHGetKnownFolderPath"); GetProcAddress(gShell32DLLInst, "SHGetKnownFolderPath");
} }
#endif #endif
@ -164,8 +164,8 @@ static nsresult GetKnownFolder(GUID* guid, nsILocalFile** aFile)
if (!path) if (!path)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
nsresult rv = NS_NewLocalFile(nsDependentString(path), nsresult rv = NS_NewLocalFile(nsDependentString(path),
PR_TRUE, PR_TRUE,
aFile); aFile);
CoTaskMemFree(path); CoTaskMemFree(path);
@ -181,43 +181,43 @@ static nsresult GetWindowsFolder(int folder, nsILocalFile** aFile)
#endif #endif
WCHAR path[MAX_PATH + 2]; WCHAR path[MAX_PATH + 2];
HRESULT result = SHGetSpecialFolderPathW(NULL, path, folder, true); HRESULT result = SHGetSpecialFolderPathW(NULL, path, folder, true);
if (!SUCCEEDED(result)) if (!SUCCEEDED(result))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
// Append the trailing slash // Append the trailing slash
int len = wcslen(path); int len = wcslen(path);
if (len > 1 && path[len - 1] != L'\\') if (len > 1 && path[len - 1] != L'\\')
{ {
path[len] = L'\\'; path[len] = L'\\';
path[++len] = L'\0'; path[++len] = L'\0';
} }
return NS_NewLocalFile(nsDependentString(path, len), PR_TRUE, aFile); return NS_NewLocalFile(nsDependentString(path, len), PR_TRUE, aFile);
} }
#endif // XP_WIN #endif // XP_WIN
#if defined (XP_BEOS) #if defined (XP_BEOS)
static nsresult static nsresult
GetBeOSFolder( directory_which which, dev_t volume, nsILocalFile** aFile) GetBeOSFolder( directory_which which, dev_t volume, nsILocalFile** aFile)
{ {
char path[MAXPATHLEN]; char path[MAXPATHLEN];
if (volume < 0) if (volume < 0)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
status_t result = find_directory(which, volume, false, path, MAXPATHLEN - 2); status_t result = find_directory(which, volume, false, path, MAXPATHLEN - 2);
if (result != B_OK) if (result != B_OK)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
int len = strlen(path); int len = strlen(path);
if (len == 0) if (len == 0)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
if (path[len-1] != '/') if (path[len-1] != '/')
{ {
path[len] = '/'; path[len] = '/';
path[len+1] = '\0'; path[len+1] = '\0';
} }
return NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, aFile); return NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, aFile);
} }
@ -231,16 +231,16 @@ GetUnixHomeDir(nsILocalFile** aFile)
char *pHome; char *pHome;
pHome = getenv("HOME"); pHome = getenv("HOME");
if (*pHome == '/') { if (*pHome == '/') {
return NS_NewNativeLocalFile(nsDependentCString(pHome), return NS_NewNativeLocalFile(nsDependentCString(pHome),
PR_TRUE, PR_TRUE,
aFile); aFile);
} else { } else {
return NS_NewNativeLocalFile(nsDependentCString(decc$translate_vms(pHome)), return NS_NewNativeLocalFile(nsDependentCString(decc$translate_vms(pHome)),
PR_TRUE, PR_TRUE,
aFile); aFile);
} }
#else #else
return NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), return NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")),
PR_TRUE, aFile); PR_TRUE, aFile);
#endif #endif
} }
@ -281,7 +281,7 @@ xdg_user_dir_lookup (const char *type)
char *p, *d; char *p, *d;
int len; int len;
int relative; int relative;
home_dir = getenv ("HOME"); home_dir = getenv ("HOME");
if (home_dir == NULL) if (home_dir == NULL)
@ -319,11 +319,11 @@ xdg_user_dir_lookup (const char *type)
len = strlen (buffer); len = strlen (buffer);
if (len > 0 && buffer[len-1] == '\n') if (len > 0 && buffer[len-1] == '\n')
buffer[len-1] = 0; buffer[len-1] = 0;
p = buffer; p = buffer;
while (*p == ' ' || *p == '\t') while (*p == ' ' || *p == '\t')
p++; p++;
if (strncmp (p, "XDG_", 4) != 0) if (strncmp (p, "XDG_", 4) != 0)
continue; continue;
p += 4; p += 4;
@ -340,14 +340,14 @@ xdg_user_dir_lookup (const char *type)
if (*p != '=') if (*p != '=')
continue; continue;
p++; p++;
while (*p == ' ' || *p == '\t') while (*p == ' ' || *p == '\t')
p++; p++;
if (*p != '"') if (*p != '"')
continue; continue;
p++; p++;
relative = 0; relative = 0;
if (strncmp (p, "$HOME/", 6) == 0) if (strncmp (p, "$HOME/", 6) == 0)
{ {
@ -356,7 +356,7 @@ xdg_user_dir_lookup (const char *type)
} }
else if (*p != '/') else if (*p != '/')
continue; continue;
if (relative) if (relative)
{ {
user_dir = (char*) malloc (strlen (home_dir) + 1 + strlen (p) + 1); user_dir = (char*) malloc (strlen (home_dir) + 1 + strlen (p) + 1);
@ -374,7 +374,7 @@ xdg_user_dir_lookup (const char *type)
*user_dir = 0; *user_dir = 0;
} }
d = user_dir + strlen (user_dir); d = user_dir + strlen (user_dir);
while (*p && *p != '"') while (*p && *p != '"')
{ {
@ -421,7 +421,7 @@ GetUnixXDGUserDirectory(SystemDirectories aSystemDirectory,
{ {
char *dir = xdg_user_dir_lookup char *dir = xdg_user_dir_lookup
(xdg_user_dirs + xdg_user_dir_offsets[aSystemDirectory - (xdg_user_dirs + xdg_user_dir_offsets[aSystemDirectory -
Unix_XDG_Desktop]); Unix_XDG_Desktop]);
nsresult rv; nsresult rv;
nsCOMPtr<nsILocalFile> file; nsCOMPtr<nsILocalFile> file;
@ -437,10 +437,28 @@ GetUnixXDGUserDirectory(SystemDirectories aSystemDirectory,
return rv; return rv;
rv = file->AppendNative(NS_LITERAL_CSTRING("Desktop")); rv = file->AppendNative(NS_LITERAL_CSTRING("Desktop"));
} else { }
#if defined(NS_OSSO)
// "MYDOCSDIR" is exported to point to "/home/user/MyDocs" in maemo.
else if (Unix_XDG_Documents == aSystemDirectory) {
char *myDocs = PR_GetEnv("MYDOCSDIR");
if (!myDocs || !*myDocs)
return NS_ERROR_FAILURE;
rv = NS_NewNativeLocalFile(nsDependentCString(myDocs), PR_TRUE,
getter_AddRefs(file));
if (NS_FAILED(rv))
return rv;
rv = file->AppendNative(NS_LITERAL_CSTRING(".documents"));
}
#else
else {
// no fallback for the other XDG dirs // no fallback for the other XDG dirs
rv = NS_ERROR_FAILURE; rv = NS_ERROR_FAILURE;
} }
#endif
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
@ -478,8 +496,8 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
#if defined(XP_WIN) #if defined(XP_WIN)
if (!_wgetcwd(path, MAX_PATH)) if (!_wgetcwd(path, MAX_PATH))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
return NS_NewLocalFile(nsDependentString(path), return NS_NewLocalFile(nsDependentString(path),
PR_TRUE, PR_TRUE,
aFile); aFile);
#elif defined(XP_OS2) #elif defined(XP_OS2)
if (DosQueryPathInfo( ".", FIL_QUERYFULLNAME, path, MAXPATHLEN)) if (DosQueryPathInfo( ".", FIL_QUERYFULLNAME, path, MAXPATHLEN))
@ -490,8 +508,8 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
#endif #endif
#if !defined(XP_WIN) #if !defined(XP_WIN)
return NS_NewNativeLocalFile(nsDependentCString(path), return NS_NewNativeLocalFile(nsDependentCString(path),
PR_TRUE, PR_TRUE,
aFile); aFile);
#endif #endif
@ -499,7 +517,7 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
#if defined (WINCE) #if defined (WINCE)
{ {
return NS_NewLocalFile(nsDependentString(L"\\"), return NS_NewLocalFile(nsDependentString(L"\\"),
PR_TRUE, PR_TRUE,
aFile); aFile);
} }
#elif defined (XP_WIN) #elif defined (XP_WIN)
@ -511,7 +529,7 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
path[3] = 0; path[3] = 0;
return NS_NewLocalFile(nsDependentString(path), return NS_NewLocalFile(nsDependentString(path),
PR_TRUE, PR_TRUE,
aFile); aFile);
} }
#elif defined(XP_OS2) #elif defined(XP_OS2)
@ -523,24 +541,24 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index... buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index...
return NS_NewNativeLocalFile(nsDependentCString(buffer), return NS_NewNativeLocalFile(nsDependentCString(buffer),
PR_TRUE, PR_TRUE,
aFile); aFile);
} }
#else #else
return NS_NewNativeLocalFile(nsDependentCString("/"), return NS_NewNativeLocalFile(nsDependentCString("/"),
PR_TRUE, PR_TRUE,
aFile); aFile);
#endif #endif
case OS_TemporaryDirectory: case OS_TemporaryDirectory:
#if defined (XP_WIN) #if defined (XP_WIN)
{ {
DWORD len = ::GetTempPathW(MAX_PATH, path); DWORD len = ::GetTempPathW(MAX_PATH, path);
if (len == 0) if (len == 0)
break; break;
return NS_NewLocalFile(nsDependentString(path, len), return NS_NewLocalFile(nsDependentString(path, len),
PR_TRUE, PR_TRUE,
aFile); aFile);
} }
#elif defined(XP_OS2) #elif defined(XP_OS2)
@ -580,16 +598,16 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
} }
} }
} }
return NS_NewNativeLocalFile(nsDependentCString(tPath), return NS_NewNativeLocalFile(nsDependentCString(tPath),
PR_TRUE, PR_TRUE,
aFile); aFile);
} }
#else #else
break; break;
#endif #endif
#if defined (XP_WIN) #if defined (XP_WIN)
case Win_SystemDirectory: case Win_SystemDirectory:
{ {
#ifdef WINCE #ifdef WINCE
PRUnichar winDirBuf[MAX_PATH]; PRUnichar winDirBuf[MAX_PATH];
nsAutoString winDir; nsAutoString winDir;
@ -600,21 +618,21 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
return NS_NewLocalFile(winDir, PR_TRUE, aFile); return NS_NewLocalFile(winDir, PR_TRUE, aFile);
#else #else
PRInt32 len = ::GetSystemDirectoryW(path, MAX_PATH); PRInt32 len = ::GetSystemDirectoryW(path, MAX_PATH);
// Need enough space to add the trailing backslash // Need enough space to add the trailing backslash
if (!len || len > MAX_PATH - 2) if (!len || len > MAX_PATH - 2)
break; break;
path[len] = L'\\'; path[len] = L'\\';
path[++len] = L'\0'; path[++len] = L'\0';
return NS_NewLocalFile(nsDependentString(path, len), return NS_NewLocalFile(nsDependentString(path, len),
PR_TRUE, PR_TRUE,
aFile); aFile);
#endif #endif
} }
case Win_WindowsDirectory: case Win_WindowsDirectory:
{ {
#ifdef WINCE #ifdef WINCE
PRUnichar winDirBuf[MAX_PATH]; PRUnichar winDirBuf[MAX_PATH];
nsAutoString winDir; nsAutoString winDir;
@ -625,16 +643,16 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
return NS_NewLocalFile(winDir, PR_TRUE, aFile); return NS_NewLocalFile(winDir, PR_TRUE, aFile);
#else #else
PRInt32 len = ::GetWindowsDirectoryW(path, MAX_PATH); PRInt32 len = ::GetWindowsDirectoryW(path, MAX_PATH);
// Need enough space to add the trailing backslash // Need enough space to add the trailing backslash
if (!len || len > MAX_PATH - 2) if (!len || len > MAX_PATH - 2)
break; break;
path[len] = L'\\'; path[len] = L'\\';
path[++len] = L'\0'; path[++len] = L'\0';
return NS_NewLocalFile(nsDependentString(path, len), return NS_NewLocalFile(nsDependentString(path, len),
PR_TRUE, PR_TRUE,
aFile); aFile);
#endif #endif
} }
@ -645,19 +663,19 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
} }
case Win_HomeDirectory: case Win_HomeDirectory:
{ {
PRInt32 len; PRInt32 len;
if ((len = ::GetEnvironmentVariableW(L"HOME", path, MAX_PATH)) > 0) if ((len = ::GetEnvironmentVariableW(L"HOME", path, MAX_PATH)) > 0)
{ {
// Need enough space to add the trailing backslash // Need enough space to add the trailing backslash
if (len > MAX_PATH - 2) if (len > MAX_PATH - 2)
break; break;
path[len] = L'\\'; path[len] = L'\\';
path[++len] = L'\0'; path[++len] = L'\0';
return NS_NewLocalFile(nsDependentString(path, len), return NS_NewLocalFile(nsDependentString(path, len),
PR_TRUE, PR_TRUE,
aFile); aFile);
} }
@ -668,18 +686,18 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
DWORD len2 = ::GetEnvironmentVariableW(L"HOMEPATH", temp, MAX_PATH); DWORD len2 = ::GetEnvironmentVariableW(L"HOMEPATH", temp, MAX_PATH);
if (0 < len2 && len + len2 < MAX_PATH) if (0 < len2 && len + len2 < MAX_PATH)
wcsncat(path, temp, len2); wcsncat(path, temp, len2);
len = wcslen(path); len = wcslen(path);
// Need enough space to add the trailing backslash // Need enough space to add the trailing backslash
if (len > MAX_PATH - 2) if (len > MAX_PATH - 2)
break; break;
path[len] = L'\\'; path[len] = L'\\';
path[++len] = L'\0'; path[++len] = L'\0';
return NS_NewLocalFile(nsDependentString(path, len), return NS_NewLocalFile(nsDependentString(path, len),
PR_TRUE, PR_TRUE,
aFile); aFile);
} }
} }
@ -806,12 +824,12 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
#if defined(XP_UNIX) #if defined(XP_UNIX)
case Unix_LocalDirectory: case Unix_LocalDirectory:
return NS_NewNativeLocalFile(nsDependentCString("/usr/local/netscape/"), return NS_NewNativeLocalFile(nsDependentCString("/usr/local/netscape/"),
PR_TRUE, PR_TRUE,
aFile); aFile);
case Unix_LibDirectory: case Unix_LibDirectory:
return NS_NewNativeLocalFile(nsDependentCString("/usr/local/lib/netscape/"), return NS_NewNativeLocalFile(nsDependentCString("/usr/local/lib/netscape/"),
PR_TRUE, PR_TRUE,
aFile); aFile);
case Unix_HomeDirectory: case Unix_HomeDirectory:
@ -852,7 +870,7 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
{ {
return GetBeOSFolder(B_BEOS_DIRECTORY,0, aFile); return GetBeOSFolder(B_BEOS_DIRECTORY,0, aFile);
} }
#endif #endif
#ifdef XP_OS2 #ifdef XP_OS2
case OS2_SystemDirectory: case OS2_SystemDirectory:
{ {
@ -862,8 +880,8 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
&ulBootDrive, sizeof ulBootDrive); &ulBootDrive, sizeof ulBootDrive);
buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index... buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index...
return NS_NewNativeLocalFile(nsDependentCString(buffer), return NS_NewNativeLocalFile(nsDependentCString(buffer),
PR_TRUE, PR_TRUE,
aFile); aFile);
} }
@ -875,8 +893,8 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
&ulBootDrive, sizeof ulBootDrive); &ulBootDrive, sizeof ulBootDrive);
buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index... buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index...
return NS_NewNativeLocalFile(nsDependentCString(buffer), return NS_NewNativeLocalFile(nsDependentCString(buffer),
PR_TRUE, PR_TRUE,
aFile); aFile);
} }
@ -896,7 +914,7 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
tPath = buffer; tPath = buffer;
} }
rv = NS_NewNativeLocalFile(nsDependentCString(tPath), rv = NS_NewNativeLocalFile(nsDependentCString(tPath),
PR_TRUE, PR_TRUE,
aFile); aFile);
PrfWriteProfileString(HINI_USERPROFILE, "Mozilla", "Home", tPath); PrfWriteProfileString(HINI_USERPROFILE, "Mozilla", "Home", tPath);
@ -905,7 +923,7 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
case OS2_DesktopDirectory: case OS2_DesktopDirectory:
{ {
char szPath[CCHMAXPATH + 1]; char szPath[CCHMAXPATH + 1];
BOOL fSuccess; BOOL fSuccess;
fSuccess = WinQueryActiveDesktopPathname (szPath, sizeof(szPath)); fSuccess = WinQueryActiveDesktopPathname (szPath, sizeof(szPath));
if (!fSuccess) { if (!fSuccess) {
@ -913,14 +931,14 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
// the Home directory instead // the Home directory instead
return GetSpecialSystemDirectory(OS2_HomeDirectory, aFile); return GetSpecialSystemDirectory(OS2_HomeDirectory, aFile);
} }
int len = strlen (szPath); int len = strlen (szPath);
if (len > CCHMAXPATH -1) if (len > CCHMAXPATH -1)
break; break;
szPath[len] = '\\'; szPath[len] = '\\';
szPath[len + 1] = '\0'; szPath[len + 1] = '\0';
return NS_NewNativeLocalFile(nsDependentCString(szPath), return NS_NewNativeLocalFile(nsDependentCString(szPath),
PR_TRUE, PR_TRUE,
aFile); aFile);
} }
#endif #endif
@ -947,6 +965,6 @@ GetOSXFolderType(short aDomain, OSType aFolderType, nsILocalFile **localFile)
rv = localMacFile->InitWithFSRef(&fsRef); rv = localMacFile->InitWithFSRef(&fsRef);
} }
return rv; return rv;
} }
#endif #endif