fixing bug 195148 - XPInstall API's getFolder should support Classic and OSX folders under OSX. r=ccarlen,dougt sr=sspitzer

This commit is contained in:
ssu%netscape.com 2003-04-07 07:02:32 +00:00
parent 625a741ad3
commit 669e313b68
7 changed files with 445 additions and 170 deletions

View File

@ -1982,7 +1982,7 @@ char * nsProfile::GetOldRegLocation()
#elif defined(XP_WIN)
NS_GetSpecialDirectory(NS_WIN_WINDOWS_DIR, getter_AddRefs(oldRegFile));
#elif defined(XP_MAC)
NS_GetSpecialDirectory(NS_MAC_CLASSICPREFS_DIR, getter_AddRefs(oldRegFile));
NS_GetSpecialDirectory(NS_MAC_PREFS_DIR, getter_AddRefs(oldRegFile));
#endif
if (!oldRegFile)

View File

@ -339,7 +339,12 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
}
#elif defined(XP_MAC)
return nsIFileFromOSType(kTemporaryFolderType, aFile);
#elif defined(XP_MACOSX)
{
return GetOSXFolderType(kUserDomain, kTemporaryFolderType, aFile);
}
#elif defined(XP_UNIX) || defined(XP_BEOS)
{
static const char *tPath = nsnull;
@ -778,65 +783,23 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
}
}
#if defined(XP_MAC)
//----------------------------------------------------------------------------------------
static nsresult nsIFileFromOSType(OSType folderType, nsILocalFile** aFile)
//----------------------------------------------------------------------------------------
#if defined (XP_MACOSX)
nsresult
GetOSXFolderType(short aDomain, OSType aFolderType, nsILocalFile **localFile)
{
CInfoPBRec cinfo;
DirInfo *dipb=(DirInfo *)&cinfo;
// hack: first check for kDefaultDownloadFolderType
// if it is, get Internet Config Download folder, if that's
// not availble use desktop folder
if (folderType == kDefaultDownloadFolderType)
{
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
{
if (NS_SUCCEEDED(icService->GetDownloadFolder(&mSpec)))
return;
else
folderType = kDesktopFolderType;
}
else
{
folderType = kDesktopFolderType;
}
}
// Call FindFolder to fill in the vrefnum and dirid
for (int attempts = 0; attempts < 2; attempts++)
{
mError = NS_FILE_RESULT(FindFolder(kOnSystemDisk,
folderType,
true,
&dipb->ioVRefNum,
&dipb->ioDrDirID));
if (NS_SUCCEEDED(mError))
break;
if (attempts > 0)
return;
switch (folderType)
{
case kDocumentsFolderType:
// Find folder will find this, as long as it exists.
// The "create" parameter, however, is sadly ignored.
// How do we internationalize this?
return nsIFileFromOSType(kVolumeRootFolderType;
*this += "Documents";
CreateDirectory();
break;
} // switch
} // for
StrFileName filename;
filename[0] = '\0';
dipb->ioNamePtr = (StringPtr)&filename;
dipb->ioFDirIndex = -1;
mError = NS_FILE_RESULT(PBGetCatInfoSync(&cinfo));
if (NS_SUCCEEDED(mError))
{
mError = NS_FILE_RESULT(FSMakeFSSpec(dipb->ioVRefNum, dipb->ioDrParID, filename, &mSpec));
}
}
#endif // XP_MAC
OSErr err;
FSRef fsRef;
nsresult rv = NS_ERROR_FAILURE;
err = ::FSFindFolder(aDomain, aFolderType, kCreateFolder, &fsRef);
if (err == noErr)
{
NS_NewLocalFile(nsString(), PR_TRUE, localFile);
nsCOMPtr<nsILocalFileMac> localMacFile(do_QueryInterface(*localFile));
if (localMacFile)
rv = localMacFile->InitWithFSRef(&fsRef);
}
return rv;
}
#endif

View File

@ -31,6 +31,8 @@
#if defined(XP_MAC) || defined(XP_MACOSX)
#include <Types.h>
#include "nsILocalFileMac.h"
#include "prenv.h"
#endif
@ -109,5 +111,9 @@ enum SystemDirectories {
nsresult
GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
nsILocalFile** aFile);
#if defined(XP_MACOSX)
nsresult
GetOSXFolderType(short aDomain, OSType aFolderType, nsILocalFile **localFile);
#endif
#endif

View File

@ -100,7 +100,7 @@
#if defined (XP_WIN)
#define HOME_DIR NS_WIN_APPDATA_DIR
#elif defined (XP_MAC) || defined (XP_MACOSX)
#define HOME_DIR NS_MAC_HOME_DIR
#define HOME_DIR NS_OSX_HOME_DIR
#elif defined (XP_UNIX)
#define HOME_DIR NS_UNIX_HOME_DIR
#elif defined (XP_OS2)
@ -348,7 +348,7 @@ nsIAtom* nsDirectoryService::sOS_DriveDirectory = nsnull;
nsIAtom* nsDirectoryService::sOS_TemporaryDirectory = nsnull;
nsIAtom* nsDirectoryService::sOS_CurrentProcessDirectory = nsnull;
nsIAtom* nsDirectoryService::sOS_CurrentWorkingDirectory = nsnull;
#if defined(XP_MAC)
#if defined (XP_MACOSX)
nsIAtom* nsDirectoryService::sDirectory = nsnull;
nsIAtom* nsDirectoryService::sDesktopDirectory = nsnull;
nsIAtom* nsDirectoryService::sTrashDirectory = nsnull;
@ -358,16 +358,28 @@ nsIAtom* nsDirectoryService::sAppleMenuDirectory = nsnull;
nsIAtom* nsDirectoryService::sControlPanelDirectory = nsnull;
nsIAtom* nsDirectoryService::sExtensionDirectory = nsnull;
nsIAtom* nsDirectoryService::sFontsDirectory = nsnull;
nsIAtom* nsDirectoryService::sClassicPreferencesDirectory = nsnull;
nsIAtom* nsDirectoryService::sPreferencesDirectory = nsnull;
nsIAtom* nsDirectoryService::sDocumentsDirectory = nsnull;
nsIAtom* nsDirectoryService::sInternetSearchDirectory = nsnull;
nsIAtom* nsDirectoryService::sHomeDirectory = nsnull;
nsIAtom* nsDirectoryService::sDefaultDownloadDirectory = nsnull;
nsIAtom* nsDirectoryService::sUserLibDirectory = nsnull;
#elif defined (XP_MACOSX)
nsIAtom* nsDirectoryService::sHomeDirectory = nsnull;
nsIAtom* nsDirectoryService::sDefaultDownloadDirectory = nsnull;
nsIAtom* nsDirectoryService::sUserDesktopDirectory = nsnull;
nsIAtom* nsDirectoryService::sLocalDesktopDirectory = nsnull;
nsIAtom* nsDirectoryService::sUserApplicationsDirectory = nsnull;
nsIAtom* nsDirectoryService::sLocalApplicationsDirectory = nsnull;
nsIAtom* nsDirectoryService::sUserDocumentsDirectory = nsnull;
nsIAtom* nsDirectoryService::sLocalDocumentsDirectory = nsnull;
nsIAtom* nsDirectoryService::sUserInternetPlugInDirectory = nsnull;
nsIAtom* nsDirectoryService::sLocalInternetPlugInDirectory = nsnull;
nsIAtom* nsDirectoryService::sUserFrameworksDirectory = nsnull;
nsIAtom* nsDirectoryService::sLocalFrameworksDirectory = nsnull;
nsIAtom* nsDirectoryService::sUserPreferencesDirectory = nsnull;
nsIAtom* nsDirectoryService::sLocalPreferencesDirectory = nsnull;
nsIAtom* nsDirectoryService::sPictureDocumentsDirectory = nsnull;
nsIAtom* nsDirectoryService::sMovieDocumentsDirectory = nsnull;
nsIAtom* nsDirectoryService::sMusicDocumentsDirectory = nsnull;
nsIAtom* nsDirectoryService::sInternetSitesDirectory = nsnull;
#elif defined (XP_WIN)
nsIAtom* nsDirectoryService::sSystemDirectory = nsnull;
nsIAtom* nsDirectoryService::sWindowsDirectory = nsnull;
@ -444,26 +456,38 @@ static const nsStaticAtom directory_atoms[] = {
{ NS_OS_TEMP_DIR, &nsDirectoryService::sOS_TemporaryDirectory },
{ NS_OS_CURRENT_PROCESS_DIR, &nsDirectoryService::sOS_CurrentProcessDirectory },
{ NS_OS_CURRENT_WORKING_DIR, &nsDirectoryService::sOS_CurrentWorkingDirectory },
#if defined(XP_MAC)
{ NS_OS_SYSTEM_DIR, &nsDirectoryService::sDirectory },
{ NS_MAC_DESKTOP_DIR, &nsDirectoryService::sDesktopDirectory },
{ NS_MAC_TRASH_DIR, &nsDirectoryService::sTrashDirectory },
{ NS_MAC_STARTUP_DIR, &nsDirectoryService::sStartupDirectory },
{ NS_MAC_SHUTDOWN_DIR, &nsDirectoryService::sShutdownDirectory },
{ NS_MAC_APPLE_MENU_DIR, &nsDirectoryService::sAppleMenuDirectory },
{ NS_MAC_CONTROL_PANELS_DIR, &nsDirectoryService::sControlPanelDirectory },
{ NS_MAC_EXTENSIONS_DIR, &nsDirectoryService::sExtensionDirectory },
{ NS_MAC_FONTS_DIR, &nsDirectoryService::sFontsDirectory },
{ NS_MAC_CLASSICPREFS_DIR, &nsDirectoryService::sClassicPreferencesDirectory },
{ NS_MAC_PREFS_DIR, &nsDirectoryService::sPreferencesDirectory },
{ NS_MAC_DOCUMENTS_DIR, &nsDirectoryService::sDocumentsDirectory },
{ NS_MAC_INTERNET_SEARCH_DIR, &nsDirectoryService::sInternetSearchDirectory },
{ NS_MAC_HOME_DIR, &nsDirectoryService::sHomeDirectory },
{ NS_MAC_DEFAULT_DOWNLOAD_DIR, &nsDirectoryService::sDefaultDownloadDirectory },
{ NS_MAC_USER_LIB_DIR, &nsDirectoryService::sUserLibDirectory },
#elif defined (XP_MACOSX)
{ NS_MAC_HOME_DIR, &nsDirectoryService::sHomeDirectory },
{ NS_MAC_DEFAULT_DOWNLOAD_DIR, &nsDirectoryService::sDefaultDownloadDirectory },
#if defined (XP_MACOSX)
{ NS_OS_SYSTEM_DIR, &nsDirectoryService::sDirectory },
{ NS_MAC_DESKTOP_DIR, &nsDirectoryService::sDesktopDirectory },
{ NS_MAC_TRASH_DIR, &nsDirectoryService::sTrashDirectory },
{ NS_MAC_STARTUP_DIR, &nsDirectoryService::sStartupDirectory },
{ NS_MAC_SHUTDOWN_DIR, &nsDirectoryService::sShutdownDirectory },
{ NS_MAC_APPLE_MENU_DIR, &nsDirectoryService::sAppleMenuDirectory },
{ NS_MAC_CONTROL_PANELS_DIR, &nsDirectoryService::sControlPanelDirectory },
{ NS_MAC_EXTENSIONS_DIR, &nsDirectoryService::sExtensionDirectory },
{ NS_MAC_FONTS_DIR, &nsDirectoryService::sFontsDirectory },
{ NS_MAC_PREFS_DIR, &nsDirectoryService::sPreferencesDirectory },
{ NS_MAC_DOCUMENTS_DIR, &nsDirectoryService::sDocumentsDirectory },
{ NS_MAC_INTERNET_SEARCH_DIR, &nsDirectoryService::sInternetSearchDirectory },
{ NS_MAC_USER_LIB_DIR, &nsDirectoryService::sUserLibDirectory },
{ NS_OSX_HOME_DIR, &nsDirectoryService::sHomeDirectory },
{ NS_OSX_DEFAULT_DOWNLOAD_DIR, &nsDirectoryService::sDefaultDownloadDirectory },
{ NS_OSX_USER_DESKTOP_DIR, &nsDirectoryService::sUserDesktopDirectory },
{ NS_OSX_LOCAL_DESKTOP_DIR, &nsDirectoryService::sLocalDesktopDirectory },
{ NS_OSX_USER_APPLICATIONS_DIR, &nsDirectoryService::sUserApplicationsDirectory },
{ NS_OSX_LOCAL_APPLICATIONS_DIR, &nsDirectoryService::sLocalApplicationsDirectory },
{ NS_OSX_USER_DOCUMENTS_DIR, &nsDirectoryService::sUserDocumentsDirectory },
{ NS_OSX_LOCAL_DOCUMENTS_DIR, &nsDirectoryService::sLocalDocumentsDirectory },
{ NS_OSX_USER_INTERNET_PLUGIN_DIR, &nsDirectoryService::sUserInternetPlugInDirectory },
{ NS_OSX_LOCAL_INTERNET_PLUGIN_DIR, &nsDirectoryService::sLocalInternetPlugInDirectory },
{ NS_OSX_USER_FRAMEWORKS_DIR, &nsDirectoryService::sUserFrameworksDirectory },
{ NS_OSX_LOCAL_FRAMEWORKS_DIR, &nsDirectoryService::sLocalFrameworksDirectory },
{ NS_OSX_USER_PREFERENCES_DIR, &nsDirectoryService::sUserPreferencesDirectory },
{ NS_OSX_LOCAL_PREFERENCES_DIR, &nsDirectoryService::sLocalPreferencesDirectory },
{ NS_OSX_PICTURE_DOCUMENTS_DIR, &nsDirectoryService::sPictureDocumentsDirectory },
{ NS_OSX_MOVIE_DOCUMENTS_DIR, &nsDirectoryService::sMovieDocumentsDirectory },
{ NS_OSX_MUSIC_DOCUMENTS_DIR, &nsDirectoryService::sMusicDocumentsDirectory },
{ NS_OSX_INTERNET_SITES_DIR, &nsDirectoryService::sInternetSitesDirectory },
#elif defined (XP_WIN)
{ NS_OS_SYSTEM_DIR, &nsDirectoryService::sSystemDirectory },
{ NS_WIN_WINDOWS_DIR, &nsDirectoryService::sWindowsDirectory },
@ -806,84 +830,62 @@ nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_ret
rv = GetSpecialSystemDirectory(OS_CurrentWorkingDirectory, getter_AddRefs(localFile));
}
#if defined(XP_MAC)
#if defined(XP_MACOSX)
else if (inAtom == nsDirectoryService::sDirectory)
{
rv = GetSpecialSystemDirectory(Mac_SystemDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kClassicDomain, kSystemFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sDesktopDirectory)
{
rv = GetSpecialSystemDirectory(Mac_DesktopDirectory, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sHomeDirectory)
{
rv = GetSpecialSystemDirectory(Mac_DocumentsDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kClassicDomain, kDesktopFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sTrashDirectory)
{
rv = GetSpecialSystemDirectory(Mac_TrashDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kClassicDomain, kTrashFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sStartupDirectory)
{
rv = GetSpecialSystemDirectory(Mac_StartupDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kClassicDomain, kStartupFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sShutdownDirectory)
{
rv = GetSpecialSystemDirectory(Mac_ShutdownDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kClassicDomain, kShutdownFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sAppleMenuDirectory)
{
rv = GetSpecialSystemDirectory(Mac_AppleMenuDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kClassicDomain, kAppleMenuFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sControlPanelDirectory)
{
rv = GetSpecialSystemDirectory(Mac_ControlPanelDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kClassicDomain, kControlPanelFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sExtensionDirectory)
{
rv = GetSpecialSystemDirectory(Mac_ExtensionDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kClassicDomain, kExtensionFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sFontsDirectory)
{
rv = GetSpecialSystemDirectory(Mac_FontsDirectory, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sClassicPreferencesDirectory)
{
rv = GetSpecialSystemDirectory(Mac_ClassicPreferencesDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kClassicDomain, kFontsFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sPreferencesDirectory)
{
rv = GetSpecialSystemDirectory(Mac_PreferencesDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kClassicDomain, kPreferencesFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sDocumentsDirectory)
{
rv = GetSpecialSystemDirectory(Mac_DocumentsDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kClassicDomain, kDocumentsFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sInternetSearchDirectory)
{
rv = GetSpecialSystemDirectory(Mac_InternetSearchDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kClassicDomain, kInternetSearchSitesFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sDefaultDownloadDirectory)
{
rv = GetSpecialSystemDirectory(Mac_DefaultDownloadDirectory, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sUserLibDirectory)
{
rv = GetSpecialSystemDirectory(Mac_UserLibDirectory, getter_AddRefs(localFile));
rv = GetOSXFolderType(kUserDomain, kDomainLibraryFolderType, getter_AddRefs(localFile));
}
#elif defined (XP_MACOSX)
else if (inAtom == nsDirectoryService::sHomeDirectory)
{
OSErr err;
FSRef fsRef;
err = ::FSFindFolder(kUserDomain, kDomainTopLevelFolderType, kCreateFolder, &fsRef);
if (err == noErr)
{
NS_NewLocalFile(nsString(), PR_TRUE, getter_AddRefs(localFile));
nsCOMPtr<nsILocalFileMac> localMacFile(do_QueryInterface(localFile));
if (localMacFile)
rv = localMacFile->InitWithFSRef(&fsRef);
}
rv = GetOSXFolderType(kUserDomain, kDomainTopLevelFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sDefaultDownloadDirectory)
{
@ -910,11 +912,9 @@ nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_ret
}
if NS_FAILED(rv)
{ // We got an error getting the DL folder from IC so try finding the user's Desktop folder
FSRef fsRef;
err = ::FSFindFolder(kUserDomain, kSystemDesktopFolderType, kCreateFolder, &fsRef);
if (err == noErr)
rv = localMacFile->InitWithFSRef(&fsRef);
{
// We got an error getting the DL folder from IC so try finding the user's Desktop folder
rv = GetOSXFolderType(kUserDomain, kSystemDesktopFolderType, getter_AddRefs(localFile));
}
}
@ -922,6 +922,70 @@ nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_ret
// Negligible perf hit as this directory is only requested for downloads
*persistent = PR_FALSE;
}
else if (inAtom == nsDirectoryService::sUserDesktopDirectory)
{
rv = GetOSXFolderType(kUserDomain, kDesktopFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sLocalDesktopDirectory)
{
rv = GetOSXFolderType(kLocalDomain, kDesktopFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sUserApplicationsDirectory)
{
rv = GetOSXFolderType(kUserDomain, kApplicationsFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sLocalApplicationsDirectory)
{
rv = GetOSXFolderType(kLocalDomain, kApplicationsFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sUserDocumentsDirectory)
{
rv = GetOSXFolderType(kUserDomain, kDocumentsFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sLocalDocumentsDirectory)
{
rv = GetOSXFolderType(kLocalDomain, kDocumentsFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sUserInternetPlugInDirectory)
{
rv = GetOSXFolderType(kUserDomain, kInternetPlugInFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sLocalInternetPlugInDirectory)
{
rv = GetOSXFolderType(kLocalDomain, kInternetPlugInFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sUserFrameworksDirectory)
{
rv = GetOSXFolderType(kUserDomain, kFrameworksFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sLocalFrameworksDirectory)
{
rv = GetOSXFolderType(kLocalDomain, kFrameworksFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sUserPreferencesDirectory)
{
rv = GetOSXFolderType(kUserDomain, kPreferencesFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sLocalPreferencesDirectory)
{
rv = GetOSXFolderType(kLocalDomain, kPreferencesFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sPictureDocumentsDirectory)
{
rv = GetOSXFolderType(kUserDomain, kPictureDocumentsFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sMovieDocumentsDirectory)
{
rv = GetOSXFolderType(kUserDomain, kMovieDocumentsFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sMusicDocumentsDirectory)
{
rv = GetOSXFolderType(kUserDomain, kMusicDocumentsFolderType, getter_AddRefs(localFile));
}
else if (inAtom == nsDirectoryService::sInternetSitesDirectory)
{
rv = GetOSXFolderType(kUserDomain, kInternetSitesFolderType, getter_AddRefs(localFile));
}
#elif defined (XP_WIN)
else if (inAtom == nsDirectoryService::sSystemDirectory)
{

View File

@ -92,7 +92,7 @@ public:
static nsIAtom *sOS_TemporaryDirectory;
static nsIAtom *sOS_CurrentProcessDirectory;
static nsIAtom *sOS_CurrentWorkingDirectory;
#if defined(XP_MAC)
#if defined (XP_MACOSX)
static nsIAtom *sDirectory;
static nsIAtom *sDesktopDirectory;
static nsIAtom *sTrashDirectory;
@ -102,16 +102,28 @@ public:
static nsIAtom *sControlPanelDirectory;
static nsIAtom *sExtensionDirectory;
static nsIAtom *sFontsDirectory;
static nsIAtom *sClassicPreferencesDirectory;
static nsIAtom *sPreferencesDirectory;
static nsIAtom *sDocumentsDirectory;
static nsIAtom *sInternetSearchDirectory;
static nsIAtom *sHomeDirectory;
static nsIAtom *sDefaultDownloadDirectory;
static nsIAtom *sUserLibDirectory;
#elif defined (XP_MACOSX)
static nsIAtom *sHomeDirectory;
static nsIAtom *sDefaultDownloadDirectory;
static nsIAtom *sUserDesktopDirectory;
static nsIAtom *sLocalDesktopDirectory;
static nsIAtom *sUserApplicationsDirectory;
static nsIAtom *sLocalApplicationsDirectory;
static nsIAtom *sUserDocumentsDirectory;
static nsIAtom *sLocalDocumentsDirectory;
static nsIAtom *sUserInternetPlugInDirectory;
static nsIAtom *sLocalInternetPlugInDirectory;
static nsIAtom *sUserFrameworksDirectory;
static nsIAtom *sLocalFrameworksDirectory;
static nsIAtom *sUserPreferencesDirectory;
static nsIAtom *sLocalPreferencesDirectory;
static nsIAtom *sPictureDocumentsDirectory;
static nsIAtom *sMovieDocumentsDirectory;
static nsIAtom *sMusicDocumentsDirectory;
static nsIAtom *sInternetSitesDirectory;
#elif defined (XP_WIN)
static nsIAtom *sSystemDirectory;
static nsIAtom *sWindowsDirectory;

View File

@ -72,7 +72,7 @@
#define NS_OS_SYSTEM_DIR "SysD"
#endif
#if defined(XP_MAC)
#if defined (XP_MACOSX)
#define NS_MAC_DESKTOP_DIR "Desk"
#define NS_MAC_TRASH_DIR "Trsh"
#define NS_MAC_STARTUP_DIR "Strt"
@ -81,16 +81,30 @@
#define NS_MAC_CONTROL_PANELS_DIR "CntlPnl"
#define NS_MAC_EXTENSIONS_DIR "Exts"
#define NS_MAC_FONTS_DIR "Fnts"
#define NS_MAC_CLASSICPREFS_DIR "ClassicPrfs"
#define NS_MAC_PREFS_DIR "Prfs"
#define NS_MAC_DOCUMENTS_DIR "Docs"
#define NS_MAC_INTERNET_SEARCH_DIR "ISrch"
#define NS_MAC_HOME_DIR "Home"
#define NS_OSX_HOME_DIR "Home"
#define NS_MAC_HOME_DIR NS_OSX_HOME_DIR
#define NS_MAC_DEFAULT_DOWNLOAD_DIR "DfltDwnld"
#define NS_MAC_USER_LIB_DIR "ULibDir" // Only available under OS X
#elif defined (XP_MACOSX)
#define NS_MAC_HOME_DIR "Home"
#define NS_MAC_DEFAULT_DOWNLOAD_DIR "DfltDwnld"
#define NS_OSX_DEFAULT_DOWNLOAD_DIR NS_MAC_DEFAULT_DOWNLOAD_DIR
#define NS_OSX_USER_DESKTOP_DIR "UsrDsk"
#define NS_OSX_LOCAL_DESKTOP_DIR "LocDsk"
#define NS_OSX_USER_APPLICATIONS_DIR "UsrApp"
#define NS_OSX_LOCAL_APPLICATIONS_DIR "LocApp"
#define NS_OSX_USER_DOCUMENTS_DIR "UsrDocs"
#define NS_OSX_LOCAL_DOCUMENTS_DIR "LocDocs"
#define NS_OSX_USER_INTERNET_PLUGIN_DIR "UsrIntrntPlgn"
#define NS_OSX_LOCAL_INTERNET_PLUGIN_DIR "LoclIntrntPlgn"
#define NS_OSX_USER_FRAMEWORKS_DIR "UsrFrmwrks"
#define NS_OSX_LOCAL_FRAMEWORKS_DIR "LocFrmwrks"
#define NS_OSX_USER_PREFERENCES_DIR "UsrPrfs"
#define NS_OSX_LOCAL_PREFERENCES_DIR "LocPrfs"
#define NS_OSX_PICTURE_DOCUMENTS_DIR "Pct"
#define NS_OSX_MOVIE_DOCUMENTS_DIR "Mov"
#define NS_OSX_MUSIC_DOCUMENTS_DIR "Music"
#define NS_OSX_INTERNET_SITES_DIR "IntrntSts"
#elif defined (XP_WIN)
#define NS_WIN_WINDOWS_DIR "WinD"
#define NS_WIN_HOME_DIR "Home"

View File

@ -50,40 +50,59 @@ struct DirectoryTable
struct DirectoryTable DirectoryTable[] =
{
{"Plugins", 100 },
{"Program", 101 },
{"Communicator", 101 }, // "Communicator" is deprecated
{"Plugins", 100 },
{"Program", 101 },
{"Communicator", 101 }, // "Communicator" is deprecated
{"Temporary", 104 },
{"Temporary", 104 },
{"Profile", 106 },
{"Current User", 106 }, // "Current User" is deprecated
{"Preferences", 107 },
{"OS Drive", 108 },
{"file:///", 109 },
{"Profile", 106 },
{"Current User", 106 }, // "Current User" is deprecated
{"Preferences", 107 },
{"OS Drive", 108 },
{"file:///", 109 },
{"Components", 110 },
{"Chrome", 111 },
{"Components", 110 },
{"Chrome", 111 },
{"Win System", 200 },
{"Windows", 201 },
{"Win System", 200 },
{"Windows", 201 },
{"Mac System", 300 },
{"Mac Desktop", 301 },
{"Mac Trash", 302 },
{"Mac Startup", 303 },
{"Mac Shutdown", 304 },
{"Mac Apple Menu", 305 },
{"Mac Control Panel", 306 },
{"Mac Extension", 307 },
{"Mac Fonts", 308 },
{"Mac Preferences", 309 },
{"Mac Documents", 310 },
{"Mac System", 300 },
{"Mac Desktop", 301 },
{"Mac Trash", 302 },
{"Mac Startup", 303 },
{"Mac Shutdown", 304 },
{"Mac Apple Menu", 305 },
{"Mac Control Panel", 306 },
{"Mac Extension", 307 },
{"Mac Fonts", 308 },
{"Mac Preferences", 309 },
{"Mac Documents", 310 },
{"Unix Local", 400 },
{"Unix Lib", 401 },
{"MacOSX Home", 500 },
{"MacOSX Default Download", 501 },
{"MacOSX User Desktop", 502 },
{"MacOSX Local Desktop", 503 },
{"MacOSX User Applications", 504 },
{"MacOSX Local Applications", 505 },
{"MacOSX User Documents", 506 },
{"MacOSX Local Documents", 507 },
{"MacOSX User Internet PlugIn", 508 },
{"MacOSX Local Internet PlugIn", 509 },
{"MacOSX User Frameworks", 510 },
{"MacOSX Local Frameworks", 511 },
{"MacOSX User Preferences", 512 },
{"MacOSX Local Preferences", 513 },
{"MacOSX Picture Documents", 514 },
{"MacOSX Movie Documents", 515 },
{"MacOSX Music Documents", 516 },
{"MacOSX Internet Sites", 517 },
{"", -1 }
{"Unix Local", 400 },
{"Unix Lib", 401 },
{"", -1 }
};
@ -339,7 +358,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
break;
#endif
#ifdef XP_MAC
#if defined (XP_MACOSX)
case 300: /////////////////////////////////////////////////////////// Mac System
{
nsCOMPtr<nsIProperties> directoryService =
@ -460,6 +479,203 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
getter_AddRefs(mFileSpec));
}
break;
case 500: /////////////////////////////////////////////////////////// MacOSX Home
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_HOME_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 501: /////////////////////////////////////////////////////////// MacOSX Default Download
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_DEFAULT_DOWNLOAD_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 502: /////////////////////////////////////////////////////////// MacOSX User Desktop
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_USER_DESKTOP_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 503: /////////////////////////////////////////////////////////// MacOSX Local Desktop
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_LOCAL_DESKTOP_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 504: /////////////////////////////////////////////////////////// MacOSX User Applications
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_USER_APPLICATIONS_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 505: /////////////////////////////////////////////////////////// MacOSX Local Applications
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_LOCAL_APPLICATIONS_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 506: /////////////////////////////////////////////////////////// MacOSX User Documents
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_USER_DOCUMENTS_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 507: /////////////////////////////////////////////////////////// MacOSX Local Documents
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_LOCAL_DOCUMENTS_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 508: /////////////////////////////////////////////////////////// MacOSX User Internet PlugIn
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_USER_INTERNET_PLUGIN_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 509: /////////////////////////////////////////////////////////// MacOSX Local Internet PlugIn
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_LOCAL_INTERNET_PLUGIN_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 510: /////////////////////////////////////////////////////////// MacOSX User Frameworks
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_USER_FRAMEWORKS_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 511: /////////////////////////////////////////////////////////// MacOSX Local Frameworks
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_LOCAL_FRAMEWORKS_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 512: /////////////////////////////////////////////////////////// MacOSX User Preferences
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_USER_PREFERENCES_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 513: /////////////////////////////////////////////////////////// MacOSX Local Preferences
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_LOCAL_PREFERENCES_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 514: /////////////////////////////////////////////////////////// MacOSX Picture Documents
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_PICTURE_DOCUMENTS_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 515: /////////////////////////////////////////////////////////// MacOSX Movie Documents
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_MOVIE_DOCUMENTS_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 516: /////////////////////////////////////////////////////////// MacOSX Music Documents
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_MUSIC_DOCUMENTS_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
case 517: /////////////////////////////////////////////////////////// MacOSX Internet Sites
{
nsCOMPtr<nsIProperties> directoryService =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
if (!directoryService) return;
directoryService->Get(NS_OSX_INTERNET_SITES_DIR,
NS_GET_IID(nsIFile),
getter_AddRefs(mFileSpec));
}
break;
#endif
#if defined(XP_UNIX) && !defined(XP_MACOSX)