зеркало из https://github.com/mozilla/gecko-dev.git
Changes for using nsSpecialSystemDirectory directory - Bug #18021 - r: jefft
This commit is contained in:
Родитель
b823e0340c
Коммит
74d7368d51
|
@ -66,6 +66,9 @@ nsMsgCreateTempFileSpec(char *tFileName)
|
||||||
|
|
||||||
nsFileSpec *tmpSpec = new nsFileSpec(nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory));
|
nsFileSpec *tmpSpec = new nsFileSpec(nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory));
|
||||||
|
|
||||||
|
if (!tmpSpec)
|
||||||
|
return nsnull;
|
||||||
|
|
||||||
*tmpSpec += tFileName;
|
*tmpSpec += tFileName;
|
||||||
tmpSpec->MakeUnique();
|
tmpSpec->MakeUnique();
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "nsIIOService.h"
|
#include "nsIIOService.h"
|
||||||
#include "nsIURI.h"
|
#include "nsIURI.h"
|
||||||
#include "prprf.h"
|
#include "prprf.h"
|
||||||
|
#include "nsSpecialSystemDirectory.h"
|
||||||
|
|
||||||
extern "C" PRBool
|
extern "C" PRBool
|
||||||
EmitThisHeaderForPrefSetting(PRInt32 dispType, const char *header)
|
EmitThisHeaderForPrefSetting(PRInt32 dispType, const char *header)
|
||||||
|
@ -86,44 +87,6 @@ EmitThisHeaderForPrefSetting(PRInt32 dispType, const char *header)
|
||||||
//
|
//
|
||||||
#define TPATH_LEN 1024
|
#define TPATH_LEN 1024
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#include "windows.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *
|
|
||||||
GetTheTempDirectoryOnTheSystem(void)
|
|
||||||
{
|
|
||||||
char *retPath = (char *)PR_Malloc(TPATH_LEN);
|
|
||||||
if (!retPath)
|
|
||||||
return nsnull;
|
|
||||||
|
|
||||||
retPath[0] = '\0';
|
|
||||||
#ifdef WIN32
|
|
||||||
if (getenv("TEMP"))
|
|
||||||
PL_strncpy(retPath, getenv("TEMP"), TPATH_LEN); // environment variable
|
|
||||||
else if (getenv("TMP"))
|
|
||||||
PL_strncpy(retPath, getenv("TMP"), TPATH_LEN); // How about this environment variable?
|
|
||||||
else
|
|
||||||
GetWindowsDirectory(retPath, TPATH_LEN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// RICHIE - should do something better here!
|
|
||||||
|
|
||||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
|
||||||
char *tPath = getenv("TMPDIR");
|
|
||||||
if (!tPath)
|
|
||||||
PL_strncpy(retPath, "/tmp/", TPATH_LEN);
|
|
||||||
else
|
|
||||||
PL_strncpy(retPath, tPath, TPATH_LEN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef XP_MAC
|
|
||||||
PL_strncpy(retPath, "", TPATH_LEN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return retPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create a file spec for the a unique temp file
|
// Create a file spec for the a unique temp file
|
||||||
// on the local machine. Caller must free memory
|
// on the local machine. Caller must free memory
|
||||||
|
@ -132,24 +95,15 @@ nsFileSpec *
|
||||||
nsMsgCreateTempFileSpec(char *tFileName)
|
nsMsgCreateTempFileSpec(char *tFileName)
|
||||||
{
|
{
|
||||||
if ((!tFileName) || (!*tFileName))
|
if ((!tFileName) || (!*tFileName))
|
||||||
tFileName = "nsmail.tmp";
|
tFileName = "emitter.tmp";
|
||||||
|
|
||||||
// Age old question, where to store temp files....ugh!
|
nsFileSpec *tmpSpec = new nsFileSpec(nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory));
|
||||||
char *tDir = GetTheTempDirectoryOnTheSystem();
|
|
||||||
if (!tDir)
|
|
||||||
return (new nsFileSpec("mozmail.tmp")); // No need to I18N
|
|
||||||
|
|
||||||
nsFileSpec *tmpSpec = new nsFileSpec(tDir);
|
|
||||||
if (!tmpSpec)
|
if (!tmpSpec)
|
||||||
{
|
return nsnull;
|
||||||
PR_FREEIF(tDir);
|
|
||||||
return (new nsFileSpec("mozmail.tmp")); // No need to I18N
|
|
||||||
}
|
|
||||||
|
|
||||||
*tmpSpec += tFileName;
|
*tmpSpec += tFileName;
|
||||||
tmpSpec->MakeUnique();
|
tmpSpec->MakeUnique();
|
||||||
|
|
||||||
PR_FREEIF(tDir);
|
|
||||||
return tmpSpec;
|
return tmpSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,17 +118,17 @@ nsMsgCreateTempFileName(char *tFileName)
|
||||||
if ((!tFileName) || (!*tFileName))
|
if ((!tFileName) || (!*tFileName))
|
||||||
tFileName = "nsmail.tmp";
|
tFileName = "nsmail.tmp";
|
||||||
|
|
||||||
|
nsFileSpec *tmpSpec = new nsFileSpec(nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory));
|
||||||
|
|
||||||
// Age old question, where to store temp files....ugh!
|
// Age old question, where to store temp files....ugh!
|
||||||
char *tDir = GetTheTempDirectoryOnTheSystem();
|
if (!tmpSpec)
|
||||||
if (!tDir)
|
|
||||||
return "mozmail.tmp"; // No need to I18N
|
return "mozmail.tmp"; // No need to I18N
|
||||||
|
|
||||||
nsFileSpec tmpSpec(tDir);
|
*tmpSpec += tFileName;
|
||||||
tmpSpec += tFileName;
|
tmpSpec->MakeUnique();
|
||||||
tmpSpec.MakeUnique();
|
|
||||||
|
|
||||||
PR_FREEIF(tDir);
|
char *tString = (char *)nsCRT::strdup(tmpSpec->GetNativePathCString());
|
||||||
char *tString = (char *)nsCRT::strdup(tmpSpec.GetNativePathCString());
|
delete tmpSpec;
|
||||||
if (!tString)
|
if (!tString)
|
||||||
return nsCRT::strdup("mozmail.tmp"); // No need to I18N
|
return nsCRT::strdup("mozmail.tmp"); // No need to I18N
|
||||||
else
|
else
|
||||||
|
|
|
@ -36,7 +36,5 @@ char *nsMsgCreateTempFileName(char *tFileName);
|
||||||
|
|
||||||
char *nsMimePlatformFileToURL (nsFileSpec aFileSpec);
|
char *nsMimePlatformFileToURL (nsFileSpec aFileSpec);
|
||||||
|
|
||||||
char *GetTheTempDirectoryOnTheSystem(void);
|
|
||||||
|
|
||||||
#endif // _nsEmitterUtils_h_
|
#endif // _nsEmitterUtils_h_
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIMsgMailNewsUrl.h"
|
#include "nsIMsgMailNewsUrl.h"
|
||||||
#include "nsXPIDLString.h"
|
#include "nsXPIDLString.h"
|
||||||
|
#include "nsSpecialSystemDirectory.h"
|
||||||
|
|
||||||
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
|
static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
|
||||||
static NS_DEFINE_CID(kCAddressCollecter, NS_ABADDRESSCOLLECTER_CID);
|
static NS_DEFINE_CID(kCAddressCollecter, NS_ABADDRESSCOLLECTER_CID);
|
||||||
|
@ -211,15 +212,15 @@ nsMimeXULEmitter::WriteBody(const char *buf, PRUint32 size, PRUint32 *amountWrit
|
||||||
nsresult
|
nsresult
|
||||||
nsMimeXULEmitter::OhTheHumanityCleanupTempFileHack()
|
nsMimeXULEmitter::OhTheHumanityCleanupTempFileHack()
|
||||||
{
|
{
|
||||||
// Age old question, where to store temp files....ugh!
|
// Age old question, where to find temp files....ugh!
|
||||||
char *tDir = GetTheTempDirectoryOnTheSystem();
|
nsFileSpec *tmpSpec = new nsFileSpec(nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory));
|
||||||
if (!tDir)
|
|
||||||
|
if (!tmpSpec)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
nsFileSpec tempDir(tDir);
|
if (tmpSpec->Exists())
|
||||||
if (tempDir.Exists())
|
|
||||||
{
|
{
|
||||||
for (nsDirectoryIterator i(tempDir, PR_FALSE); i.Exists(); i++)
|
for (nsDirectoryIterator i(*tmpSpec, PR_FALSE); i.Exists(); i++)
|
||||||
{
|
{
|
||||||
nsFileSpec possibleTempFile = i.Spec();
|
nsFileSpec possibleTempFile = i.Spec();
|
||||||
char *filename = possibleTempFile.GetLeafName();
|
char *filename = possibleTempFile.GetLeafName();
|
||||||
|
@ -235,7 +236,7 @@ nsMimeXULEmitter::OhTheHumanityCleanupTempFileHack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PR_FREEIF(tDir);
|
delete tmpSpec;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include "nsIMsgComposeService.h"
|
#include "nsIMsgComposeService.h"
|
||||||
#include "nsIMsgCompose.h"
|
#include "nsIMsgCompose.h"
|
||||||
#include "nsMsgI18N.h"
|
#include "nsMsgI18N.h"
|
||||||
|
#include "nsSpecialSystemDirectory.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Header strings...
|
// Header strings...
|
||||||
|
@ -101,38 +102,6 @@ nsMimeNewURI(nsIURI** aInstancePtrResult, const char *aSpec)
|
||||||
//
|
//
|
||||||
#define TPATH_LEN 1024
|
#define TPATH_LEN 1024
|
||||||
|
|
||||||
static char *
|
|
||||||
GetTheTempDirectoryOnTheSystem(void)
|
|
||||||
{
|
|
||||||
char *retPath = (char *)PR_Malloc(TPATH_LEN);
|
|
||||||
if (!retPath)
|
|
||||||
return nsnull;
|
|
||||||
|
|
||||||
retPath[0] = '\0';
|
|
||||||
#ifdef WIN32
|
|
||||||
if (getenv("TEMP"))
|
|
||||||
PL_strncpy(retPath, getenv("TEMP"), TPATH_LEN); // environment variable
|
|
||||||
else if (getenv("TMP"))
|
|
||||||
PL_strncpy(retPath, getenv("TMP"), TPATH_LEN); // How about this environment variable?
|
|
||||||
else
|
|
||||||
GetWindowsDirectory(retPath, TPATH_LEN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
|
||||||
char *tPath = getenv("TMPDIR");
|
|
||||||
if (!tPath)
|
|
||||||
PL_strncpy(retPath, "/tmp/", TPATH_LEN);
|
|
||||||
else
|
|
||||||
PL_strncpy(retPath, tPath, TPATH_LEN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef XP_MAC
|
|
||||||
PL_strncpy(retPath, "", TPATH_LEN);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return retPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create a file spec for the a unique temp file
|
// Create a file spec for the a unique temp file
|
||||||
// on the local machine. Caller must free memory
|
// on the local machine. Caller must free memory
|
||||||
|
@ -141,24 +110,15 @@ nsFileSpec *
|
||||||
nsMsgCreateTempFileSpec(char *tFileName)
|
nsMsgCreateTempFileSpec(char *tFileName)
|
||||||
{
|
{
|
||||||
if ((!tFileName) || (!*tFileName))
|
if ((!tFileName) || (!*tFileName))
|
||||||
tFileName = "nsmail.tmp";
|
tFileName = "nsmime.tmp";
|
||||||
|
|
||||||
// Age old question, where to store temp files....ugh!
|
nsFileSpec *tmpSpec = new nsFileSpec(nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory));
|
||||||
char *tDir = GetTheTempDirectoryOnTheSystem();
|
|
||||||
if (!tDir)
|
|
||||||
return (new nsFileSpec("mozmail.tmp")); // No need to I18N
|
|
||||||
|
|
||||||
nsFileSpec *tmpSpec = new nsFileSpec(tDir);
|
|
||||||
if (!tmpSpec)
|
if (!tmpSpec)
|
||||||
{
|
return nsnull;
|
||||||
PR_FREEIF(tDir);
|
|
||||||
return (new nsFileSpec("mozmail.tmp")); // No need to I18N
|
|
||||||
}
|
|
||||||
|
|
||||||
*tmpSpec += tFileName;
|
*tmpSpec += tFileName;
|
||||||
tmpSpec->MakeUnique();
|
tmpSpec->MakeUnique();
|
||||||
|
|
||||||
PR_FREEIF(tDir);
|
|
||||||
return tmpSpec;
|
return tmpSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче