Bug 663899 - Use the win temp file handling code in all platforms. r=smichaud. a=LegNeato.
authorRafael Ávila de Espíndola <respindola@mozilla.com>
Fri, 09 Sep 2011 19:01:16 -0400
changeset 35186 23d85432311d9e88d09f564aedc47af22fe198c2
parent 35174 d19ac6a6ef00e4de49ae8abe6fc49a9458256a43
child 35187 f5dd7005daa85ccf07b8dce3fbe7cc55483ecce2
push id1973
push userrespindola@mozilla.com
push dateFri, 09 Sep 2011 23:02:56 +0000
reviewerssmichaud, LegNeato
bugs663899
milestone1.9.2.23pre
Bug 663899 - Use the win temp file handling code in all platforms. r=smichaud. a=LegNeato.
uriloader/exthandler/nsExternalHelperAppService.cpp
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -1349,51 +1349,43 @@ nsresult nsExternalAppHandler::SetUpTemp
   mMimeInfo->GetPrimaryExtension(ext);
   if (!ext.IsEmpty()) {
     ext.ReplaceChar(FILE_PATH_SEPARATOR FILE_ILLEGAL_CHARACTERS, '_');
     if (ext.First() != '.')
       tempLeafName.Append('.');
     tempLeafName.Append(ext);
   }
 
-#ifdef XP_WIN
-  // On windows, we need to temporarily create a dummy file with the correct
+  // We need to temporarily create a dummy file with the correct
   // file extension to determine the executable-ness, so do this before adding
   // the extra .part extension.
   nsCOMPtr<nsIFile> dummyFile;
   rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(dummyFile));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Set the file name without .part
   rv = dummyFile->Append(NS_ConvertUTF8toUTF16(tempLeafName));
   NS_ENSURE_SUCCESS(rv, rv);
   rv = dummyFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Store executable-ness then delete
   dummyFile->IsExecutable(&mTempFileIsExecutable);
   dummyFile->Remove(PR_FALSE);
-#endif
 
   // Add an additional .part to prevent the OS from running this file in the
   // default application.
   tempLeafName.Append(NS_LITERAL_CSTRING(".part"));
 
   rv = mTempFile->Append(NS_ConvertUTF8toUTF16(tempLeafName));
   // make this file unique!!!
   NS_ENSURE_SUCCESS(rv, rv);
   rv = mTempFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0600);
   NS_ENSURE_SUCCESS(rv, rv);
 
-#ifndef XP_WIN
-  // On other platforms, the file permission bits are used, so we can just call
-  // IsExecutable
-  mTempFile->IsExecutable(&mTempFileIsExecutable);
-#endif
-
   nsCOMPtr<nsIOutputStream> outputStream;
   rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), mTempFile,
                                    PR_WRONLY | PR_CREATE_FILE, 0600);
   if (NS_FAILED(rv)) {
     mTempFile->Remove(PR_FALSE);
     return rv;
   }