diff --git a/mailnews/base/search/src/nsMsgFilterService.cpp b/mailnews/base/search/src/nsMsgFilterService.cpp index 6a58e60d7840..f34d9387a2a1 100644 --- a/mailnews/base/search/src/nsMsgFilterService.cpp +++ b/mailnews/base/search/src/nsMsgFilterService.cpp @@ -43,7 +43,7 @@ #include "nsMsgFilterService.h" #include "nsFileStream.h" #include "nsMsgFilterList.h" -#include "nsSpecialSystemDirectory.h" +#include "nsDirectoryServiceDefs.h" #include "nsIPrompt.h" #include "nsIDocShell.h" #include "nsIMsgWindow.h" @@ -63,6 +63,7 @@ #include "nsIOutputStream.h" #include "nsIMsgComposeService.h" #include "nsMsgCompCID.h" +#include "nsMsgUtils.h" NS_IMPL_ISUPPORTS1(nsMsgFilterService, nsIMsgFilterService) @@ -147,11 +148,9 @@ NS_IMETHODIMP nsMsgFilterService::SaveFilterList(nsIMsgFilterList *filterList, n nsCOMPtr realFiltersFile; nsCOMPtr parentDir; - - nsSpecialSystemDirectory tmpFile(nsSpecialSystemDirectory::OS_TemporaryDirectory); - tmpFile += "tmprules.dat"; - - ret = NS_NewFileSpecWithSpec(tmpFile, getter_AddRefs(tmpFiltersFile)); + ret = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, + "tmprules.dat", + getter_AddRefs(tmpFiltersFile)); NS_ASSERTION(NS_SUCCEEDED(ret),"writing filters file: failed to append filename"); if (NS_FAILED(ret)) diff --git a/mailnews/base/src/nsMessenger.cpp b/mailnews/base/src/nsMessenger.cpp index a538c3c533b8..54289e08f929 100644 --- a/mailnews/base/src/nsMessenger.cpp +++ b/mailnews/base/src/nsMessenger.cpp @@ -52,8 +52,8 @@ #include "nsReadableUtils.h" #include "nsIFileSpec.h" #include "nsILocalFile.h" +#include "nsDirectoryServiceDefs.h" #include "nsISupportsObsolete.h" -#include "nsSpecialSystemDirectory.h" #include "nsQuickSort.h" #if defined(XP_MAC) || defined(XP_MACOSX) #include "nsIAppleFileDecoder.h" @@ -2992,17 +2992,14 @@ nsDelAttachListener::StartProcessing(nsMessenger * aMessenger, nsIMsgWindow * aM // create an output stream on a temporary file. This stream will save the modified // message data to a file which we will later use to replace the existing message. // The file is removed in the destructor. - nsFileSpec * msgFileSpec = new nsFileSpec( - nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory) ); - if (!msgFileSpec) return NS_ERROR_OUT_OF_MEMORY; - *msgFileSpec += "nsmail.tmp"; - msgFileSpec->MakeUnique(); - rv = NS_NewFileSpecWithSpec(*msgFileSpec, getter_AddRefs(mMsgFileSpec)); - nsCOMPtr msgFile; - if (NS_SUCCEEDED(rv)) - rv = NS_FileSpecToIFile(msgFileSpec, getter_AddRefs(msgFile)); - delete msgFileSpec; + nsCOMPtr msgFile; + rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, "nsmail.tmp", + getter_AddRefs(msgFile)); NS_ENSURE_SUCCESS(rv,rv); + + rv = msgFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600); + NS_ENSURE_SUCCESS(rv,rv); + nsCOMPtr fileOutputStream; rv = NS_NewLocalFileOutputStream(getter_AddRefs(fileOutputStream), msgFile, -1, 00600); NS_ENSURE_SUCCESS(rv,rv); diff --git a/mailnews/base/util/nsMsgProtocol.cpp b/mailnews/base/util/nsMsgProtocol.cpp index cf6500ea071d..cbdbc29af958 100644 --- a/mailnews/base/util/nsMsgProtocol.cpp +++ b/mailnews/base/util/nsMsgProtocol.cpp @@ -43,7 +43,6 @@ #include "nsISocketTransportService.h" #include "nsISocketTransport.h" #include "nsXPIDLString.h" -#include "nsSpecialSystemDirectory.h" #include "nsILoadGroup.h" #include "nsIIOService.h" #include "nsNetUtil.h" @@ -62,6 +61,8 @@ #include "nsThreadUtils.h" #include "nsIPrefBranch.h" #include "nsIPrefService.h" +#include "nsDirectoryServiceDefs.h" +#include "nsMsgUtils.h" NS_IMPL_THREADSAFE_ADDREF(nsMsgProtocol) NS_IMPL_THREADSAFE_RELEASE(nsMsgProtocol) @@ -84,9 +85,10 @@ nsMsgProtocol::nsMsgProtocol(nsIURI * aURL) m_readCount = 0; mLoadFlags = 0; m_socketIsOpen = PR_FALSE; - - m_tempMsgFileSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory); - m_tempMsgFileSpec += "tempMessage.eml"; + + GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, "tempMessage.eml", + getter_AddRefs(m_tempMsgFile)); + mSuppressListenerNotifications = PR_FALSE; InitFromURI(aURL); } diff --git a/mailnews/base/util/nsMsgProtocol.h b/mailnews/base/util/nsMsgProtocol.h index 13221330c3be..06b3b3d06c7c 100644 --- a/mailnews/base/util/nsMsgProtocol.h +++ b/mailnews/base/util/nsMsgProtocol.h @@ -165,7 +165,7 @@ protected: //PRUint32 m_startPosition; PRInt32 m_readCount; - nsFileSpec m_tempMsgFileSpec; // we currently have a hack where displaying a msg involves writing it to a temp file first + nsCOMPtr m_tempMsgFile; // we currently have a hack where displaying a msg involves writing it to a temp file first // auth module for access to NTLM functions nsCOMPtr m_authModule; diff --git a/mailnews/base/util/nsMsgUtils.cpp b/mailnews/base/util/nsMsgUtils.cpp index 105e2000d32f..d406329f598e 100644 --- a/mailnews/base/util/nsMsgUtils.cpp +++ b/mailnews/base/util/nsMsgUtils.cpp @@ -1221,6 +1221,47 @@ void GetSummaryFileLocation(nsFileSpec& fileLocation, nsFileSpec* summaryLocatio summaryLocation->SetLeafName(fileName); } +// Gets a special directory and appends the supplied file name onto it. +nsresult GetSpecialDirectoryWithFileName(const char* specialDirName, + const char* fileName, + nsIFile** result) +{ + nsresult rv = NS_GetSpecialDirectory(specialDirName, result); + NS_ENSURE_SUCCESS(rv, rv); + + return (*result)->AppendNative(nsDependentCString(fileName)); +} + +// XXX This function is provided temporarily whilst we are still working +// on bug 33451 to remove nsIFileSpec from mailnews. +nsresult GetSpecialDirectoryWithFileName(const char* specialDirName, + const char* fileName, + nsIFileSpec** result) +{ + nsCOMPtr tmpFile; + nsresult rv = GetSpecialDirectoryWithFileName(specialDirName, fileName, + getter_AddRefs(tmpFile)); + NS_ENSURE_SUCCESS(rv, rv); + + return NS_NewFileSpecFromIFile(tmpFile, result); +} + +// XXX This function is provided temporarily whilst we are still working +// on bug 33451 to remove nsIFileSpec from mailnews. +nsresult GetSpecialDirectoryWithFileName(const char* specialDirName, + const char* fileName, + nsFileSpec* result) +{ + + + nsCOMPtr tmpFile; + nsresult rv = GetSpecialDirectoryWithFileName(specialDirName, fileName, + getter_AddRefs(tmpFile)); + NS_ENSURE_SUCCESS(rv, rv); + + return tmpFile->GetFileSpec(result); +} + PRBool MsgFindKeyword(const nsACString &keyword, nsACString &keywords, nsACString::const_iterator &start, nsACString::const_iterator &end) { keywords.BeginReading(start); diff --git a/mailnews/base/util/nsMsgUtils.h b/mailnews/base/util/nsMsgUtils.h index 1488d8ee636a..3047ce47075c 100644 --- a/mailnews/base/util/nsMsgUtils.h +++ b/mailnews/base/util/nsMsgUtils.h @@ -158,6 +158,24 @@ NS_MSG_BASE nsresult GetSummaryFileLocation(nsIFileSpec* fileLocation, // on bug 33451 to remove nsIFileSpec from mailnews. NS_MSG_BASE void GetSummaryFileLocation(nsFileSpec& fileLocation, nsFileSpec* summaryLocation); + +// Gets a special directory and appends the supplied file name onto it. +NS_MSG_BASE nsresult GetSpecialDirectoryWithFileName(const char* specialDirName, + const char* fileName, + nsIFile** result); + +// XXX This function is provided temporarily whilst we are still working +// on bug 33451 to remove nsIFileSpec from mailnews. +NS_MSG_BASE nsresult GetSpecialDirectoryWithFileName(const char* specialDirName, + const char* fileName, + nsIFileSpec** result); + +// XXX This function is provided temporarily whilst we are still working +// on bug 33451 to remove nsIFileSpec from mailnews. +NS_MSG_BASE nsresult GetSpecialDirectoryWithFileName(const char* specialDirName, + const char* fileName, + nsFileSpec* result); + // fills in the position of the passed in keyword in the passed in keyword list // and returns false if the keyword isn't present NS_MSG_BASE PRBool MsgFindKeyword(const nsACString &keyword, nsACString &keywords, diff --git a/mailnews/compose/src/nsMsgCompUtils.cpp b/mailnews/compose/src/nsMsgCompUtils.cpp index 9aafa02c368f..2014289943c4 100644 --- a/mailnews/compose/src/nsMsgCompUtils.cpp +++ b/mailnews/compose/src/nsMsgCompUtils.cpp @@ -53,7 +53,7 @@ #include "nsMsgComposeStringBundle.h" #include "nsXPIDLString.h" #include "nsReadableUtils.h" -#include "nsSpecialSystemDirectory.h" +#include "nsDirectoryServiceDefs.h" #include "nsIDocumentEncoder.h" // for editor output flags #include "nsIURI.h" #include "nsNetCID.h" @@ -119,12 +119,16 @@ nsMsgCreateTempFileSpec(const char *tFileName) if ((!tFileName) || (!*tFileName)) tFileName = "nsmail.tmp"; - nsFileSpec *tmpSpec = new nsFileSpec(nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory)); - - if (!tmpSpec) + nsFileSpec *tmpSpec = new nsFileSpec; + + if (NS_FAILED(GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, + tFileName, + tmpSpec))) + { + delete tmpSpec; return nsnull; + } - *tmpSpec += tFileName; tmpSpec->MakeUnique(); return tmpSpec; @@ -141,15 +145,28 @@ nsMsgCreateTempFileName(const char *tFileName) if ((!tFileName) || (!*tFileName)) tFileName = "nsmail.tmp"; - nsFileSpec tmpSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory); - tmpSpec += tFileName; - tmpSpec.MakeUnique(); + nsCOMPtr tmpFile; - char *tString = (char *)PL_strdup(tmpSpec.GetNativePathCString()); + nsresult rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, + tFileName, + getter_AddRefs(tmpFile)); + if (NS_FAILED(rv)) + return nsnull; + + rv = tmpFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600); + if (NS_FAILED(rv)) + return nsnull; + + nsXPIDLCString tempString; + rv = tmpFile->GetNativePath(tempString); + if (NS_FAILED(rv)) + return nsnull; + + char *tString = (char *)PL_strdup(tempString.get()); if (!tString) return PL_strdup("mozmail.tmp"); // No need to I18N - else - return tString; + + return tString; } static PRBool mime_headers_use_quoted_printable_p = PR_FALSE; @@ -1674,8 +1691,6 @@ msg_pick_real_name (nsMsgAttachmentHandler *attachment, const PRUnichar *propose nsUnescape (attachment->m_real_name); } - PRInt32 parmFolding = 0; - /* Now a special case for attaching uuencoded files... If we attach a file "foo.txt.uu", we will send it out with diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index 8858425c9e84..b173df51a22f 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -66,7 +66,6 @@ #include "nsMsgCompUtils.h" #include "nsIMsgStringService.h" #include "nsMsgComposeStringBundle.h" -#include "nsSpecialSystemDirectory.h" #include "nsMsgSend.h" #include "nsMsgCreate.h" #include "nsMailHeaders.h" diff --git a/mailnews/extensions/mdn/src/nsMsgMdnGenerator.cpp b/mailnews/extensions/mdn/src/nsMsgMdnGenerator.cpp index a20baeb7f32e..ff4d1297c7a0 100644 --- a/mailnews/extensions/mdn/src/nsMsgMdnGenerator.cpp +++ b/mailnews/extensions/mdn/src/nsMsgMdnGenerator.cpp @@ -43,7 +43,6 @@ #include "nsMsgMimeCID.h" #include "nsIMsgAccountManager.h" #include "nsMsgBaseCID.h" -#include "nsSpecialSystemDirectory.h" #include "nsCRT.h" #include "nsMimeTypes.h" #include "prmem.h" @@ -62,6 +61,8 @@ #include "nsIPrefService.h" #include "nsIPrefBranch.h" #include "nsIStringBundle.h" +#include "nsDirectoryServiceDefs.h" +#include "nsMsgUtils.h" #define MDN_NOT_IN_TO_CC ((int) 0x0001) #define MDN_OUTSIDE_DOMAIN ((int) 0x0002) @@ -408,12 +409,18 @@ nsresult nsMsgMdnGenerator::CreateMdnMsg() if (!m_reallySendMdn) return NS_OK; - nsSpecialSystemDirectory - tmpFile(nsSpecialSystemDirectory::OS_TemporaryDirectory); - tmpFile += "mdnmsg"; - tmpFile.MakeUnique(); + - rv = NS_NewFileSpecWithSpec(tmpFile, getter_AddRefs(m_fileSpec)); + nsCOMPtr tmpFile; + rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, + "mdnmsg", + getter_AddRefs(tmpFile)); + NS_ENSURE_SUCCESS(rv, rv); + + rv = tmpFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600); + NS_ENSURE_SUCCESS(rv, rv); + + rv = NS_NewFileSpecFromIFile(tmpFile, getter_AddRefs(m_fileSpec)); NS_ASSERTION(NS_SUCCEEDED(rv),"creating mdn: failed to create"); if (NS_FAILED(rv)) diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index fec2628af0ef..3cce23ed428e 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -81,7 +81,6 @@ #include "nsIDocShell.h" #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" -#include "nsSpecialSystemDirectory.h" #include "nsXPIDLString.h" #include "nsReadableUtils.h" #include "nsUnicharUtils.h" @@ -114,6 +113,7 @@ #include "nsIMsgComposeService.h" #include "nsMsgCompCID.h" #include "nsICacheEntryDescriptor.h" +#include "nsDirectoryServiceDefs.h" static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); @@ -3108,16 +3108,15 @@ NS_IMETHODIMP nsImapMailFolder::BeginCopy(nsIMsgDBHdr *message) if (message) m_copyState->m_message = do_QueryInterface(message, &rv); - nsSpecialSystemDirectory tmpFileSpec(nsSpecialSystemDirectory::OS_TemporaryDirectory); - - tmpFileSpec += "nscpmsg.txt"; - tmpFileSpec.MakeUnique(); - rv = NS_NewFileSpecWithSpec(tmpFileSpec, - getter_AddRefs(m_copyState->m_tmpFileSpec)); - nsCOMPtr msgFile; - if (NS_SUCCEEDED(rv)) - rv = NS_FileSpecToIFile(&tmpFileSpec, getter_AddRefs(msgFile)); - NS_ENSURE_SUCCESS(rv,rv); + nsCOMPtr msgFile; + rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, + "nscpmsg.txt", + getter_AddRefs(msgFile)); + NS_ENSURE_SUCCESS(rv, rv); + + rv = msgFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600); + NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr fileOutputStream; rv = NS_NewLocalFileOutputStream(getter_AddRefs(fileOutputStream), msgFile, -1, 00600); NS_ENSURE_SUCCESS(rv,rv); diff --git a/mailnews/imap/src/nsImapOfflineSync.cpp b/mailnews/imap/src/nsImapOfflineSync.cpp index c9b64c544268..d29ea2ba6616 100644 --- a/mailnews/imap/src/nsImapOfflineSync.cpp +++ b/mailnews/imap/src/nsImapOfflineSync.cpp @@ -47,10 +47,11 @@ #include "nsIMsgAccountManager.h" #include "nsINntpIncomingServer.h" #include "nsIRequestObserver.h" -#include "nsSpecialSystemDirectory.h" +#include "nsDirectoryServiceDefs.h" #include "nsIFileStream.h" #include "nsIMsgCopyService.h" #include "nsImapProtocol.h" +#include "nsMsgUtils.h" static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); @@ -379,12 +380,17 @@ nsImapOfflineSync::ProcessAppendMsgOperation(nsIMsgOfflineImapOperation *current mailHdr->GetMessageOffset(&messageOffset); mailHdr->GetOfflineMessageSize(&messageSize); nsCOMPtr tempFileSpec; - nsSpecialSystemDirectory tmpFileSpec(nsSpecialSystemDirectory::OS_TemporaryDirectory); - - tmpFileSpec += "nscpmsg.txt"; - tmpFileSpec.MakeUnique(); - rv = NS_NewFileSpecWithSpec(tmpFileSpec, - getter_AddRefs(tempFileSpec)); + nsCOMPtr tmpFile; + + if (NS_FAILED(GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, + "nscpmsg.txt", + getter_AddRefs(tmpFile)))) + return; + + if (NS_FAILED(tmpFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600))) + return; + + NS_NewFileSpecFromIFile(tmpFile, getter_AddRefs(tempFileSpec)); if (tempFileSpec) { nsCOMPtr outputStream; diff --git a/mailnews/import/eudora/src/nsEudoraMac.cpp b/mailnews/import/eudora/src/nsEudoraMac.cpp index fb7a3b4bc0b2..5f931e41a6fc 100644 --- a/mailnews/import/eudora/src/nsEudoraMac.cpp +++ b/mailnews/import/eudora/src/nsEudoraMac.cpp @@ -50,7 +50,7 @@ #include "nsIImportService.h" #include "nsIImportMailboxDescriptor.h" #include "nsIImportABDescriptor.h" -#include "nsSpecialSystemDirectory.h" +#include "nsDirectoryServiceDefs.h" #include "nsEudoraStringBundle.h" #include "nsEudoraImport.h" #include "nsIPop3IncomingServer.h" @@ -112,11 +112,20 @@ PRBool nsEudoraMac::FindEudoraLocation( nsIFileSpec *pFolder, PRBool findIni, ns // "Eudora Folder" (not sure if this is true for intl versions of Eudora) if (!pLookIn) { - nsSpecialSystemDirectory sysDir( nsSpecialSystemDirectory::Mac_SystemDirectory); - pFolder->SetFromFileSpec( sysDir); + nsCOMPtr sysDir; + nsresult rv = NS_GetSpecialDirectory(NS_OS_SYSTEM_DIR, getter_AddRefs(sysDir)); + if (NS_FAILED(rv)) + return (PR_FALSE); + + nsCOMPtr sysDirSpec; + rv = NS_NewFileSpecFromIFile(sysDir, getter_AddRefs(sysDirSpec)); + if (NS_FAILED(rv)) + return (PR_FALSE); + + pFolder->FromFileSpec(sysDirSpec); pFolder->AppendRelativeUnixPath( "Eudora Folder"); PRBool link = PR_FALSE; - nsresult rv = pFolder->IsSymlink( &link); + rv = pFolder->IsSymlink( &link); if (NS_SUCCEEDED( rv) && link) { rv = pFolder->ResolveSymlink(); if (NS_FAILED( rv)) @@ -478,9 +487,18 @@ PRBool nsEudoraMac::CreateTocFromResource( nsIFileSpec *pMail, nsIFileSpec *pToc if (resH) { PRInt32 sz = (PRInt32) GetHandleSize( resH); if (sz) { - // Create the new TOC file - nsSpecialSystemDirectory dir( nsSpecialSystemDirectory::OS_TemporaryDirectory); - rv = pToc->SetFromFileSpec( dir); + // Create the new TOC file + nsCOMPtr tempDir; + nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tempDir)); + if (NS_FAILED(rv)) + return (PR_FALSE); + + nsCOMPtr dir; + rv = NS_NewFileSpecFromIFile(tempDir, getter_AddRefs(dir)); + if (NS_FAILED(rv)) + return (PR_FALSE); + + rv = pToc->FromFileSpec( dir); if (NS_SUCCEEDED( rv)) rv = pToc->AppendRelativeUnixPath( "temp.toc"); if (NS_SUCCEEDED( rv)) diff --git a/mailnews/import/eudora/src/nsEudoraMailbox.cpp b/mailnews/import/eudora/src/nsEudoraMailbox.cpp index 1122eb2bb7b9..419301547d6a 100644 --- a/mailnews/import/eudora/src/nsEudoraMailbox.cpp +++ b/mailnews/import/eudora/src/nsEudoraMailbox.cpp @@ -40,9 +40,10 @@ #include "nsCOMPtr.h" #include "nsReadableUtils.h" #include "nsEudoraMailbox.h" -#include "nsSpecialSystemDirectory.h" +#include "nsDirectoryServiceDefs.h" #include "nsEudoraCompose.h" #include "nspr.h" +#include "nsMsgUtils.h" #include "EudoraDebugLog.h" @@ -118,23 +119,18 @@ nsEudoraMailbox::~nsEudoraMailbox() nsresult nsEudoraMailbox::CreateTempFile( nsIFileSpec **ppSpec) { - *ppSpec = nsnull; - - nsSpecialSystemDirectory temp(nsSpecialSystemDirectory::OS_TemporaryDirectory); - - // nsSpecialSystemDirectory temp(nsSpecialSystemDirectory::Mac_DesktopDirectory); - - temp += "impmail.txt"; - temp.MakeUnique(); - nsresult rv = NS_NewFileSpecWithSpec( temp, ppSpec); - if (NS_SUCCEEDED(rv)) { - if (*ppSpec) - return( NS_OK); - else - return( NS_ERROR_FAILURE); - } + *ppSpec = nsnull; - return( rv); + nsCOMPtr tmpFile; + nsresult rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, + "impmail.txt", + getter_AddRefs(tmpFile)); + NS_ENSURE_SUCCESS(rv, rv); + + rv = tmpFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600); + NS_ENSURE_SUCCESS(rv, rv); + + return NS_NewFileSpecFromIFile(tmpFile, ppSpec); } nsresult nsEudoraMailbox::DeleteFile( nsIFileSpec *pSpec) diff --git a/mailnews/import/outlook/src/MapiMessage.cpp b/mailnews/import/outlook/src/MapiMessage.cpp index 7d9565acb03f..6a07f5fc574c 100644 --- a/mailnews/import/outlook/src/MapiMessage.cpp +++ b/mailnews/import/outlook/src/MapiMessage.cpp @@ -39,7 +39,8 @@ #include #include "nsString.h" #include "nsFileSpec.h" -#include "nsSpecialSystemDirectory.h" +#include "nsDirectoryServiceDefs.h" +#include "nsMsgUtils.h" #include "MapiDbgLog.h" #include "MapiApi.h" @@ -605,14 +606,19 @@ BOOL CMapiMessage::CopyBinAttachToFile( LPATTACH lpAttach) m_ownsAttachFile = FALSE; m_attachPath.Truncate(); - const char *tFileName = "mapiattach.tmp"; + nsCOMPtr tmpFile; + nsresult rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, + "mapiattach.tmp", + getter_AddRefs(tmpFile)); + NS_ENSURE_SUCCESS(rv, rv); - nsFileSpec tmpSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory); - tmpSpec += tFileName; - tmpSpec.MakeUnique(); + rv = tmpFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600); + NS_ENSURE_SUCCESS(rv, rv); + nsXPIDLCString tmpPath; + tmpFile->GetNativePath(tmpPath); HRESULT hr = CMapiApi::OpenStreamOnFile( gpMapiAllocateBuffer, gpMapiFreeBuffer, STGM_READWRITE | STGM_CREATE, - (char *) tmpSpec.GetNativePathCString(), NULL, &lpStreamFile); + (char *) tmpPath.get(), NULL, &lpStreamFile); if (HR_FAILED(hr)) { MAPI_TRACE1( "~~ERROR~~ OpenStreamOnFile failed - temp path: %s\r\n", tPath); return( FALSE); @@ -644,7 +650,7 @@ BOOL CMapiMessage::CopyBinAttachToFile( LPATTACH lpAttach) } } - m_attachPath = tmpSpec.GetNativePathCString(); + m_attachPath = tmpPath; if (lpAttachStream) lpAttachStream->Release(); lpStreamFile->Release(); diff --git a/mailnews/local/src/nsMailboxProtocol.cpp b/mailnews/local/src/nsMailboxProtocol.cpp index 338d81d0e0e3..be1adce30644 100644 --- a/mailnews/local/src/nsMailboxProtocol.cpp +++ b/mailnews/local/src/nsMailboxProtocol.cpp @@ -222,7 +222,7 @@ nsresult nsMailboxProtocol::Initialize(nsIURI * aURL) m_initialState = MAILBOX_READ_FOLDER; mCurrentProgress = 0; - NS_NewFileSpecWithSpec(m_tempMsgFileSpec, getter_AddRefs(m_tempMessageFile)); + NS_NewFileSpecFromIFile(m_tempMsgFile, getter_AddRefs(m_tempMessageFile)); return rv; } diff --git a/mailnews/local/src/nsPop3Sink.cpp b/mailnews/local/src/nsPop3Sink.cpp index a3fa82ba7aca..07c59129f5ae 100644 --- a/mailnews/local/src/nsPop3Sink.cpp +++ b/mailnews/local/src/nsPop3Sink.cpp @@ -59,7 +59,7 @@ #include "nsLocalMailFolder.h" #include "nsIPrefBranch.h" #include "nsIPrefService.h" -#include "nsSpecialSystemDirectory.h" +#include "nsDirectoryServiceDefs.h" #include "nsIMsgStringService.h" #include "nsIPrompt.h" #include "nsIPromptService.h" @@ -68,6 +68,7 @@ #include "nsIDocShell.h" #include "nsIDOMWindowInternal.h" #include "nsEmbedCID.h" +#include "nsMsgUtils.h" NS_IMPL_THREADSAFE_ISUPPORTS1(nsPop3Sink, nsIPop3Sink) @@ -309,11 +310,10 @@ nsPop3Sink::BeginMailDelivery(PRBool uidlDownload, nsIMsgWindow *aMsgWindow, PRB if (m_downloadingToTempFile) { // need to create an nsIOFileStream from a temp file... - nsCOMPtr tmpDownloadFile; - nsSpecialSystemDirectory tmpFile(nsSpecialSystemDirectory::OS_TemporaryDirectory); - tmpFile += "newmsg"; - - rv = NS_NewFileSpecWithSpec(tmpFile, getter_AddRefs(tmpDownloadFile)); + nsCOMPtr tmpDownloadFile; + rv = GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, + "newmsg", + getter_AddRefs(tmpDownloadFile)); NS_ASSERTION(NS_SUCCEEDED(rv),"writing tmp pop3 download file: failed to append filename"); if (NS_FAILED(rv)) diff --git a/mailnews/mime/src/mimedrft.cpp b/mailnews/mime/src/mimedrft.cpp index 231867ac6a47..85daacc1c28b 100644 --- a/mailnews/mime/src/mimedrft.cpp +++ b/mailnews/mime/src/mimedrft.cpp @@ -72,7 +72,7 @@ #include "nsIMsgComposeService.h" #include "nsMsgI18N.h" #include "nsNativeCharsetUtils.h" -#include "nsSpecialSystemDirectory.h" +#include "nsDirectoryServiceDefs.h" #include "nsIMsgMessageService.h" #include "nsMsgUtils.h" #include "nsXPIDLString.h" @@ -121,12 +121,22 @@ nsFileSpec * nsMsgCreateTempFileSpec(const char *tFileName) { //Calling NS_MsgHashIfNecessary so that when Replies are forwarded - the ':' in the subject line doesn't cause problems - nsFileSpec *tmpSpec = new nsFileSpec(nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory)); - NS_ASSERTION(tmpSpec, "out of memory"); + nsCOMPtr tmpFile; + nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tmpFile)); + if (NS_FAILED(rv)) + return nsnull; + + nsCOMPtr tmpFileSpec; + rv = NS_NewFileSpecFromIFile(tmpFile, getter_AddRefs(tmpFileSpec)); + + if (NS_FAILED(rv)) + return nsnull; + + nsFileSpec *tmpSpec = new nsFileSpec; + tmpFileSpec->GetFileSpec(tmpSpec); if (!tmpSpec) return nsnull; - nsresult rv = NS_OK; nsCAutoString tempName; if ((!tFileName) || (!*tFileName)) { tempName = SAFE_TMP_FILENAME; diff --git a/mailnews/mime/src/mimemoz2.cpp b/mailnews/mime/src/mimemoz2.cpp index 3fa494c5d3cf..d2f2a2f9d141 100644 --- a/mailnews/mime/src/mimemoz2.cpp +++ b/mailnews/mime/src/mimemoz2.cpp @@ -67,7 +67,6 @@ #include "nsStreamConverter.h" #include "nsIMsgSend.h" #include "nsIMsgMailNewsUrl.h" -#include "nsSpecialSystemDirectory.h" #include "mozITXTToHTMLConv.h" #include "nsCExternalHandlerService.h" #include "nsIMIMEService.h" diff --git a/mailnews/news/src/nsNNTPProtocol.h b/mailnews/news/src/nsNNTPProtocol.h index 8aa5169cc013..57ea613afbf7 100644 --- a/mailnews/news/src/nsNNTPProtocol.h +++ b/mailnews/news/src/nsNNTPProtocol.h @@ -55,7 +55,6 @@ #include "nsIMsgWindow.h" #include "nsMsgLineBuffer.h" -#include "nsSpecialSystemDirectory.h" #include "nsXPIDLString.h" #include "nsIStringBundle.h" #include "nsITimer.h"