From bf7163c089d0d9d9ef4aeb03b7c72a631e49d8d5 Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Tue, 25 Apr 2000 01:48:02 +0000 Subject: [PATCH] checked in warren's patch to remove circular memory leak in directory service removed strcmp'er in favor of atom compares. added comments to nsFileSpec indicating that it is no longer supported. git-svn-id: svn://10.0.0.236/trunk@67030 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/io/nsDirectoryService.cpp | 440 ++++++++++++++++-------- mozilla/xpcom/io/nsDirectoryService.h | 64 ++++ mozilla/xpcom/io/nsFileSpec.cpp | 5 + mozilla/xpcom/io/nsFileSpec.h | 16 + mozilla/xpcom/io/nsFileSpecImpl.cpp | 4 + mozilla/xpcom/io/nsFileSpecMac.cpp | 9 +- mozilla/xpcom/io/nsFileSpecOS2.cpp | 1 + mozilla/xpcom/io/nsFileSpecWin.cpp | 1 + mozilla/xpcom/io/nsIFileSpec.idl | 10 + 9 files changed, 409 insertions(+), 141 deletions(-) diff --git a/mozilla/xpcom/io/nsDirectoryService.cpp b/mozilla/xpcom/io/nsDirectoryService.cpp index f3df87129d9..72613e2edbd 100644 --- a/mozilla/xpcom/io/nsDirectoryService.cpp +++ b/mozilla/xpcom/io/nsDirectoryService.cpp @@ -216,20 +216,65 @@ static nsresult GetCurrentProcessDirectory(nsILocalFile** aFile) } // GetCurrentProcessDirectory() - - - - - - - - - - - - - - +nsIAtom* nsDirectoryService::sCurrentProcess = nsnull; +nsIAtom* nsDirectoryService::sComponentRegistry = nsnull; +nsIAtom* nsDirectoryService::sComponentDirectory = nsnull; +nsIAtom* nsDirectoryService::sOS_DriveDirectory = nsnull; +nsIAtom* nsDirectoryService::sOS_TemporaryDirectory = nsnull; +nsIAtom* nsDirectoryService::sOS_CurrentProcessDirectory = nsnull; +nsIAtom* nsDirectoryService::sOS_CurrentWorkingDirectory = nsnull; +#ifdef XP_MAC +nsIAtom* nsDirectoryService::sDirectory = nsnull; +nsIAtom* nsDirectoryService::sDesktopDirectory = nsnull; +nsIAtom* nsDirectoryService::sTrashDirectory = nsnull; +nsIAtom* nsDirectoryService::sStartupDirectory = nsnull; +nsIAtom* nsDirectoryService::sShutdownDirectory = nsnull; +nsIAtom* nsDirectoryService::sAppleMenuDirectory = nsnull; +nsIAtom* nsDirectoryService::sControlPanelDirectory = nsnull; +nsIAtom* nsDirectoryService::sExtensionDirectory = nsnull; +nsIAtom* nsDirectoryService::sFontsDirectory = nsnull; +nsIAtom* nsDirectoryService::sPreferencesDirectory = nsnull; +nsIAtom* nsDirectoryService::sDocumentsDirectory = nsnull; +nsIAtom* nsDirectoryService::sInternetSearchDirectory = nsnull; +#elif defined (XP_PC) +nsIAtom* nsDirectoryService::sSystemDirectory = nsnull; +nsIAtom* nsDirectoryService::sWindowsDirectory = nsnull; +nsIAtom* nsDirectoryService::sHomeDirectory = nsnull; +nsIAtom* nsDirectoryService::sDesktop = nsnull; +nsIAtom* nsDirectoryService::sPrograms = nsnull; +nsIAtom* nsDirectoryService::sControls = nsnull; +nsIAtom* nsDirectoryService::sPrinters = nsnull; +nsIAtom* nsDirectoryService::sPersonal = nsnull; +nsIAtom* nsDirectoryService::sFavorites = nsnull; +nsIAtom* nsDirectoryService::sStartup = nsnull; +nsIAtom* nsDirectoryService::sRecent = nsnull; +nsIAtom* nsDirectoryService::sSendto = nsnull; +nsIAtom* nsDirectoryService::sBitbucket = nsnull; +nsIAtom* nsDirectoryService::sStartmenu = nsnull; +nsIAtom* nsDirectoryService::sDesktopdirectory = nsnull; +nsIAtom* nsDirectoryService::sDrives = nsnull; +nsIAtom* nsDirectoryService::sNetwork = nsnull; +nsIAtom* nsDirectoryService::sNethood = nsnull; +nsIAtom* nsDirectoryService::sFonts = nsnull; +nsIAtom* nsDirectoryService::sTemplates = nsnull; +nsIAtom* nsDirectoryService::sCommon_Startmenu = nsnull; +nsIAtom* nsDirectoryService::sCommon_Programs = nsnull; +nsIAtom* nsDirectoryService::sCommon_Startup = nsnull; +nsIAtom* nsDirectoryService::sCommon_Desktopdirectory = nsnull; +nsIAtom* nsDirectoryService::sAppdata = nsnull; +nsIAtom* nsDirectoryService::sPrinthood = nsnull; +#elif defined (XP_UNIX) +nsIAtom* nsDirectoryService::sLocalDirectory = nsnull; +nsIAtom* nsDirectoryService::sLibDirectory = nsnull; +nsIAtom* nsDirectoryService::sHomeDirectory = nsnull; +#elif defined (XP_BEOS) +nsIAtom* nsDirectoryService::sSettingsDirectory = nsnull; +nsIAtom* nsDirectoryService::sHomeDirectory = nsnull; +nsIAtom* nsDirectoryService::sDesktopDirectory = nsnull; +nsIAtom* nsDirectoryService::sSystemDirectory = nsnull; +#elif defined (XP_OS2) +nsIAtom* nsDirectoryService::sSystemDirectory = nsnull; +#endif nsDirectoryService* nsDirectoryService::mService = nsnull; @@ -237,28 +282,111 @@ nsDirectoryService* nsDirectoryService::mService = nsnull; nsDirectoryService::nsDirectoryService() { NS_INIT_REFCNT(); - mHashtable = new nsHashtable(256, PR_TRUE); - NS_ASSERTION(mHashtable != NULL, "hashtable null error"); - - NS_NewISupportsArray(getter_AddRefs(mProviders)); - NS_ASSERTION(mProviders.get() != NULL, "providers null error"); - - RegisterProvider(NS_STATIC_CAST(nsIDirectoryServiceProvider*, this)); } NS_METHOD nsDirectoryService::Create(nsISupports *outer, REFNSIID aIID, void **aResult) { - NS_ENSURE_ARG_POINTER(aResult); - + NS_ENSURE_ARG_POINTER(aResult); + nsresult rv; + if (mService == nsnull) { mService = new nsDirectoryService(); if (mService == NULL) return NS_ERROR_OUT_OF_MEMORY; - } + + // use this to temporarily hold a reference to mService: + nsCOMPtr serv = mService; - return mService->QueryInterface(aIID, aResult); + nsresult rv = mService->Init(); + if (NS_FAILED(rv)) return rv; + rv = mService->QueryInterface(aIID, aResult); + } + else + { + rv = mService->QueryInterface(aIID, aResult); + } + return rv; +} + +nsresult +nsDirectoryService::Init() +{ + nsresult rv; + mHashtable = new nsSupportsHashtable(256, PR_TRUE); + if (mHashtable == nsnull) + return NS_ERROR_OUT_OF_MEMORY; + + rv = NS_NewISupportsArray(getter_AddRefs(mProviders)); + if (NS_FAILED(rv)) return rv; + + + nsDirectoryService::sCurrentProcess = NS_NewAtom("xpcom.currentProcess"); + nsDirectoryService::sComponentRegistry = NS_NewAtom("xpcom.currentProcess.componentRegistry"); + nsDirectoryService::sComponentDirectory = NS_NewAtom("xpcom.currentProcess.componentDirectory"); + nsDirectoryService::sOS_DriveDirectory = NS_NewAtom("system.OS_DriveDirectory"); + nsDirectoryService::sOS_TemporaryDirectory = NS_NewAtom("system.OS_TemporaryDirectory"); + nsDirectoryService::sOS_CurrentProcessDirectory = NS_NewAtom("system.OS_CurrentProcessDirectory"); + nsDirectoryService::sOS_CurrentWorkingDirectory = NS_NewAtom("system.OS_CurrentWorkingDirectory"); +#ifdef XP_MAC + nsDirectoryService::sDirectory = NS_NewAtom("system.SystemDirectory"); + nsDirectoryService::sDesktopDirectory = NS_NewAtom("system.DesktopDirectory"); + nsDirectoryService::sTrashDirectory = NS_NewAtom("system.TrashDirectory"); + nsDirectoryService::sStartupDirectory = NS_NewAtom("system.StartupDirectory"); + nsDirectoryService::sShutdownDirectory = NS_NewAtom("system.ShutdownDirectory"); + nsDirectoryService::sAppleMenuDirectory = NS_NewAtom("system.AppleMenuDirectory"); + nsDirectoryService::sControlPanelDirectory = NS_NewAtom("system.ControlPanelDirectory"); + nsDirectoryService::sExtensionDirectory = NS_NewAtom("system.ExtensionDirectory"); + nsDirectoryService::sFontsDirectory = NS_NewAtom("system.FontsDirectory"); + nsDirectoryService::sPreferencesDirectory = NS_NewAtom("system.PreferencesDirectory"); + nsDirectoryService::sDocumentsDirectory = NS_NewAtom("system.DocumentsDirectory"); + nsDirectoryService::sInternetSearchDirectory = NS_NewAtom("system.InternetSearchDirectory"); +#elif defined (XP_PC) + nsDirectoryService::sSystemDirectory = NS_NewAtom("system.SystemDirectory"); + nsDirectoryService::sWindowsDirectory = NS_NewAtom("system.WindowsDirectory"); + nsDirectoryService::sHomeDirectory = NS_NewAtom("system.HomeDirectory"); + nsDirectoryService::sDesktop = NS_NewAtom("system.Desktop"); + nsDirectoryService::sPrograms = NS_NewAtom("system.Programs"); + nsDirectoryService::sControls = NS_NewAtom("system.Controls"); + nsDirectoryService::sPrinters = NS_NewAtom("system.Printers"); + nsDirectoryService::sPersonal = NS_NewAtom("system.Personal"); + nsDirectoryService::sFavorites = NS_NewAtom("system.Favorites"); + nsDirectoryService::sStartup = NS_NewAtom("system.Startup"); + nsDirectoryService::sRecent = NS_NewAtom("system.Recent"); + nsDirectoryService::sSendto = NS_NewAtom("system.Sendto"); + nsDirectoryService::sBitbucket = NS_NewAtom("system.Bitbucket"); + nsDirectoryService::sStartmenu = NS_NewAtom("system.Startmenu"); + nsDirectoryService::sDesktopdirectory = NS_NewAtom("system.Desktopdirectory"); + nsDirectoryService::sDrives = NS_NewAtom("system.Drives"); + nsDirectoryService::sNetwork = NS_NewAtom("system.Network"); + nsDirectoryService::sNethood = NS_NewAtom("system.Nethood"); + nsDirectoryService::sFonts = NS_NewAtom("system.Fonts"); + nsDirectoryService::sTemplates = NS_NewAtom("system.Templates"); + nsDirectoryService::sCommon_Startmenu = NS_NewAtom("system.Common_Startmenu"); + nsDirectoryService::sCommon_Programs = NS_NewAtom("system.Common_Programs"); + nsDirectoryService::sCommon_Startup = NS_NewAtom("system.Common_Startup"); + nsDirectoryService::sCommon_Desktopdirectory = NS_NewAtom("system.Common_Desktopdirectory"); + nsDirectoryService::sAppdata = NS_NewAtom("system.Appdata"); + nsDirectoryService::sPrinthood = NS_NewAtom("system.Printhood"); +#elif defined (XP_UNIX) + nsDirectoryService::sLocalDirectory = NS_NewAtom("system.LocalDirectory"); + nsDirectoryService::sLibDirectory = NS_NewAtom("system.LibDirectory"); + nsDirectoryService::sHomeDirectory = NS_NewAtom("system.HomeDirectory"); +#elif defined (XP_BEOS) + nsDirectoryService::sSettingsDirectory = NS_NewAtom("system.SettingsDirectory"); + nsDirectoryService::sHomeDirectory = NS_NewAtom("system.HomeDirectory"); + nsDirectoryService::sDesktopDirectory = NS_NewAtom("system.DesktopDirectory"); + nsDirectoryService::sSystemDirectory = NS_NewAtom("system.SystemDirectory"); +#elif defined (XP_OS2) + nsDirectoryService::sSystemDirectory = NS_NewAtom("system.SystemDirectory"); +#endif + + rv = RegisterProvider(NS_STATIC_CAST(nsIDirectoryServiceProvider*, this)); + // don't let RegisterProvider keep a reference to ourself, otherwise + // we'll never be freed: + NS_RELEASE_THIS(); + return rv; } PRBool @@ -271,8 +399,81 @@ nsDirectoryService::ReleaseValues(nsHashKey* key, void* data, void* closure) nsDirectoryService::~nsDirectoryService() { - if (mHashtable) - mHashtable->Enumerate(ReleaseValues); + nsresult rv; + // Now we need to carefully remove the weak reference to ourself that we added + // when Init called RegisterProvider. Otherwise, we'll crash trying to delete + // this nsDirectoryService twice: + mRefCnt = 99999; + nsIDirectoryService* serv = NS_STATIC_CAST(nsIDirectoryService*, this); + nsISupports* supports = NS_STATIC_CAST(nsISupports*, serv); + + rv = mProviders->RemoveElement(supports); + NS_ASSERTION(NS_SUCCEEDED(rv), "RemoveElement failed"); + + delete mHashtable; + + NS_IF_RELEASE(nsDirectoryService::sCurrentProcess); + NS_IF_RELEASE(nsDirectoryService::sComponentRegistry); + NS_IF_RELEASE(nsDirectoryService::sComponentDirectory); + NS_IF_RELEASE(nsDirectoryService::sOS_DriveDirectory); + NS_IF_RELEASE(nsDirectoryService::sOS_TemporaryDirectory); + NS_IF_RELEASE(nsDirectoryService::sOS_CurrentProcessDirectory); + NS_IF_RELEASE(nsDirectoryService::sOS_CurrentWorkingDirectory); +#ifdef XP_MAC + NS_IF_RELEASE(nsDirectoryService::sDirectory); + NS_IF_RELEASE(nsDirectoryService::sDesktopDirectory); + NS_IF_RELEASE(nsDirectoryService::sTrashDirectory); + NS_IF_RELEASE(nsDirectoryService::sStartupDirectory); + NS_IF_RELEASE(nsDirectoryService::sShutdownDirectory); + NS_IF_RELEASE(nsDirectoryService::sAppleMenuDirectory); + NS_IF_RELEASE(nsDirectoryService::sControlPanelDirectory); + NS_IF_RELEASE(nsDirectoryService::sExtensionDirectory); + NS_IF_RELEASE(nsDirectoryService::sFontsDirectory); + NS_IF_RELEASE(nsDirectoryService::sPreferencesDirectory); + NS_IF_RELEASE(nsDirectoryService::sDocumentsDirectory); + NS_IF_RELEASE(nsDirectoryService::sInternetSearchDirectory); +#elif defined (XP_PC) + NS_IF_RELEASE(nsDirectoryService::sSystemDirectory); + NS_IF_RELEASE(nsDirectoryService::sWindowsDirectory); + NS_IF_RELEASE(nsDirectoryService::sHomeDirectory); + NS_IF_RELEASE(nsDirectoryService::sDesktop); + NS_IF_RELEASE(nsDirectoryService::sPrograms); + NS_IF_RELEASE(nsDirectoryService::sControls); + NS_IF_RELEASE(nsDirectoryService::sPrinters); + NS_IF_RELEASE(nsDirectoryService::sPersonal); + NS_IF_RELEASE(nsDirectoryService::sFavorites); + NS_IF_RELEASE(nsDirectoryService::sStartup); + NS_IF_RELEASE(nsDirectoryService::sRecent); + NS_IF_RELEASE(nsDirectoryService::sSendto); + NS_IF_RELEASE(nsDirectoryService::sBitbucket); + NS_IF_RELEASE(nsDirectoryService::sStartmenu); + NS_IF_RELEASE(nsDirectoryService::sDesktopdirectory); + NS_IF_RELEASE(nsDirectoryService::sDrives); + NS_IF_RELEASE(nsDirectoryService::sNetwork); + NS_IF_RELEASE(nsDirectoryService::sNethood); + NS_IF_RELEASE(nsDirectoryService::sFonts); + NS_IF_RELEASE(nsDirectoryService::sTemplates); + NS_IF_RELEASE(nsDirectoryService::sCommon_Startmenu); + NS_IF_RELEASE(nsDirectoryService::sCommon_Programs); + NS_IF_RELEASE(nsDirectoryService::sCommon_Startup); + NS_IF_RELEASE(nsDirectoryService::sCommon_Desktopdirectory); + NS_IF_RELEASE(nsDirectoryService::sAppdata); + NS_IF_RELEASE(nsDirectoryService::sPrinthood); +#elif defined (XP_UNIX) + NS_IF_RELEASE(nsDirectoryService::sLocalDirectory); + NS_IF_RELEASE(nsDirectoryService::sLibDirectory); + NS_IF_RELEASE(nsDirectoryService::sHomeDirectory); +#elif defined (XP_BEOS) + NS_IF_RELEASE(nsDirectoryService::sSettingsDirectory); + NS_IF_RELEASE(nsDirectoryService::sHomeDirectory); + NS_IF_RELEASE(nsDirectoryService::sDesktopDirectory); + NS_IF_RELEASE(nsDirectoryService::sSystemDirectory); +#elif defined (XP_OS2) + NS_IF_RELEASE(nsDirectoryService::sSystemDirectory); +#endif + + + } NS_IMPL_ISUPPORTS3(nsDirectoryService, nsIProperties, nsIDirectoryService, nsIDirectoryServiceProvider) @@ -406,17 +607,22 @@ nsDirectoryService::Has(const char *prop, PRBool *_retval) NS_IMETHODIMP nsDirectoryService::RegisterProvider(nsIDirectoryServiceProvider *prov) { - if (!prov) - return NS_ERROR_FAILURE; + nsresult rv; + if (!prov) + return NS_ERROR_FAILURE; + + nsCOMPtr supports = do_QueryInterface(prov, &rv); + if (NS_FAILED(rv)) return rv; - nsCOMPtr supports = do_QueryInterface(prov); - if (supports) return mProviders->AppendElement(supports); - return NS_ERROR_FAILURE; } +// DO NOT ADD ANY LOCATIONS TO THIS FUNCTION UNTIL YOU TALK TO: dougt@netscape.com. +// This is meant to be a place of xpcom or system specific file locations, not +// application specific locations. If you need the later, register a callback for +// your application. NS_IMETHODIMP nsDirectoryService::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval) @@ -427,338 +633,292 @@ nsDirectoryService::GetFile(const char *prop, PRBool *persistant, nsIFile **_ret *_retval = nsnull; *persistant = PR_TRUE; + nsIAtom* inAtom = NS_NewAtom(prop); + // check to see if it is one of our defaults - if (strncmp(prop, "xpcom.currentProcess", 38) == 0) + if (inAtom == nsDirectoryService::sCurrentProcess) { rv = GetCurrentProcessDirectory(getter_AddRefs(localFile)); } - else if (strncmp(prop, "xpcom.currentProcess.componentRegistry", 38) == 0) + else if (inAtom == nsDirectoryService::sComponentRegistry) { rv = GetCurrentProcessDirectory(getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; + if (localFile) localFile->Append(COMPONENT_REGISTRY_NAME); } - else if (strncmp(prop, "xpcom.currentProcess.componentDirectory", 39) == 0) + else if (inAtom == nsDirectoryService::sComponentDirectory) { rv = GetCurrentProcessDirectory(getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; + if (localFile) localFile->Append(COMPONENT_DIRECTORY); } - - else if (strncmp(prop, "system.OS_DriveDirectory", 24) == 0) + else if (inAtom == nsDirectoryService::sOS_DriveDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::OS_DriveDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.OS_TemporaryDirectory", 28) == 0) + else if (inAtom == nsDirectoryService::sOS_TemporaryDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::OS_TemporaryDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.OS_CurrentProcessDirectory", 35) == 0) + else if (inAtom == nsDirectoryService::sOS_CurrentProcessDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::OS_CurrentProcessDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.OS_CurrentWorkingDirectory", 33) == 0) + else if (inAtom == nsDirectoryService::sOS_CurrentWorkingDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::OS_CurrentWorkingDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } #ifdef XP_MAC - else if (strncmp(prop, "system.Directory", 22) == 0) + else if (inAtom == nsDirectoryService::sDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_SystemDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.DesktopDirectory", 23) == 0) + else if (inAtom == nsDirectoryService::sDesktopDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_DesktopDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.TrashDirectory", 21) == 0) + else if (inAtom == nsDirectoryService::sTrashDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_TrashDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.StartupDirectory", 23) == 0) + else if (inAtom == nsDirectoryService::sStartupDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_StartupDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.ShutdownDirectory", 24) == 0) + else if (inAtom == nsDirectoryService::sShutdownDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_ShutdownDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.AppleMenuDirectory", 25) == 0) + else if (inAtom == nsDirectoryService::sAppleMenuDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_AppleMenuDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.ControlPanelDirectory", 28) == 0) + else if (inAtom == nsDirectoryService::sControlPanelDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_ControlPanelDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.ExtensionDirectory", 25) == 0) + else if (inAtom == nsDirectoryService::sExtensionDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_ExtensionDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.FontsDirectory", 21) == 0) + else if (inAtom == nsDirectoryService::sFontsDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_FontsDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.PreferencesDirectory", 27) == 0) + else if (inAtom == nsDirectoryService::sPreferencesDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_PreferencesDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.DocumentsDirectory", 25) == 0) + else if (inAtom == nsDirectoryService::sDocumentsDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_DocumentsDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.InternetSearchDirectory", 30) == 0) + else if (inAtom == nsDirectoryService::sInternetSearchDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_InternetSearchDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } #elif defined (XP_PC) - else if (strncmp(prop, "system.SystemDirectory", 22) == 0) + else if (inAtom == nsDirectoryService::sSystemDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_SystemDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.WindowsDirectory", 23) == 0) + else if (inAtom == nsDirectoryService::sWindowsDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_WindowsDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.HomeDirectory", 20) == 0) + else if (inAtom == nsDirectoryService::sHomeDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_HomeDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Desktop", 14) == 0) + else if (inAtom == nsDirectoryService::sDesktop) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Desktop); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Programs", 15) == 0) + else if (inAtom == nsDirectoryService::sPrograms) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Programs); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Controls", 15) == 0) + else if (inAtom == nsDirectoryService::sControls) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Controls); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Printers", 15) == 0) + else if (inAtom == nsDirectoryService::sPrinters) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Printers); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Personal", 15) == 0) + else if (inAtom == nsDirectoryService::sPersonal) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Personal); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Favorites", 16) == 0) + else if (inAtom == nsDirectoryService::sFavorites) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Favorites); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Startup", 14) == 0) + else if (inAtom == nsDirectoryService::sStartup) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Startup); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Recent", 13) == 0) + else if (inAtom == nsDirectoryService::sRecent) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Recent); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Sendto", 13) == 0) + else if (inAtom == nsDirectoryService::sSendto) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Sendto); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Bitbucket", 16) == 0) + else if (inAtom == nsDirectoryService::sBitbucket) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Bitbucket); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Startmenu", 16) == 0) + else if (inAtom == nsDirectoryService::sStartmenu) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Startmenu); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Desktopdirectory", 23) == 0) + else if (inAtom == nsDirectoryService::sDesktopdirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Desktopdirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Drives", 13) == 0) + else if (inAtom == nsDirectoryService::sDrives) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Drives); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Network", 14) == 0) + else if (inAtom == nsDirectoryService::sNetwork) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Network); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Nethood", 14) == 0) + else if (inAtom == nsDirectoryService::sNethood) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Nethood); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Fonts", 12) == 0) + else if (inAtom == nsDirectoryService::sFonts) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Fonts); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Templates", 16) == 0) + else if (inAtom == nsDirectoryService::sTemplates) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Templates); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Common_Startmenu", 23) == 0) + else if (inAtom == nsDirectoryService::sCommon_Startmenu) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Common_Startmenu); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Common_Programs", 22) == 0) + else if (inAtom == nsDirectoryService::sCommon_Programs) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Common_Programs); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Common_Startup", 21) == 0) + else if (inAtom == nsDirectoryService::sCommon_Startup) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Common_Startup); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Common_Desktopdirectory", 30) == 0) + else if (inAtom == nsDirectoryService::sCommon_Desktopdirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Common_Desktopdirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Appdata", 14) == 0) + else if (inAtom == nsDirectoryService::sAppdata) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Appdata); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.Printhood", 16) == 0) + else if (inAtom == nsDirectoryService::sPrinthood) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Printhood); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } #elif defined (XP_UNIX) - else if (strncmp(prop, "system.LocalDirectory", 21) == 0) + else if (inAtom == nsDirectoryService::sLocalDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Unix_LocalDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.LibDirectory", 19) == 0) + else if (inAtom == nsDirectoryService::sLibDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Unix_LibDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.HomeDirectory", 20) == 0) + else if (inAtom == nsDirectoryService::sHomeDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Unix_HomeDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } #elif defined (XP_BEOS) - else if (strncmp(prop, "system.SettingsDirectory", 24) == 0) + else if (inAtom == nsDirectoryService::sSettingsDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::BeOS_SettingsDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.HomeDirectory", 20) == 0) + else if (inAtom == nsDirectoryService::sHomeDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::BeOS_HomeDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.DesktopDirectory", 23) == 0) + else if (inAtom == nsDirectoryService::sDesktopDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::BeOS_DesktopDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } - else if (strncmp(prop, "system.SystemDirectory", 22) == 0) + else if (inAtom == nsDirectoryService::sSystemDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::BeOS_SystemDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } #elif defined (XP_OS2) - else if (strncmp(prop, "system.SystemDirectory", 22) == 0) + else if (inAtom == nsDirectoryService::sSystemDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::OS2_SystemDirectory); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); - if (NS_FAILED(rv)) return rv; } #endif - if (localFile) + + NS_RELEASE(inAtom); + + if (localFile && NS_SUCCEEDED(rv)) return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval); - return NS_OK; + return rv; } diff --git a/mozilla/xpcom/io/nsDirectoryService.h b/mozilla/xpcom/io/nsDirectoryService.h index 526cffa3ecc..e5f25925627 100644 --- a/mozilla/xpcom/io/nsDirectoryService.h +++ b/mozilla/xpcom/io/nsDirectoryService.h @@ -32,6 +32,8 @@ class nsDirectoryService : public nsIDirectoryService, public nsIProperties, pub public: NS_DEFINE_STATIC_CID_ACCESSOR(NS_DIRECTORY_SERVICE_CID); + + nsresult Init(); // nsISupports interface NS_DECL_ISUPPORTS @@ -53,6 +55,68 @@ private: static PRBool ReleaseValues(nsHashKey* key, void* data, void* closure); nsHashtable* mHashtable; nsCOMPtr mProviders; + + static nsIAtom *sCurrentProcess; + static nsIAtom *sComponentRegistry; + static nsIAtom *sComponentDirectory; + static nsIAtom *sOS_DriveDirectory; + static nsIAtom *sOS_TemporaryDirectory; + static nsIAtom *sOS_CurrentProcessDirectory; + static nsIAtom *sOS_CurrentWorkingDirectory; +#ifdef XP_MAC + static nsIAtom *sDirectory; + static nsIAtom *sDesktopDirectory; + static nsIAtom *sTrashDirectory; + static nsIAtom *sStartupDirectory; + static nsIAtom *sShutdownDirectory; + static nsIAtom *sAppleMenuDirectory; + static nsIAtom *sControlPanelDirectory; + static nsIAtom *sExtensionDirectory; + static nsIAtom *sFontsDirectory; + static nsIAtom *sPreferencesDirectory; + static nsIAtom *sDocumentsDirectory; + static nsIAtom *sInternetSearchDirectory; +#elif defined (XP_PC) + static nsIAtom *sSystemDirectory; + static nsIAtom *sWindowsDirectory; + static nsIAtom *sHomeDirectory; + static nsIAtom *sDesktop; + static nsIAtom *sPrograms; + static nsIAtom *sControls; + static nsIAtom *sPrinters; + static nsIAtom *sPersonal; + static nsIAtom *sFavorites; + static nsIAtom *sStartup; + static nsIAtom *sRecent; + static nsIAtom *sSendto; + static nsIAtom *sBitbucket; + static nsIAtom *sStartmenu; + static nsIAtom *sDesktopdirectory; + static nsIAtom *sDrives; + static nsIAtom *sNetwork; + static nsIAtom *sNethood; + static nsIAtom *sFonts; + static nsIAtom *sTemplates; + static nsIAtom *sCommon_Startmenu; + static nsIAtom *sCommon_Programs; + static nsIAtom *sCommon_Startup; + static nsIAtom *sCommon_Desktopdirectory; + static nsIAtom *sAppdata; + static nsIAtom *sPrinthood; +#elif defined (XP_UNIX) + static nsIAtom *sLocalDirectory; + static nsIAtom *sLibDirectory; + static nsIAtom *sHomeDirectory; +#elif defined (XP_BEOS) + static nsIAtom *sSettingsDirectory; + static nsIAtom *sHomeDirectory; + static nsIAtom *sDesktopDirectory; + static nsIAtom *sSystemDirectory; +#elif defined (XP_OS2) + static nsIAtom *sSystemDirectory; +#endif + + }; diff --git a/mozilla/xpcom/io/nsFileSpec.cpp b/mozilla/xpcom/io/nsFileSpec.cpp index faa19a394eb..e76210435b3 100644 --- a/mozilla/xpcom/io/nsFileSpec.cpp +++ b/mozilla/xpcom/io/nsFileSpec.cpp @@ -825,6 +825,7 @@ nsFileSpec::nsFileSpec() //---------------------------------------------------------------------------------------- : mError(NS_OK) // XXX shouldn't this be NS_ERROR_NOT_INITIALIZED? { +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); } //---------------------------------------------------------------------------------------- @@ -948,6 +949,7 @@ nsFileSpec::nsFileSpec(const nsFilePath& inPath) : mPath((const char*)inPath) , mError(NS_OK) { +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); } //---------------------------------------------------------------------------------------- @@ -966,6 +968,7 @@ nsFileSpec::nsFileSpec(const nsFileSpec& inSpec) : mPath(inSpec.mPath) , mError(NS_OK) { +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); } //---------------------------------------------------------------------------------------- @@ -974,6 +977,7 @@ nsFileSpec::nsFileSpec(const char* inString, PRBool inCreateDirs) : mPath(inString) , mError(NS_OK) { +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); // Make canonical and absolute. nsFileSpecHelpers::Canonify(mPath, inCreateDirs); } @@ -984,6 +988,7 @@ nsFileSpec::nsFileSpec(const nsString& inString, PRBool inCreateDirs) : mPath(inString) , mError(NS_OK) { +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); // Make canonical and absolute. nsFileSpecHelpers::Canonify(mPath, inCreateDirs); } diff --git a/mozilla/xpcom/io/nsFileSpec.h b/mozilla/xpcom/io/nsFileSpec.h index 61290512bb2..5d9cfaf3e6d 100644 --- a/mozilla/xpcom/io/nsFileSpec.h +++ b/mozilla/xpcom/io/nsFileSpec.h @@ -20,6 +20,22 @@ * Contributor(s): */ + + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + THESE CLASSES ARE DEPRECIATED AND UNSUPPORTED! USE |nsIFile| and |nsILocalFile|. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + + + + + + + + + // First checked in on 98/11/20 by John R. McMullen in the wrong directory. // Checked in again 98/12/04. // Polished version 98/12/08. diff --git a/mozilla/xpcom/io/nsFileSpecImpl.cpp b/mozilla/xpcom/io/nsFileSpecImpl.cpp index 572c3cce984..362deeff2c1 100644 --- a/mozilla/xpcom/io/nsFileSpecImpl.cpp +++ b/mozilla/xpcom/io/nsFileSpecImpl.cpp @@ -45,6 +45,8 @@ nsFileSpecImpl::nsFileSpecImpl() , mOutputStream(nsnull) { NS_INIT_ISUPPORTS(); +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); + } //---------------------------------------------------------------------------------------- @@ -55,6 +57,8 @@ nsFileSpecImpl::nsFileSpecImpl(const nsFileSpec& inSpec) , mOutputStream(nsnull) { NS_INIT_ISUPPORTS(); +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); + } //---------------------------------------------------------------------------------------- diff --git a/mozilla/xpcom/io/nsFileSpecMac.cpp b/mozilla/xpcom/io/nsFileSpecMac.cpp index d993da86627..00697d61a58 100644 --- a/mozilla/xpcom/io/nsFileSpecMac.cpp +++ b/mozilla/xpcom/io/nsFileSpecMac.cpp @@ -626,6 +626,7 @@ Clean: nsFileSpec::nsFileSpec() //---------------------------------------------------------------------------------------- { +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); Clear(); } #endif @@ -636,6 +637,7 @@ nsFileSpec::nsFileSpec(const FSSpec& inSpec, PRBool resolveAlias) : mSpec(inSpec) , mError(NS_OK) { +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); if (resolveAlias) { PRBool dummy; @@ -658,13 +660,15 @@ nsFileSpec::nsFileSpec(const nsFileSpec& inSpec) : mSpec(inSpec.mSpec) , mError(inSpec.Error()) { +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); } //---------------------------------------------------------------------------------------- nsFileSpec::nsFileSpec(const char* inNativePathString, PRBool inCreateDirs) //---------------------------------------------------------------------------------------- { - Clear(); // this sets mError to NS_ERROR_NOT_INITIALIZED + NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); + Clear(); // this sets mError to NS_ERROR_NOT_INITIALIZED if (inNativePathString) { @@ -680,6 +684,7 @@ nsFileSpec::nsFileSpec(const char* inNativePathString, PRBool inCreateDirs) nsFileSpec::nsFileSpec(const nsString& inNativePathString, PRBool inCreateDirs) //---------------------------------------------------------------------------------------- { +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); Clear(); // this sets mError to NS_ERROR_NOT_INITIALIZED mError = NS_FILE_RESULT( @@ -695,6 +700,7 @@ nsFileSpec::nsFileSpec(const nsString& inNativePathString, PRBool inCreateDirs) nsFileSpec::nsFileSpec(short vRefNum, long parID, ConstStr255Param fileName, PRBool resolveAlias) //---------------------------------------------------------------------------------------- { +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); mError = NS_FILE_RESULT(::FSMakeFSSpec(vRefNum, parID, fileName, &mSpec)); if (mError == NS_FILE_RESULT(fnfErr)) mError = NS_OK; @@ -710,6 +716,7 @@ nsFileSpec::nsFileSpec(short vRefNum, long parID, ConstStr255Param fileName, PR nsFileSpec::nsFileSpec(const nsFilePath& inPath) //---------------------------------------------------------------------------------------- { +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); *this = inPath.GetFileSpec(); } diff --git a/mozilla/xpcom/io/nsFileSpecOS2.cpp b/mozilla/xpcom/io/nsFileSpecOS2.cpp index f46dedc8f6f..fb3d70d4419 100644 --- a/mozilla/xpcom/io/nsFileSpecOS2.cpp +++ b/mozilla/xpcom/io/nsFileSpecOS2.cpp @@ -178,6 +178,7 @@ nsFilePath::nsFilePath( const nsFileSpec &inSpec) nsFileSpec::nsFileSpec( const nsFilePath &inPath) { + NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); *this = inPath; } diff --git a/mozilla/xpcom/io/nsFileSpecWin.cpp b/mozilla/xpcom/io/nsFileSpecWin.cpp index 8d3f971cbfa..65bfa567fca 100644 --- a/mozilla/xpcom/io/nsFileSpecWin.cpp +++ b/mozilla/xpcom/io/nsFileSpecWin.cpp @@ -162,6 +162,7 @@ void nsFileSpecHelpers::NativeToUnix(nsSimpleCharString& ioPath) nsFileSpec::nsFileSpec(const nsFilePath& inPath) //---------------------------------------------------------------------------------------- { +// NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); *this = inPath; } diff --git a/mozilla/xpcom/io/nsIFileSpec.idl b/mozilla/xpcom/io/nsIFileSpec.idl index bb3484157f9..05b8fa9c06c 100644 --- a/mozilla/xpcom/io/nsIFileSpec.idl +++ b/mozilla/xpcom/io/nsIFileSpec.idl @@ -20,6 +20,11 @@ * Contributor(s): */ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + THIS INTERFACE IS DEPRECIATED AND UNSUPPORTED! USE |nsIFile| and |nsILocalFile|. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + // This is the only correct cross-platform way to specify a file. // Strings are not such a way. If you grew up on windows or unix, you // may think they are. Welcome to reality. @@ -37,6 +42,11 @@ interface nsIInputStream; // Define Progid and CID %{C++ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + THIS INTERFACE IS DEPRECIATED AND UNSUPPORTED! USE |nsIFile| and |nsILocalFile|. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + // {A5740FA2-146E-11d3-B00D-00C04FC2E79B} #define NS_FILESPEC_CID \ { 0xa5740fa2, 0x146e, 0x11d3, { 0xb0, 0xd, 0x0, 0xc0, 0x4f, 0xc2, 0xe7, 0x9b } }