From 95a0e46f80be9e76acb0375fb6ad90fffcd735b6 Mon Sep 17 00:00:00 2001 From: Ben Frisch Date: Fri, 7 May 2010 10:30:09 +0100 Subject: [PATCH] Bug 558246 nsMsgAttachmentHandler isn't 64-bit compatible. r=bienvenu,sr=Standard8 --- .../compose/src/nsMsgAttachmentHandler.cpp | 51 +++++++++---------- mailnews/compose/src/nsMsgAttachmentHandler.h | 3 +- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/mailnews/compose/src/nsMsgAttachmentHandler.cpp b/mailnews/compose/src/nsMsgAttachmentHandler.cpp index 43a8ef91b5..ce0a43db8d 100644 --- a/mailnews/compose/src/nsMsgAttachmentHandler.cpp +++ b/mailnews/compose/src/nsMsgAttachmentHandler.cpp @@ -658,16 +658,11 @@ done: } #ifdef XP_MACOSX -PRBool nsMsgAttachmentHandler::HasResourceFork(FSSpec *fsSpec) +PRBool nsMsgAttachmentHandler::HasResourceFork(FSRef *fsRef) { - FSRef fsRef; - if (::FSpMakeFSRef(fsSpec, &fsRef) == noErr) - { - FSCatalogInfo catalogInfo; - OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoDataSizes + kFSCatInfoRsrcSizes, &catalogInfo, nsnull, nsnull, nsnull); - return (err == noErr && catalogInfo.rsrcLogicalSize != 0); - } - return PR_FALSE; + FSCatalogInfo catalogInfo; + OSErr err = FSGetCatalogInfo(fsRef, kFSCatInfoDataSizes + kFSCatInfoRsrcSizes, &catalogInfo, nsnull, nsnull, nsnull); + return (err == noErr && catalogInfo.rsrcLogicalSize != 0); } #endif @@ -795,24 +790,28 @@ nsMsgAttachmentHandler::ConvertToAppleEncoding(const nsCString &aFileURI, // convert the apple file to AppleDouble first, and then patch the // address in the url. - //We need to retrieve the file type and creator... - FSSpec fsSpec; - aSourceFile->GetFSSpec(&fsSpec); - FInfo info; - if (FSpGetFInfo (&fsSpec, &info) == noErr) - { - char filetype[32]; - PR_snprintf(filetype, sizeof(filetype), "%X", info.fdType); - PR_Free(m_x_mac_type); - m_x_mac_type = PL_strdup(filetype); - PR_snprintf(filetype, sizeof(filetype), "%X", info.fdCreator); - PR_Free(m_x_mac_creator); - m_x_mac_creator = PL_strdup(filetype); - } + char fileInfo[32]; + OSType type, creator; - PRBool sendResourceFork = HasResourceFork(&fsSpec); + nsresult rv = aSourceFile->GetFileType(&type); + if (NS_FAILED(rv)) + return PR_FALSE; + PR_snprintf(fileInfo, sizeof(fileInfo), "%X", type); + PR_Free(m_x_mac_type); + m_x_mac_type = PL_strdup(fileInfo); + + rv = aSourceFile->GetFileCreator(&creator); + if (NS_FAILED(rv)) + return PR_FALSE; + PR_snprintf(fileInfo, sizeof(fileInfo), "%X", creator); + PR_Free(m_x_mac_creator); + m_x_mac_creator = PL_strdup(fileInfo); + + FSRef fsRef; + aSourceFile->GetFSRef(&fsRef); + PRBool sendResourceFork = HasResourceFork(&fsRef); // if we have a resource fork, check the filename extension, maybe we don't need the resource fork! if (sendResourceFork) @@ -820,7 +819,7 @@ nsMsgAttachmentHandler::ConvertToAppleEncoding(const nsCString &aFileURI, nsCOMPtr fileUrl(do_CreateInstance(NS_STANDARDURL_CONTRACTID)); if (fileUrl) { - nsresult rv = fileUrl->SetSpec(aFileURI); + rv = fileUrl->SetSpec(aFileURI); if (NS_SUCCEEDED(rv)) { nsCAutoString ext; @@ -982,7 +981,7 @@ nsMsgAttachmentHandler::ConvertToAppleEncoding(const nsCString &aFileURI, # define TEXT_TYPE 0x54455854 /* the characters 'T' 'E' 'X' 'T' */ # define text_TYPE 0x74657874 /* the characters 't' 'e' 'x' 't' */ - if (info.fdType != TEXT_TYPE && info.fdType != text_TYPE) + if (type != TEXT_TYPE && type != text_TYPE) { MacGetFileType(aSourceFile, &useDefault, &macType, &macEncoding); PR_Free(m_type); diff --git a/mailnews/compose/src/nsMsgAttachmentHandler.h b/mailnews/compose/src/nsMsgAttachmentHandler.h index 8906acd8f7..05908ff7ca 100644 --- a/mailnews/compose/src/nsMsgAttachmentHandler.h +++ b/mailnews/compose/src/nsMsgAttachmentHandler.h @@ -50,6 +50,7 @@ #ifdef XP_MACOSX #include "nsMsgAppleDouble.h" +#include "nsILocalFileMac.h" class AppleDoubleEncodeObject { @@ -121,7 +122,7 @@ private: nsILocalFileMac *aSourceFile); // zips this attachment and does the work to make this attachment handler handle it properly. nsresult ConvertToZipFile(nsILocalFileMac *aSourceFile); - PRBool HasResourceFork(FSSpec *fsSpec); + PRBool HasResourceFork(FSRef *fsRef); #endif //