Bug 1364984 - use non-deprecated API for finding the temporary directory on OS X; r=mstange
☠☠ backed out by 130dc8355e27 ☠ ☠
authorColin Dean <colin.dean@specialiapps.org>
Thu, 01 Jun 2017 16:07:11 -0400
changeset 361908 60752371afbb6a9e0631c55ea09a05c0d767d04b
parent 361907 d0a62851c33d0ca77d986654d1d9aa201eb8852a
child 361909 fedb93c6e6f7355facca060e96ee97f7f46f3f87
push id31948
push userkwierso@gmail.com
push dateFri, 02 Jun 2017 00:27:01 +0000
treeherdermozilla-central@1e229cf8933b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1364984
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1364984 - use non-deprecated API for finding the temporary directory on OS X; r=mstange FSFindFolder is deprecated as of 10.9 and apparently continues to work...except for the case of finding the temporary directory when the user's home directory lives on an NFS mount (!). Using NSTemporaryDirectory does The Right Thing here, so let's use that instead.
xpcom/io/CocoaFileUtils.h
xpcom/io/CocoaFileUtils.mm
xpcom/io/SpecialSystemDirectory.cpp
--- a/xpcom/io/CocoaFileUtils.h
+++ b/xpcom/io/CocoaFileUtils.h
@@ -23,12 +23,13 @@ nsresult GetFileTypeCode(CFURLRef aUrl, 
 nsresult SetFileTypeCode(CFURLRef aUrl, OSType aTypeCode);
 void     AddOriginMetadataToFile(const CFStringRef filePath,
                                  const CFURLRef sourceURL,
                                  const CFURLRef referrerURL);
 void     AddQuarantineMetadataToFile(const CFStringRef filePath,
                                      const CFURLRef sourceURL,
                                      const CFURLRef referrerURL,
                                      const bool isFromWeb);
+CFURLRef GetTemporaryFolderCFURLRef();
 
 } // namespace CocoaFileUtils
 
 #endif
--- a/xpcom/io/CocoaFileUtils.mm
+++ b/xpcom/io/CocoaFileUtils.mm
@@ -252,9 +252,16 @@ void AddQuarantineMetadataToFile(const C
                                    quarantinePropKey,
                                    mutQuarantineProps,
                                    NULL);
 
   ::CFRelease(fileURL);
   ::CFRelease(mutQuarantineProps);
 }
 
+CFURLRef GetTemporaryFolderCFURLRef()
+{
+  NSString* tempDir = ::NSTemporaryDirectory();
+  return tempDir == nil ? NULL : (CFURLRef)[NSURL fileURLWithPath:tempDir
+                                                      isDirectory:YES];
+}
+
 } // namespace CocoaFileUtils
--- a/xpcom/io/SpecialSystemDirectory.cpp
+++ b/xpcom/io/SpecialSystemDirectory.cpp
@@ -22,16 +22,19 @@
 
 #elif defined(XP_UNIX)
 
 #include <limits.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <sys/param.h>
 #include "prenv.h"
+#if defined(MOZ_WIDGET_COCOA)
+#include "CocoaFileUtils.h"
+#endif
 
 #endif
 
 #ifndef MAXPATHLEN
 #ifdef PATH_MAX
 #define MAXPATHLEN PATH_MAX
 #elif defined(MAX_PATH)
 #define MAXPATHLEN MAX_PATH
@@ -761,20 +764,30 @@ GetSpecialSystemDirectory(SystemDirector
   }
   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;
-  nsresult rv = NS_ERROR_FAILURE;
-
   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);
     }
   }