diff options
author | Moonchild <moonchild@palemoon.org> | 2021-09-29 13:42:51 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-09-29 13:42:51 +0000 |
commit | 300300ed70fe45cdd9ef6014e233681a8f36c675 (patch) | |
tree | 6296166c16ba2edc657fd801679dc65ead3a057f /xpcom | |
parent | d5b9e12e27bc95bb643f29be923200683ce14e9b (diff) | |
download | aura-central-300300ed70fe45cdd9ef6014e233681a8f36c675.tar.gz |
Issue mcp-graveyard/UXP%1751 - Nuke MOZ_WIDGET_COCOA
Diffstat (limited to 'xpcom')
-rw-r--r-- | xpcom/base/CycleCollectedJSContext.cpp | 9 | ||||
-rw-r--r-- | xpcom/build/XPCOM.h | 5 | ||||
-rw-r--r-- | xpcom/build/XPCOMInit.cpp | 8 | ||||
-rw-r--r-- | xpcom/build/XPCOMModule.inc | 4 | ||||
-rw-r--r-- | xpcom/components/ManifestParser.cpp | 3 | ||||
-rw-r--r-- | xpcom/io/SpecialSystemDirectory.cpp | 39 | ||||
-rw-r--r-- | xpcom/io/SpecialSystemDirectory.h | 11 | ||||
-rw-r--r-- | xpcom/io/nsAppFileLocationProvider.cpp | 104 | ||||
-rw-r--r-- | xpcom/io/nsAppFileLocationProvider.h | 4 | ||||
-rw-r--r-- | xpcom/io/nsDirectoryService.cpp | 118 | ||||
-rw-r--r-- | xpcom/io/nsDirectoryServiceAtomList.h | 32 | ||||
-rw-r--r-- | xpcom/io/nsDirectoryServiceDefs.h | 37 | ||||
-rw-r--r-- | xpcom/io/nsLocalFileCommon.cpp | 2 | ||||
-rw-r--r-- | xpcom/io/nsLocalFileUnix.cpp | 601 | ||||
-rw-r--r-- | xpcom/io/nsLocalFileUnix.h | 10 |
15 files changed, 10 insertions, 977 deletions
diff --git a/xpcom/base/CycleCollectedJSContext.cpp b/xpcom/base/CycleCollectedJSContext.cpp index 0a4c2da4f..7b33197ff 100644 --- a/xpcom/base/CycleCollectedJSContext.cpp +++ b/xpcom/base/CycleCollectedJSContext.cpp @@ -1434,16 +1434,7 @@ CycleCollectedJSContext::RunInMetastableState(already_AddRefed<nsIRunnable>&& aR data.mRecursionDepth = RecursionDepth(); // There must be an event running to get here. -#ifndef MOZ_WIDGET_COCOA MOZ_ASSERT(data.mRecursionDepth > mBaseRecursionDepth); -#else - // XXX bug 1261143 - // Recursion depth should be greater than mBaseRecursionDepth, - // or the runnable will stay in the queue forever. - if (data.mRecursionDepth <= mBaseRecursionDepth) { - data.mRecursionDepth = mBaseRecursionDepth + 1; - } -#endif mMetastableStateEvents.AppendElement(Move(data)); } diff --git a/xpcom/build/XPCOM.h b/xpcom/build/XPCOM.h index 49bdc991a..44ab2a275 100644 --- a/xpcom/build/XPCOM.h +++ b/xpcom/build/XPCOM.h @@ -132,11 +132,6 @@ #include "nsIObjectOutputStream.h" #include "nsIPipe.h" -#ifdef MOZ_WIDGET_COCOA -#include "nsILocalFileMac.h" -#include "nsIMacUtils.h" -#endif - // xpcom/glue utility headers #include "nsComponentManagerUtils.h" diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp index e96314a1c..4327ef707 100644 --- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -113,10 +113,6 @@ extern nsresult nsStringInputStreamConstructor(nsISupports*, REFNSIID, void**); #include "nsWindowsRegKey.h" #endif -#ifdef MOZ_WIDGET_COCOA -#include "nsMacUtilsImpl.h" -#endif - #include "nsSystemInfo.h" #include "nsMemoryReporterManager.h" #include "nsMemoryInfoDumper.h" @@ -237,10 +233,6 @@ NS_GENERIC_AGGREGATED_CONSTRUCTOR(nsProperties) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUUIDGenerator, Init) -#ifdef MOZ_WIDGET_COCOA -NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacUtilsImpl) -#endif - NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSystemInfo, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsMemoryReporterManager, Init) diff --git a/xpcom/build/XPCOMModule.inc b/xpcom/build/XPCOMModule.inc index 5ac2885e2..d5fdc6ae9 100644 --- a/xpcom/build/XPCOMModule.inc +++ b/xpcom/build/XPCOMModule.inc @@ -68,10 +68,6 @@ COMPONENT(WINDOWSREGKEY, nsWindowsRegKeyConstructor) #endif -#if defined(MOZ_WIDGET_COCOA) - COMPONENT(MACUTILSIMPL, nsMacUtilsImplConstructor) -#endif - COMPONENT(SYSTEMINFO, nsSystemInfoConstructor) COMPONENT(MEMORY_REPORTER_MANAGER, nsMemoryReporterManagerConstructor) COMPONENT(MEMORY_INFO_DUMPER, nsMemoryInfoDumperConstructor) diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp index e3b0b0f3c..8d94a1545 100644 --- a/xpcom/components/ManifestParser.cpp +++ b/xpcom/components/ManifestParser.cpp @@ -13,9 +13,6 @@ #include "prprf.h" #if defined(XP_WIN) #include <windows.h> -#elif defined(MOZ_WIDGET_COCOA) -#include <CoreServices/CoreServices.h> -#include "nsCocoaFeatures.h" #elif defined(MOZ_WIDGET_GTK) #include <gtk/gtk.h> #endif diff --git a/xpcom/io/SpecialSystemDirectory.cpp b/xpcom/io/SpecialSystemDirectory.cpp index 4efd8b7af..176ac5e4b 100644 --- a/xpcom/io/SpecialSystemDirectory.cpp +++ b/xpcom/io/SpecialSystemDirectory.cpp @@ -26,9 +26,6 @@ #include <stdlib.h> #include <sys/param.h> #include "prenv.h" -#if defined(MOZ_WIDGET_COCOA) -#include "CocoaFileUtils.h" -#endif #endif @@ -487,11 +484,6 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory, true, aFile); } -#elif defined(MOZ_WIDGET_COCOA) - { - return GetOSXFolderType(kUserDomain, kTemporaryFolderType, aFile); - } - #elif defined(XP_UNIX) { static const char* tPath = nullptr; @@ -750,34 +742,3 @@ GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory, } return NS_ERROR_NOT_AVAILABLE; } - -#if defined (MOZ_WIDGET_COCOA) -nsresult -GetOSXFolderType(short aDomain, OSType aFolderType, nsIFile** aLocalFile) -{ - nsresult rv = NS_ERROR_FAILURE; - - if (aFolderType == kTemporaryFolderType) { - NS_NewLocalFile(EmptyString(), true, aLocalFile); - nsCOMPtr<nsILocalFileMac> localMacFile(do_QueryInterface(*aLocalFile)); - if (localMacFile) { - rv = localMacFile->InitWithCFURL( - CocoaFileUtils::GetTemporaryFolderCFURLRef()); - } - return rv; - } - - OSErr err; - FSRef fsRef; - err = ::FSFindFolder(aDomain, aFolderType, kCreateFolder, &fsRef); - if (err == noErr) { - NS_NewLocalFile(EmptyString(), true, aLocalFile); - nsCOMPtr<nsILocalFileMac> localMacFile(do_QueryInterface(*aLocalFile)); - if (localMacFile) { - rv = localMacFile->InitWithFSRef(&fsRef); - } - } - return rv; -} -#endif - diff --git a/xpcom/io/SpecialSystemDirectory.h b/xpcom/io/SpecialSystemDirectory.h index 46bceeff1..f75c72501 100644 --- a/xpcom/io/SpecialSystemDirectory.h +++ b/xpcom/io/SpecialSystemDirectory.h @@ -9,12 +9,6 @@ #include "nscore.h" #include "nsIFile.h" -#ifdef MOZ_WIDGET_COCOA -#include <Carbon/Carbon.h> -#include "nsILocalFileMac.h" -#include "prenv.h" -#endif - enum SystemDirectories { OS_DriveDirectory = 1, OS_TemporaryDirectory = 2, @@ -92,9 +86,4 @@ enum SystemDirectories { nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory, nsIFile** aFile); -#ifdef MOZ_WIDGET_COCOA -nsresult -GetOSXFolderType(short aDomain, OSType aFolderType, nsIFile** aLocalFile); -#endif - #endif diff --git a/xpcom/io/nsAppFileLocationProvider.cpp b/xpcom/io/nsAppFileLocationProvider.cpp index d5569985c..5dd84fd1b 100644 --- a/xpcom/io/nsAppFileLocationProvider.cpp +++ b/xpcom/io/nsAppFileLocationProvider.cpp @@ -15,10 +15,7 @@ #include "prenv.h" #include "nsCRT.h" -#if defined(MOZ_WIDGET_COCOA) -#include <Carbon/Carbon.h> -#include "nsILocalFileMac.h" -#elif defined(XP_WIN) +#if defined(XP_WIN) #include <windows.h> #include <shlobj.h> #elif defined(XP_UNIX) @@ -31,10 +28,7 @@ // WARNING: These hard coded names need to go away. They need to // come from localizable resources -#if defined(MOZ_WIDGET_COCOA) -#define APP_REGISTRY_NAME NS_LITERAL_CSTRING("Application Registry") -#define ESSENTIAL_FILES NS_LITERAL_CSTRING("Essential Files") -#elif defined(XP_WIN) +#if defined(XP_WIN) #define APP_REGISTRY_NAME NS_LITERAL_CSTRING("registry.dat") #else #define APP_REGISTRY_NAME NS_LITERAL_CSTRING("appreg") @@ -47,11 +41,7 @@ #define NS_ENV_PLUGINS_DIR "EnvPlugins" // env var MOZ_PLUGIN_PATH #define NS_USER_PLUGINS_DIR "UserPlugins" -#ifdef MOZ_WIDGET_COCOA -#define NS_MACOSX_USER_PLUGIN_DIR "OSXUserPlugins" -#define NS_MACOSX_LOCAL_PLUGIN_DIR "OSXLocalPlugins" -#define NS_MACOSX_JAVA2_PLUGIN_DIR "OSXJavaPlugins" -#elif XP_UNIX +#if XP_UNIX #define NS_SYSTEM_PLUGINS_DIR "SysPlugins" #endif @@ -96,11 +86,6 @@ nsAppFileLocationProvider::GetFile(const char* aProp, bool* aPersistent, *aResult = nullptr; *aPersistent = true; -#ifdef MOZ_WIDGET_COCOA - FSRef fileRef; - nsCOMPtr<nsILocalFileMac> macFile; -#endif - if (nsCRT::strcmp(aProp, NS_APP_APPLICATION_REGISTRY_DIR) == 0) { rv = GetProductDirectory(getter_AddRefs(localFile)); } else if (nsCRT::strcmp(aProp, NS_APP_APPLICATION_REGISTRY_FILE) == 0) { @@ -141,30 +126,6 @@ nsAppFileLocationProvider::GetFile(const char* aProp, bool* aPersistent, rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME); } } -#ifdef MOZ_WIDGET_COCOA - else if (nsCRT::strcmp(aProp, NS_MACOSX_USER_PLUGIN_DIR) == 0) { - if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false, - &fileRef) == noErr) { - rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile)); - if (NS_SUCCEEDED(rv)) { - localFile = macFile; - } - } - } else if (nsCRT::strcmp(aProp, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0) { - if (::FSFindFolder(kLocalDomain, kInternetPlugInFolderType, false, - &fileRef) == noErr) { - rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile)); - if (NS_SUCCEEDED(rv)) { - localFile = macFile; - } - } - } else if (nsCRT::strcmp(aProp, NS_MACOSX_JAVA2_PLUGIN_DIR) == 0) { - static const char* const java2PluginDirPath = - "/System/Library/Java/Support/Deploy.bundle/Contents/Resources/"; - rv = NS_NewNativeLocalFile(nsDependentCString(java2PluginDirPath), true, - getter_AddRefs(localFile)); - } -#else else if (nsCRT::strcmp(aProp, NS_ENV_PLUGINS_DIR) == 0) { NS_ERROR("Don't use nsAppFileLocationProvider::GetFile(NS_ENV_PLUGINS_DIR, ...). " "Use nsAppFileLocationProvider::GetFiles(...)."); @@ -200,7 +161,6 @@ nsAppFileLocationProvider::GetFile(const char* aProp, bool* aPersistent, #endif } #endif -#endif else if (nsCRT::strcmp(aProp, NS_APP_SEARCH_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { @@ -286,24 +246,7 @@ nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile, bool exists; nsCOMPtr<nsIFile> localDir; -#if defined(MOZ_WIDGET_COCOA) - FSRef fsRef; - OSType folderType = aLocal ? (OSType)kCachedDataFolderType : - (OSType)kDomainLibraryFolderType; - OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef); - if (err) { - return NS_ERROR_FAILURE; - } - NS_NewLocalFile(EmptyString(), true, getter_AddRefs(localDir)); - if (!localDir) { - return NS_ERROR_FAILURE; - } - nsCOMPtr<nsILocalFileMac> localDirMac(do_QueryInterface(localDir)); - rv = localDirMac->InitWithFSRef(&fsRef); - if (NS_FAILED(rv)) { - return rv; - } -#elif defined(XP_WIN) +#if defined(XP_WIN) nsCOMPtr<nsIProperties> directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) { @@ -367,7 +310,7 @@ nsAppFileLocationProvider::GetDefaultUserProfileRoot(nsIFile** aLocalFile, return rv; } -#if defined(MOZ_WIDGET_COCOA) || defined(XP_WIN) +#if defined(XP_WIN) // These 3 platforms share this part of the path - do them as one rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("Profiles")); if (NS_FAILED(rv)) { @@ -541,23 +484,6 @@ nsAppFileLocationProvider::GetFiles(const char* aProp, nsresult rv = NS_ERROR_FAILURE; if (!nsCRT::strcmp(aProp, NS_APP_PLUGINS_DIR_LIST)) { -#ifdef MOZ_WIDGET_COCOA - // As of Java for Mac OS X 10.5 Update 10, Apple has (in effect) deprecated Java Plugin2 on - // on OS X 10.5, and removed the soft link to it from /Library/Internet Plug-Ins/. Java - // Plugin2 is still present and usable, but there are no longer any links to it in the - // "normal" locations. So we won't be able to find it unless we look in the "non-normal" - // location where it actually is. Safari can use the WebKit-specific JavaPluginCocoa.bundle, - // which (of course) is still fully supported on OS X 10.5. But we have no alternative to - // using Java Plugin2. For more information see bug 668639. - static const char* keys[] = { - NS_APP_PLUGINS_DIR, - NS_MACOSX_USER_PLUGIN_DIR, - NS_MACOSX_LOCAL_PLUGIN_DIR, - IsOSXLeopard() ? NS_MACOSX_JAVA2_PLUGIN_DIR : nullptr, - nullptr - }; - *aResult = new nsAppDirectoryEnumerator(this, keys); -#else #ifdef XP_UNIX static const char* keys[] = { nullptr, NS_USER_PLUGINS_DIR, NS_APP_PLUGINS_DIR, NS_SYSTEM_PLUGINS_DIR, nullptr }; #else @@ -568,7 +494,6 @@ nsAppFileLocationProvider::GetFiles(const char* aProp, keys[0] = &nullstr; } *aResult = new nsPathsDirectoryEnumerator(this, keys); -#endif NS_ADDREF(*aResult); rv = NS_OK; } @@ -587,22 +512,3 @@ nsAppFileLocationProvider::GetFiles(const char* aProp, } return rv; } - -#if defined(MOZ_WIDGET_COCOA) -bool -nsAppFileLocationProvider::IsOSXLeopard() -{ - static SInt32 version = 0; - - if (!version) { - OSErr err = ::Gestalt(gestaltSystemVersion, &version); - if (err != noErr) { - version = 0; - } else { - version &= 0xFFFF; // The system version is in the low order word - } - } - - return ((version >= 0x1050) && (version < 0x1060)); -} -#endif diff --git a/xpcom/io/nsAppFileLocationProvider.h b/xpcom/io/nsAppFileLocationProvider.h index 03e03c863..b2f73f62e 100644 --- a/xpcom/io/nsAppFileLocationProvider.h +++ b/xpcom/io/nsAppFileLocationProvider.h @@ -44,10 +44,6 @@ protected: nsresult GetDefaultUserProfileRoot(nsIFile** aLocalFile, bool aLocal = false); -#if defined(MOZ_WIDGET_COCOA) - static bool IsOSXLeopard(); -#endif - nsCOMPtr<nsIFile> mMozBinDirectory; }; diff --git a/xpcom/io/nsDirectoryService.cpp b/xpcom/io/nsDirectoryService.cpp index dae852148..f49f1f40c 100644 --- a/xpcom/io/nsDirectoryService.cpp +++ b/xpcom/io/nsDirectoryService.cpp @@ -28,10 +28,6 @@ #include <stdlib.h> #include <sys/param.h> #include "prenv.h" -#ifdef MOZ_WIDGET_COCOA -#include <CoreServices/CoreServices.h> -#include <Carbon/Carbon.h> -#endif #endif #include "SpecialSystemDirectory.h" @@ -43,8 +39,6 @@ using namespace mozilla; // For Windows platform, We are choosing Appdata folder as HOME #if defined (XP_WIN) #define HOME_DIR NS_WIN_APPDATA_DIR -#elif defined (MOZ_WIDGET_COCOA) -#define HOME_DIR NS_OSX_HOME_DIR #elif defined (XP_UNIX) #define HOME_DIR NS_UNIX_HOME_DIR #endif @@ -102,40 +96,6 @@ nsDirectoryService::GetCurrentProcessDirectory(nsIFile** aFile) return NS_OK; } -#elif defined(MOZ_WIDGET_COCOA) - // Works even if we're not bundled. - CFBundleRef appBundle = CFBundleGetMainBundle(); - if (appBundle) { - CFURLRef bundleURL = CFBundleCopyExecutableURL(appBundle); - if (bundleURL) { - CFURLRef parentURL = CFURLCreateCopyDeletingLastPathComponent( - kCFAllocatorDefault, bundleURL); - if (parentURL) { - // Pass true for the "resolveAgainstBase" arg to CFURLGetFileSystemRepresentation. - // This will resolve the relative portion of the CFURL against it base, giving a full - // path, which CFURLCopyFileSystemPath doesn't do. - char buffer[PATH_MAX]; - if (CFURLGetFileSystemRepresentation(parentURL, true, - (UInt8*)buffer, sizeof(buffer))) { -#ifdef DEBUG_conrad - printf("nsDirectoryService - CurrentProcessDir is: %s\n", buffer); -#endif - rv = localFile->InitWithNativePath(nsDependentCString(buffer)); - if (NS_SUCCEEDED(rv)) { - localFile.forget(aFile); - } - } - CFRelease(parentURL); - } - CFRelease(bundleURL); - } - } - - NS_ASSERTION(*aFile, "nsDirectoryService - Could not determine CurrentProcessDir.\n"); - if (*aFile) { - return NS_OK; - } - #elif defined(XP_UNIX) // In the absence of a good way to get the executable directory let @@ -528,83 +488,7 @@ nsDirectoryService::GetFile(const char* aProp, bool* aPersistent, rv = GetSpecialSystemDirectory(OS_CurrentWorkingDirectory, getter_AddRefs(localFile)); } -#if defined(MOZ_WIDGET_COCOA) - else if (inAtom == nsDirectoryService::sDirectory) { - rv = GetOSXFolderType(kClassicDomain, kSystemFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sTrashDirectory) { - rv = GetOSXFolderType(kClassicDomain, kTrashFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sStartupDirectory) { - rv = GetOSXFolderType(kClassicDomain, kStartupFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sShutdownDirectory) { - rv = GetOSXFolderType(kClassicDomain, kShutdownFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sAppleMenuDirectory) { - rv = GetOSXFolderType(kClassicDomain, kAppleMenuFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sControlPanelDirectory) { - rv = GetOSXFolderType(kClassicDomain, kControlPanelFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sExtensionDirectory) { - rv = GetOSXFolderType(kClassicDomain, kExtensionFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sFontsDirectory) { - rv = GetOSXFolderType(kClassicDomain, kFontsFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sPreferencesDirectory) { - rv = GetOSXFolderType(kClassicDomain, kPreferencesFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sDocumentsDirectory) { - rv = GetOSXFolderType(kClassicDomain, kDocumentsFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sInternetSearchDirectory) { - rv = GetOSXFolderType(kClassicDomain, kInternetSearchSitesFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sUserLibDirectory) { - rv = GetOSXFolderType(kUserDomain, kDomainLibraryFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sOS_HomeDirectory) { - rv = GetOSXFolderType(kUserDomain, kDomainTopLevelFolderType, getter_AddRefs(localFile)); - } else if (inAtom == nsDirectoryService::sDefaultDownloadDirectory) { - // 10.5 and later, we can use kDownloadsFolderType which is defined in - // Folders.h as "down". However, in order to support 10.4 still, we - // cannot use the named constant. We'll use it's value, and if it - // fails, fall back to the desktop. -#ifndef kDownloadsFolderType -#define kDownloadsFolderType 'down' -#endif - - rv = GetOSXFolderType(kUserDomain, kDownloadsFolderType, - getter_AddRefs(localFile)); - if (NS_FAILED(rv)) { - rv = GetOSXFolderType(kUserDomain, kDesktopFolderType, - getter_AddRefs(localFile)); - } - } else if (inAtom == nsDirectoryService::sUserDesktopDirectory || - inAtom == nsDirectoryService::sOS_DesktopDirectory) { - 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) +#if defined (XP_WIN) else if (inAtom == nsDirectoryService::sSystemDirectory) { rv = GetSpecialSystemDirectory(Win_SystemDirectory, getter_AddRefs(localFile)); } else if (inAtom == nsDirectoryService::sWindowsDirectory) { diff --git a/xpcom/io/nsDirectoryServiceAtomList.h b/xpcom/io/nsDirectoryServiceAtomList.h index 8a574cb69..7030e55b0 100644 --- a/xpcom/io/nsDirectoryServiceAtomList.h +++ b/xpcom/io/nsDirectoryServiceAtomList.h @@ -13,37 +13,7 @@ DIR_ATOM(sOS_CurrentWorkingDirectory, NS_OS_CURRENT_WORKING_DIR) DIR_ATOM(sOS_HomeDirectory, NS_OS_HOME_DIR) DIR_ATOM(sOS_DesktopDirectory, NS_OS_DESKTOP_DIR) DIR_ATOM(sInitCurrentProcess_dummy, NS_XPCOM_INIT_CURRENT_PROCESS_DIR) -#if defined (MOZ_WIDGET_COCOA) -DIR_ATOM(sDirectory, NS_OS_SYSTEM_DIR) -DIR_ATOM(sTrashDirectory, NS_MAC_TRASH_DIR) -DIR_ATOM(sStartupDirectory, NS_MAC_STARTUP_DIR) -DIR_ATOM(sShutdownDirectory, NS_MAC_SHUTDOWN_DIR) -DIR_ATOM(sAppleMenuDirectory, NS_MAC_APPLE_MENU_DIR) -DIR_ATOM(sControlPanelDirectory, NS_MAC_CONTROL_PANELS_DIR) -DIR_ATOM(sExtensionDirectory, NS_MAC_EXTENSIONS_DIR) -DIR_ATOM(sFontsDirectory, NS_MAC_FONTS_DIR) -DIR_ATOM(sPreferencesDirectory, NS_MAC_PREFS_DIR) -DIR_ATOM(sDocumentsDirectory, NS_MAC_DOCUMENTS_DIR) -DIR_ATOM(sInternetSearchDirectory, NS_MAC_INTERNET_SEARCH_DIR) -DIR_ATOM(sUserLibDirectory, NS_MAC_USER_LIB_DIR) -DIR_ATOM(sDefaultDownloadDirectory, NS_OSX_DEFAULT_DOWNLOAD_DIR) -DIR_ATOM(sUserDesktopDirectory, NS_OSX_USER_DESKTOP_DIR) -DIR_ATOM(sLocalDesktopDirectory, NS_OSX_LOCAL_DESKTOP_DIR) -DIR_ATOM(sUserApplicationsDirectory, NS_OSX_USER_APPLICATIONS_DIR) -DIR_ATOM(sLocalApplicationsDirectory, NS_OSX_LOCAL_APPLICATIONS_DIR) -DIR_ATOM(sUserDocumentsDirectory, NS_OSX_USER_DOCUMENTS_DIR) -DIR_ATOM(sLocalDocumentsDirectory, NS_OSX_LOCAL_DOCUMENTS_DIR) -DIR_ATOM(sUserInternetPlugInDirectory, NS_OSX_USER_INTERNET_PLUGIN_DIR) -DIR_ATOM(sLocalInternetPlugInDirectory, NS_OSX_LOCAL_INTERNET_PLUGIN_DIR) -DIR_ATOM(sUserFrameworksDirectory, NS_OSX_USER_FRAMEWORKS_DIR) -DIR_ATOM(sLocalFrameworksDirectory, NS_OSX_LOCAL_FRAMEWORKS_DIR) -DIR_ATOM(sUserPreferencesDirectory, NS_OSX_USER_PREFERENCES_DIR) -DIR_ATOM(sLocalPreferencesDirectory, NS_OSX_LOCAL_PREFERENCES_DIR) -DIR_ATOM(sPictureDocumentsDirectory, NS_OSX_PICTURE_DOCUMENTS_DIR) -DIR_ATOM(sMovieDocumentsDirectory, NS_OSX_MOVIE_DOCUMENTS_DIR) -DIR_ATOM(sMusicDocumentsDirectory, NS_OSX_MUSIC_DOCUMENTS_DIR) -DIR_ATOM(sInternetSitesDirectory, NS_OSX_INTERNET_SITES_DIR) -#elif defined (XP_WIN) +#if defined (XP_WIN) DIR_ATOM(sSystemDirectory, NS_OS_SYSTEM_DIR) DIR_ATOM(sWindowsDirectory, NS_WIN_WINDOWS_DIR) DIR_ATOM(sWindowsProgramFiles, NS_WIN_PROGRAM_FILES_DIR) diff --git a/xpcom/io/nsDirectoryServiceDefs.h b/xpcom/io/nsDirectoryServiceDefs.h index b7fab619c..fbf300e4f 100644 --- a/xpcom/io/nsDirectoryServiceDefs.h +++ b/xpcom/io/nsDirectoryServiceDefs.h @@ -62,44 +62,11 @@ /* Platform Specific Locations */ -#if !defined (XP_UNIX) || defined(MOZ_WIDGET_COCOA) +#if !defined (XP_UNIX) #define NS_OS_SYSTEM_DIR "SysD" #endif -#if defined (MOZ_WIDGET_COCOA) - #define NS_MAC_DESKTOP_DIR NS_OS_DESKTOP_DIR - #define NS_MAC_TRASH_DIR "Trsh" - #define NS_MAC_STARTUP_DIR "Strt" - #define NS_MAC_SHUTDOWN_DIR "Shdwn" - #define NS_MAC_APPLE_MENU_DIR "ApplMenu" - #define NS_MAC_CONTROL_PANELS_DIR "CntlPnl" - #define NS_MAC_EXTENSIONS_DIR "Exts" - #define NS_MAC_FONTS_DIR "Fnts" - #define NS_MAC_PREFS_DIR "Prfs" - #define NS_MAC_DOCUMENTS_DIR "Docs" - #define NS_MAC_INTERNET_SEARCH_DIR "ISrch" - #define NS_OSX_HOME_DIR NS_OS_HOME_DIR - #define NS_MAC_HOME_DIR NS_OS_HOME_DIR - #define NS_MAC_DEFAULT_DOWNLOAD_DIR "DfltDwnld" - #define NS_MAC_USER_LIB_DIR "ULibDir" // Only available under OS X - #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) +#if defined (XP_WIN) #define NS_WIN_WINDOWS_DIR "WinD" #define NS_WIN_PROGRAM_FILES_DIR "ProgF" #define NS_WIN_HOME_DIR NS_OS_HOME_DIR diff --git a/xpcom/io/nsLocalFileCommon.cpp b/xpcom/io/nsLocalFileCommon.cpp index f3c3aed8a..a6d4a116e 100644 --- a/xpcom/io/nsLocalFileCommon.cpp +++ b/xpcom/io/nsLocalFileCommon.cpp @@ -32,7 +32,7 @@ NS_ShutdownLocalFile() nsLocalFile::GlobalShutdown(); } -#if !defined(MOZ_WIDGET_COCOA) && !defined(XP_WIN) +#if !defined(XP_WIN) NS_IMETHODIMP nsLocalFile::InitWithFile(nsIFile* aFile) { diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index 8aa5ae433..67aab9089 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -52,15 +52,6 @@ #include "nsIGIOService.h" #endif -#ifdef MOZ_WIDGET_COCOA -#include <Carbon/Carbon.h> -#include "CocoaFileUtils.h" -#include "prmem.h" -#include "plbase64.h" - -static nsresult MacErrorMapper(OSErr inErr); -#endif - #ifdef MOZ_ENABLE_CONTENTACTION #include <contentaction/contentaction.h> #endif @@ -229,18 +220,10 @@ nsLocalFile::nsLocalFile(const nsLocalFile& aOther) { } -#ifdef MOZ_WIDGET_COCOA NS_IMPL_ISUPPORTS(nsLocalFile, - nsILocalFileMac, nsILocalFile, nsIFile, nsIHashable) -#else -NS_IMPL_ISUPPORTS(nsLocalFile, - nsILocalFile, - nsIFile, - nsIHashable) -#endif nsresult nsLocalFile::nsLocalFileConstructor(nsISupports* aOuter, @@ -1529,28 +1512,6 @@ nsLocalFile::IsExecutable(bool* aResult) } } - // On OS X, then query Launch Services. -#ifdef MOZ_WIDGET_COCOA - // Certain Mac applications, such as Classic applications, which - // run under Rosetta, might not have the +x mode bit but are still - // considered to be executable by Launch Services (bug 646748). - CFURLRef url; - if (NS_FAILED(GetCFURL(&url))) { - return NS_ERROR_FAILURE; - } - - LSRequestedInfo theInfoRequest = kLSRequestAllInfo; - LSItemInfoRecord theInfo; - OSStatus result = ::LSCopyItemInfoForURL(url, theInfoRequest, &theInfo); - ::CFRelease(url); - if (result == noErr) { - if ((theInfo.flags & kLSItemInfoIsApplication) != 0) { - *aResult = true; - return NS_OK; - } - } -#endif - // Then check the execute bit. *aResult = (access(mPath.get(), X_OK) == 0); #ifdef XP_SOLARIS @@ -1852,63 +1813,7 @@ nsLocalFile::GetPersistentDescriptor(nsACString& aPersistentDescriptor) NS_IMETHODIMP nsLocalFile::SetPersistentDescriptor(const nsACString& aPersistentDescriptor) { -#ifdef MOZ_WIDGET_COCOA - if (aPersistentDescriptor.IsEmpty()) { - return NS_ERROR_INVALID_ARG; - } - - // Support pathnames as user-supplied descriptors if they begin with '/' - // or '~'. These characters do not collide with the base64 set used for - // encoding alias records. - char first = aPersistentDescriptor.First(); - if (first == '/' || first == '~') { - return InitWithNativePath(aPersistentDescriptor); - } - - uint32_t dataSize = aPersistentDescriptor.Length(); - char* decodedData = PL_Base64Decode( - PromiseFlatCString(aPersistentDescriptor).get(), dataSize, nullptr); - if (!decodedData) { - NS_ERROR("SetPersistentDescriptor was given bad data"); - return NS_ERROR_FAILURE; - } - - // Cast to an alias record and resolve. - AliasRecord aliasHeader = *(AliasPtr)decodedData; - int32_t aliasSize = ::GetAliasSizeFromPtr(&aliasHeader); - if (aliasSize > ((int32_t)dataSize * 3) / 4) { // be paranoid about having too few data - PR_Free(decodedData); - return NS_ERROR_FAILURE; - } - - nsresult rv = NS_OK; - - // Move the now-decoded data into the Handle. - // The size of the decoded data is 3/4 the size of the encoded data. See plbase64.h - Handle newHandle = nullptr; - if (::PtrToHand(decodedData, &newHandle, aliasSize) != noErr) { - rv = NS_ERROR_OUT_OF_MEMORY; - } - PR_Free(decodedData); - if (NS_FAILED(rv)) { - return rv; - } - - Boolean changed; - FSRef resolvedFSRef; - OSErr err = ::FSResolveAlias(nullptr, (AliasHandle)newHandle, &resolvedFSRef, - &changed); - - rv = MacErrorMapper(err); - DisposeHandle(newHandle); - if (NS_FAILED(rv)) { - return rv; - } - - return InitWithFSRef(&resolvedFSRef); -#else return InitWithNativePath(aPersistentDescriptor); -#endif } NS_IMETHODIMP @@ -1941,14 +1846,6 @@ nsLocalFile::Reveal() return giovfs->ShowURIForInput(dirPath); } -#elif defined(MOZ_WIDGET_COCOA) - CFURLRef url; - if (NS_SUCCEEDED(GetCFURL(&url))) { - nsresult rv = CocoaFileUtils::RevealFileInFinder(url); - ::CFRelease(url); - return rv; - } - return NS_ERROR_FAILURE; #else return NS_ERROR_FAILURE; #endif @@ -1975,14 +1872,6 @@ nsLocalFile::Launch() } return NS_ERROR_FAILURE; -#elif defined(MOZ_WIDGET_COCOA) - CFURLRef url; - if (NS_SUCCEEDED(GetCFURL(&url))) { - nsresult rv = CocoaFileUtils::OpenURL(url); - ::CFRelease(url); - return rv; - } - return NS_ERROR_FAILURE; #else return NS_ERROR_FAILURE; #endif @@ -2168,493 +2057,3 @@ void nsLocalFile::GlobalShutdown() { } - -// nsILocalFileMac - -#ifdef MOZ_WIDGET_COCOA - -static nsresult MacErrorMapper(OSErr inErr) -{ - nsresult outErr; - - switch (inErr) { - case noErr: - outErr = NS_OK; - break; - - case fnfErr: - case afpObjectNotFound: - case afpDirNotFound: - outErr = NS_ERROR_FILE_NOT_FOUND; - break; - - case dupFNErr: - case afpObjectExists: - outErr = NS_ERROR_FILE_ALREADY_EXISTS; - break; - - case dskFulErr: - case afpDiskFull: - outErr = NS_ERROR_FILE_DISK_FULL; - break; - - case fLckdErr: - case afpVolLocked: - outErr = NS_ERROR_FILE_IS_LOCKED; - break; - - case afpAccessDenied: - outErr = NS_ERROR_FILE_ACCESS_DENIED; - break; - - case afpDirNotEmpty: - outErr = NS_ERROR_FILE_DIR_NOT_EMPTY; - break; - - // Can't find good map for some - case bdNamErr: - outErr = NS_ERROR_FAILURE; - break; - - default: - outErr = NS_ERROR_FAILURE; - break; - } - - return outErr; -} - -static nsresult CFStringReftoUTF8(CFStringRef aInStrRef, nsACString& aOutStr) -{ - // first see if the conversion would succeed and find the length of the result - CFIndex usedBufLen, inStrLen = ::CFStringGetLength(aInStrRef); - CFIndex charsConverted = ::CFStringGetBytes(aInStrRef, CFRangeMake(0, inStrLen), - kCFStringEncodingUTF8, 0, false, - nullptr, 0, &usedBufLen); - if (charsConverted == inStrLen) { - // all characters converted, do the actual conversion - aOutStr.SetLength(usedBufLen); - if (aOutStr.Length() != (unsigned int)usedBufLen) { - return NS_ERROR_OUT_OF_MEMORY; - } - UInt8* buffer = (UInt8*)aOutStr.BeginWriting(); - ::CFStringGetBytes(aInStrRef, CFRangeMake(0, inStrLen), kCFStringEncodingUTF8, - 0, false, buffer, usedBufLen, &usedBufLen); - return NS_OK; - } - - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsLocalFile::InitWithCFURL(CFURLRef aCFURL) -{ - UInt8 path[PATH_MAX]; - if (::CFURLGetFileSystemRepresentation(aCFURL, true, path, PATH_MAX)) { - nsDependentCString nativePath((char*)path); - return InitWithNativePath(nativePath); - } - - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsLocalFile::InitWithFSRef(const FSRef* aFSRef) -{ - if (NS_WARN_IF(!aFSRef)) { - return NS_ERROR_INVALID_ARG; - } - - CFURLRef newURLRef = ::CFURLCreateFromFSRef(kCFAllocatorDefault, aFSRef); - if (newURLRef) { - nsresult rv = InitWithCFURL(newURLRef); - ::CFRelease(newURLRef); - return rv; - } - - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsLocalFile::GetCFURL(CFURLRef* aResult) -{ - CHECK_mPath(); - - bool isDir; - IsDirectory(&isDir); - *aResult = ::CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, - (UInt8*)mPath.get(), - mPath.Length(), - isDir); - - return (*aResult ? NS_OK : NS_ERROR_FAILURE); -} - -NS_IMETHODIMP -nsLocalFile::GetFSRef(FSRef* aResult) -{ - if (NS_WARN_IF(!aResult)) { - return NS_ERROR_INVALID_ARG; - } - - nsresult rv = NS_ERROR_FAILURE; - - CFURLRef url = nullptr; - if (NS_SUCCEEDED(GetCFURL(&url))) { - if (::CFURLGetFSRef(url, aResult)) { - rv = NS_OK; - } - ::CFRelease(url); - } - - return rv; -} - -NS_IMETHODIMP -nsLocalFile::GetFSSpec(FSSpec* aResult) -{ - if (NS_WARN_IF(!aResult)) { - return NS_ERROR_INVALID_ARG; - } - - FSRef fsRef; - nsresult rv = GetFSRef(&fsRef); - if (NS_SUCCEEDED(rv)) { - OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoNone, nullptr, nullptr, - aResult, nullptr); - return MacErrorMapper(err); - } - - return rv; -} - -NS_IMETHODIMP -nsLocalFile::GetFileSizeWithResFork(int64_t* aFileSizeWithResFork) -{ - if (NS_WARN_IF(!aFileSizeWithResFork)) { - return NS_ERROR_INVALID_ARG; - } - - FSRef fsRef; - nsresult rv = GetFSRef(&fsRef); - if (NS_FAILED(rv)) { - return rv; - } - - FSCatalogInfo catalogInfo; - OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoDataSizes + kFSCatInfoRsrcSizes, - &catalogInfo, nullptr, nullptr, nullptr); - if (err != noErr) { - return MacErrorMapper(err); - } - - *aFileSizeWithResFork = - catalogInfo.dataLogicalSize + catalogInfo.rsrcLogicalSize; - return NS_OK; -} - -NS_IMETHODIMP -nsLocalFile::GetFileType(OSType* aFileType) -{ - CFURLRef url; - if (NS_SUCCEEDED(GetCFURL(&url))) { - nsresult rv = CocoaFileUtils::GetFileTypeCode(url, aFileType); - ::CFRelease(url); - return rv; - } - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsLocalFile::SetFileType(OSType aFileType) -{ - CFURLRef url; - if (NS_SUCCEEDED(GetCFURL(&url))) { - nsresult rv = CocoaFileUtils::SetFileTypeCode(url, aFileType); - ::CFRelease(url); - return rv; - } - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsLocalFile::GetFileCreator(OSType* aFileCreator) -{ - CFURLRef url; - if (NS_SUCCEEDED(GetCFURL(&url))) { - nsresult rv = CocoaFileUtils::GetFileCreatorCode(url, aFileCreator); - ::CFRelease(url); - return rv; - } - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsLocalFile::SetFileCreator(OSType aFileCreator) -{ - CFURLRef url; - if (NS_SUCCEEDED(GetCFURL(&url))) { - nsresult rv = CocoaFileUtils::SetFileCreatorCode(url, aFileCreator); - ::CFRelease(url); - return rv; - } - return NS_ERROR_FAILURE; -} - -NS_IMETHODIMP -nsLocalFile::LaunchWithDoc(nsIFile* aDocToLoad, bool aLaunchInBackground) -{ - bool isExecutable; - nsresult rv = IsExecutable(&isExecutable); - if (NS_FAILED(rv)) { - return rv; - } - if (!isExecutable) { - return NS_ERROR_FILE_EXECUTION_FAILED; - } - - FSRef appFSRef, docFSRef; - rv = GetFSRef(&appFSRef); - if (NS_FAILED(rv)) { - return rv; - } - - if (aDocToLoad) { - nsCOMPtr<nsILocalFileMac> macDoc = do_QueryInterface(aDocToLoad); - rv = macDoc->GetFSRef(&docFSRef); - if (NS_FAILED(rv)) { - return rv; - } - } - - LSLaunchFlags theLaunchFlags = kLSLaunchDefaults; - LSLaunchFSRefSpec thelaunchSpec; - - if (aLaunchInBackground) { - theLaunchFlags |= kLSLaunchDontSwitch; - } - memset(&thelaunchSpec, 0, sizeof(LSLaunchFSRefSpec)); - - thelaunchSpec.appRef = &appFSRef; - if (aDocToLoad) { - thelaunchSpec.numDocs = 1; - thelaunchSpec.itemRefs = &docFSRef; - } - thelaunchSpec.launchFlags = theLaunchFlags; - - OSErr err = ::LSOpenFromRefSpec(&thelaunchSpec, nullptr); - if (err != noErr) { - return MacErrorMapper(err); - } - - return NS_OK; -} - -NS_IMETHODIMP -nsLocalFile::OpenDocWithApp(nsIFile* aAppToOpenWith, bool aLaunchInBackground) -{ - FSRef docFSRef; - nsresult rv = GetFSRef(&docFSRef); - if (NS_FAILED(rv)) { - return rv; - } - - if (!aAppToOpenWith) { - OSErr err = ::LSOpenFSRef(&docFSRef, nullptr); - return MacErrorMapper(err); - } - - nsCOMPtr<nsILocalFileMac> appFileMac = do_QueryInterface(aAppToOpenWith, &rv); - if (!appFileMac) { - return rv; - } - - bool isExecutable; - rv = appFileMac->IsExecutable(&isExecutable); - if (NS_FAILED(rv)) { - return rv; - } - if (!isExecutable) { - return NS_ERROR_FILE_EXECUTION_FAILED; - } - - FSRef appFSRef; - rv = appFileMac->GetFSRef(&appFSRef); - if (NS_FAILED(rv)) { - return rv; - } - - LSLaunchFlags theLaunchFlags = kLSLaunchDefaults; - LSLaunchFSRefSpec thelaunchSpec; - - if (aLaunchInBackground) { - theLaunchFlags |= kLSLaunchDontSwitch; - } - memset(&thelaunchSpec, 0, sizeof(LSLaunchFSRefSpec)); - - thelaunchSpec.appRef = &appFSRef; - thelaunchSpec.numDocs = 1; - thelaunchSpec.itemRefs = &docFSRef; - thelaunchSpec.launchFlags = theLaunchFlags; - - OSErr err = ::LSOpenFromRefSpec(&thelaunchSpec, nullptr); - if (err != noErr) { - return MacErrorMapper(err); - } - - return NS_OK; -} - -NS_IMETHODIMP -nsLocalFile::IsPackage(bool* aResult) -{ - if (NS_WARN_IF(!aResult)) { - return NS_ERROR_INVALID_ARG; - } - *aResult = false; - - CFURLRef url; - nsresult rv = GetCFURL(&url); - if (NS_FAILED(rv)) { - return rv; - } - - LSItemInfoRecord info; - OSStatus status = ::LSCopyItemInfoForURL(url, kLSRequestBasicFlagsOnly, &info); - - ::CFRelease(url); - - if (status != noErr) { - return NS_ERROR_FAILURE; - } - - *aResult = !!(info.flags & kLSItemInfoIsPackage); - - return NS_OK; -} - -NS_IMETHODIMP -nsLocalFile::GetBundleDisplayName(nsAString& aOutBundleName) -{ - bool isPackage = false; - nsresult rv = IsPackage(&isPackage); - if (NS_FAILED(rv) || !isPackage) { - return NS_ERROR_FAILURE; - } - - nsAutoString name; - rv = GetLeafName(name); - if (NS_FAILED(rv)) { - return rv; - } - - int32_t length = name.Length(); - if (Substring(name, length - 4, length).EqualsLiteral(".app")) { - // 4 characters in ".app" - aOutBundleName = Substring(name, 0, length - 4); - } else { - aOutBundleName = name; - } - - return NS_OK; -} - -NS_IMETHODIMP -nsLocalFile::GetBundleIdentifier(nsACString& aOutBundleIdentifier) -{ - nsresult rv = NS_ERROR_FAILURE; - - CFURLRef urlRef; - if (NS_SUCCEEDED(GetCFURL(&urlRef))) { - CFBundleRef bundle = ::CFBundleCreate(nullptr, urlRef); - if (bundle) { - CFStringRef bundleIdentifier = ::CFBundleGetIdentifier(bundle); - if (bundleIdentifier) { - rv = CFStringReftoUTF8(bundleIdentifier, aOutBundleIdentifier); - } - ::CFRelease(bundle); - } - ::CFRelease(urlRef); - } - - return rv; -} - -NS_IMETHODIMP -nsLocalFile::GetBundleContentsLastModifiedTime(int64_t* aLastModTime) -{ - CHECK_mPath(); - if (NS_WARN_IF(!aLastModTime)) { - return NS_ERROR_INVALID_ARG; - } - - bool isPackage = false; - nsresult rv = IsPackage(&isPackage); - if (NS_FAILED(rv) || !isPackage) { - return GetLastModifiedTime(aLastModTime); - } - - nsAutoCString infoPlistPath(mPath); - infoPlistPath.AppendLiteral("/Contents/Info.plist"); - PRFileInfo64 info; - if (PR_GetFileInfo64(infoPlistPath.get(), &info) != PR_SUCCESS) { - return GetLastModifiedTime(aLastModTime); - } - int64_t modTime = int64_t(info.modifyTime); - if (modTime == 0) { - *aLastModTime = 0; - } else { - *aLastModTime = modTime / int64_t(PR_USEC_PER_MSEC); - } - - return NS_OK; -} - -NS_IMETHODIMP nsLocalFile::InitWithFile(nsIFile* aFile) -{ - if (NS_WARN_IF(!aFile)) { - return NS_ERROR_INVALID_ARG; - } - - nsAutoCString nativePath; - nsresult rv = aFile->GetNativePath(nativePath); - if (NS_FAILED(rv)) { - return rv; - } - - return InitWithNativePath(nativePath); -} - -nsresult -NS_NewLocalFileWithFSRef(const FSRef* aFSRef, bool aFollowLinks, - nsILocalFileMac** aResult) -{ - RefPtr<nsLocalFile> file = new nsLocalFile(); - - file->SetFollowLinks(aFollowLinks); - - nsresult rv = file->InitWithFSRef(aFSRef); - if (NS_FAILED(rv)) { - return rv; - } - file.forget(aResult); - return NS_OK; -} - -nsresult -NS_NewLocalFileWithCFURL(const CFURLRef aURL, bool aFollowLinks, - nsILocalFileMac** aResult) -{ - RefPtr<nsLocalFile> file = new nsLocalFile(); - - file->SetFollowLinks(aFollowLinks); - - nsresult rv = file->InitWithCFURL(aURL); - if (NS_FAILED(rv)) { - return rv; - } - file.forget(aResult); - return NS_OK; -} - -#endif diff --git a/xpcom/io/nsLocalFileUnix.h b/xpcom/io/nsLocalFileUnix.h index 5bdc6a3da..c4262dd88 100644 --- a/xpcom/io/nsLocalFileUnix.h +++ b/xpcom/io/nsLocalFileUnix.h @@ -20,9 +20,6 @@ #include "nsIHashable.h" #include "nsIClassInfoImpl.h" #include "mozilla/Attributes.h" -#ifdef MOZ_WIDGET_COCOA -#include "nsILocalFileMac.h" -#endif /** * we need these for statfs() @@ -72,11 +69,7 @@ class nsLocalFile final -#ifdef MOZ_WIDGET_COCOA - : public nsILocalFileMac -#else : public nsILocalFile -#endif , public nsIHashable { public: @@ -91,9 +84,6 @@ public: NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIFILE NS_DECL_NSILOCALFILE -#ifdef MOZ_WIDGET_COCOA - NS_DECL_NSILOCALFILEMAC -#endif NS_DECL_NSIHASHABLE public: |