зеркало из https://github.com/mozilla/gecko-dev.git
fixes bug 129279 "nsIFile unicode/utf8/ascii task"
r=dougt sr=alecf
This commit is contained in:
Родитель
f9171f1b27
Коммит
e554d83626
|
@ -1869,10 +1869,10 @@ nsScriptSecurityManager::SetCanEnableCapability(const char* certificateID,
|
|||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
#ifdef XP_MAC
|
||||
// On Mac, this file will be located in the Essential Files folder
|
||||
systemCertFile->Append("Essential Files");
|
||||
systemCertFile->Append(NS_LITERAL_CSTRING("Essential Files"));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
systemCertFile->Append("systemSignature.jar");
|
||||
systemCertFile->Append(NS_LITERAL_CSTRING("systemSignature.jar"));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIZipReader> systemCertZip;
|
||||
rv = nsComponentManager::CreateInstance(kZipReaderCID, nsnull,
|
||||
|
|
|
@ -99,6 +99,7 @@
|
|||
#include "prio.h"
|
||||
#include "nsInt64.h"
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
@ -109,10 +110,11 @@
|
|||
#include "imgICache.h"
|
||||
|
||||
static char kChromePrefix[] = "chrome://";
|
||||
static char kChromeFileName[] = "chrome.rdf";
|
||||
static char kInstalledChromeFileName[] = "installed-chrome.txt";
|
||||
static char kUseXBLFormsPref[] = "nglayout.debug.enable_xbl_forms";
|
||||
|
||||
#define kChromeFileName NS_LITERAL_CSTRING("chrome.rdf")
|
||||
#define kInstalledChromeFileName NS_LITERAL_CSTRING("installed-chrome.txt")
|
||||
|
||||
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
|
||||
|
@ -1800,9 +1802,8 @@ nsChromeRegistry::SetProviderForPackage(const nsACString& aProvider,
|
|||
|
||||
// Figure out which file we're needing to modify, e.g., is it the install
|
||||
// dir or the profile dir, and get the right datasource.
|
||||
nsDependentCString dataSourceStr(kChromeFileName);
|
||||
nsCOMPtr<nsIRDFDataSource> dataSource;
|
||||
rv = LoadDataSource(dataSourceStr, getter_AddRefs(dataSource), aUseProfile, aProfilePath);
|
||||
rv = LoadDataSource(kChromeFileName, getter_AddRefs(dataSource), aUseProfile, aProfilePath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = nsChromeRegistry::UpdateArc(dataSource, aPackageResource, aSelectionArc, aProviderPackageResource, !aIsAdding);
|
||||
|
@ -2077,10 +2078,9 @@ nsChromeRegistry::IsProviderSetForPackage(const nsACString& aProvider,
|
|||
nsresult rv;
|
||||
// Figure out which file we're needing to modify, e.g., is it the install
|
||||
// dir or the profile dir, and get the right datasource.
|
||||
nsDependentCString dataSourceStr(kChromeFileName);
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> dataSource;
|
||||
rv = LoadDataSource(dataSourceStr, getter_AddRefs(dataSource), aUseProfile, nsnull);
|
||||
rv = LoadDataSource(kChromeFileName, getter_AddRefs(dataSource), aUseProfile, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRDFNode> retVal;
|
||||
|
@ -2166,8 +2166,7 @@ NS_IMETHODIMP nsChromeRegistry::InstallProvider(const nsACString& aProviderType,
|
|||
|
||||
// Load the install data source that we wish to manipulate.
|
||||
nsCOMPtr<nsIRDFDataSource> installSource;
|
||||
nsDependentCString installStr(kChromeFileName);
|
||||
rv = LoadDataSource(installStr, getter_AddRefs(installSource), aUseProfile, nsnull);
|
||||
rv = LoadDataSource(kChromeFileName, getter_AddRefs(installSource), aUseProfile, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ASSERTION(installSource, "failed to get installSource");
|
||||
|
||||
|
@ -2533,8 +2532,7 @@ nsChromeRegistry::UninstallProvider(const nsACString& aProviderType,
|
|||
|
||||
// Instantiate the data source we wish to modify.
|
||||
nsCOMPtr<nsIRDFDataSource> installSource;
|
||||
nsDependentCString installStr(kChromeFileName);
|
||||
rv = LoadDataSource(installStr, getter_AddRefs(installSource), aUseProfile, nsnull);
|
||||
rv = LoadDataSource(kChromeFileName, getter_AddRefs(installSource), aUseProfile, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ASSERTION(installSource, "failed to get installSource");
|
||||
|
||||
|
@ -2605,15 +2603,15 @@ nsChromeRegistry::GetProfileRoot(nsCString& aFileURL)
|
|||
getter_AddRefs(defaultUserChromeFile));
|
||||
if (NS_FAILED(rv))
|
||||
return(rv);
|
||||
defaultUserContentFile->Append("chrome");
|
||||
defaultUserContentFile->Append("userContent.css");
|
||||
defaultUserChromeFile->Append("chrome");
|
||||
defaultUserChromeFile->Append("userChrome.css");
|
||||
defaultUserContentFile->Append(NS_LITERAL_CSTRING("chrome"));
|
||||
defaultUserContentFile->Append(NS_LITERAL_CSTRING("userContent.css"));
|
||||
defaultUserChromeFile->Append(NS_LITERAL_CSTRING("chrome"));
|
||||
defaultUserChromeFile->Append(NS_LITERAL_CSTRING("userChrome.css"));
|
||||
|
||||
// copy along
|
||||
// It aint an error if these files dont exist
|
||||
(void) defaultUserContentFile->CopyTo(userChromeDir, nsnull);
|
||||
(void) defaultUserChromeFile->CopyTo(userChromeDir, nsnull);
|
||||
(void) defaultUserContentFile->CopyTo(userChromeDir, nsCString());
|
||||
(void) defaultUserChromeFile->CopyTo(userChromeDir, nsCString());
|
||||
}
|
||||
}
|
||||
if (NS_FAILED(rv))
|
||||
|
@ -2745,17 +2743,16 @@ nsChromeRegistry::AddToCompositeDataSource(PRBool aUseProfile)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsDependentCString name(kChromeFileName);
|
||||
if (aUseProfile) {
|
||||
// Profiles take precedence. Load them first.
|
||||
nsCOMPtr<nsIRDFDataSource> dataSource;
|
||||
LoadDataSource(name, getter_AddRefs(dataSource), PR_TRUE, nsnull);
|
||||
LoadDataSource(kChromeFileName, getter_AddRefs(dataSource), PR_TRUE, nsnull);
|
||||
mChromeDataSource->AddDataSource(dataSource);
|
||||
}
|
||||
|
||||
// Always load the install dir datasources
|
||||
nsCOMPtr<nsIRDFDataSource> dataSource;
|
||||
LoadDataSource(name, getter_AddRefs(dataSource), PR_FALSE, nsnull);
|
||||
LoadDataSource(kChromeFileName, getter_AddRefs(dataSource), PR_FALSE, nsnull);
|
||||
mChromeDataSource->AddDataSource(dataSource);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -3155,7 +3152,8 @@ nsChromeRegistry::ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength)
|
|||
nsCOMPtr<nsILocalFile> chromeFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = chromeFile->InitWithPath(chromeLocation);
|
||||
// assuming chromeLocation is given in the charset of the current locale
|
||||
rv = chromeFile->InitWithNativePath(nsDependentCString(chromeLocation));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
@ -3218,9 +3216,8 @@ nsChromeRegistry::ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength)
|
|||
}
|
||||
|
||||
mBatchInstallFlushes = PR_FALSE;
|
||||
nsDependentCString dataSourceStr(kChromeFileName);
|
||||
nsCOMPtr<nsIRDFDataSource> dataSource;
|
||||
LoadDataSource(dataSourceStr, getter_AddRefs(dataSource), PR_FALSE, nsnull);
|
||||
LoadDataSource(kChromeFileName, getter_AddRefs(dataSource), PR_FALSE, nsnull);
|
||||
nsCOMPtr<nsIRDFRemoteDataSource> remote(do_QueryInterface(dataSource));
|
||||
remote->Flush();
|
||||
return NS_OK;
|
||||
|
|
28
configure.in
28
configure.in
|
@ -1507,7 +1507,7 @@ dnl ========================================================
|
|||
|
||||
AC_CACHE_CHECK(for usable wchar_t (2 bytes, unsigned),
|
||||
ac_cv_have_usable_wchar,
|
||||
[AC_TRY_RUN([#include <wchar.h>
|
||||
[AC_TRY_RUN([#include <stdlib.h>
|
||||
int main () {
|
||||
return (sizeof(wchar_t) != 2) ||
|
||||
(wchar_t)-1 < (wchar_t) 0 ; } ],
|
||||
|
@ -1531,7 +1531,7 @@ dnl Note that we assume that mac & win32 have short wchar (see nscore.h)
|
|||
|
||||
AC_CACHE_CHECK(for compiler -fshort-wchar option,
|
||||
ac_cv_have_usable_wchar_option,
|
||||
[AC_TRY_RUN([#include <wchar.h>
|
||||
[AC_TRY_RUN([#include <stdlib.h>
|
||||
int main () {
|
||||
return (sizeof(wchar_t) != 2) ||
|
||||
(wchar_t)-1 < (wchar_t) 0 ; } ],
|
||||
|
@ -1548,6 +1548,30 @@ dnl Note that we assume that mac & win32 have short wchar (see nscore.h)
|
|||
AC_LANG_RESTORE
|
||||
fi
|
||||
|
||||
dnl check for wcrtomb/mbrtowc
|
||||
dnl =======================================================================
|
||||
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_CACHE_CHECK(for wcrtomb,
|
||||
ac_cv_have_wcrtomb,
|
||||
[AC_TRY_LINK([#include <wchar.h>],
|
||||
[mbstate_t ps={0};wcrtomb(0,'f',&ps);],
|
||||
ac_cv_have_wcrtomb="yes",
|
||||
ac_cv_have_wcrtomb="no")])
|
||||
if test "$ac_cv_have_wcrtomb" = "yes"; then
|
||||
AC_DEFINE(HAVE_WCRTOMB)
|
||||
fi
|
||||
AC_CACHE_CHECK(for mbrtowc,
|
||||
ac_cv_have_mbrtowc,
|
||||
[AC_TRY_LINK([#include <wchar.h>],
|
||||
[mbstate_t ps={0};mbrtowc(0,0,0,&ps);],
|
||||
ac_cv_have_mbrtowc="yes",
|
||||
ac_cv_have_mbrtowc="no")])
|
||||
if test "$ac_cv_have_mbrtowc" = "yes"; then
|
||||
AC_DEFINE(HAVE_MBRTOWC)
|
||||
fi
|
||||
AC_LANG_C
|
||||
|
||||
dnl Checks for header files.
|
||||
dnl ========================================================
|
||||
AC_HEADER_DIRENT
|
||||
|
|
|
@ -2182,19 +2182,18 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission,
|
|||
&rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = file->InitWithUnicodePath(value.get());
|
||||
rv = file->InitWithPath(NS_ConvertUCS2toUTF8(value));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
||||
//
|
||||
// Get the leaf path name (to be submitted as the value)
|
||||
//
|
||||
PRUnichar* leafNameChars = nsnull;
|
||||
rv = file->GetUnicodeLeafName(&leafNameChars);
|
||||
nsCAutoString leafNameChars;
|
||||
rv = file->GetLeafName(leafNameChars);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (leafNameChars) {
|
||||
nsAutoString filename;
|
||||
filename.Adopt(leafNameChars);
|
||||
if (!leafNameChars.IsEmpty()) {
|
||||
NS_ConvertUTF8toUCS2 filename(leafNameChars);
|
||||
|
||||
PRBool acceptsFiles = PR_FALSE;
|
||||
aFormSubmission->AcceptsFiles(&acceptsFiles);
|
||||
|
|
|
@ -5069,8 +5069,8 @@ nsXULDocument::StartFastLoad()
|
|||
rv = NS_GetSpecialDirectory(NS_APP_CHROME_DIR, getter_AddRefs(chromeDir));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsXPIDLCString chromePath;
|
||||
rv = chromeDir->GetPath(getter_Copies(chromePath));
|
||||
nsCAutoString chromePath;
|
||||
rv = chromeDir->GetPath(chromePath);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
@ -5145,7 +5145,7 @@ nsXULDocument::StartFastLoad()
|
|||
rv = objectInput->ReadStringZ(
|
||||
getter_Copies(fileChromePath));
|
||||
if (NS_SUCCEEDED(rv) &&
|
||||
nsCRT::strcmp(fileChromePath, chromePath) != 0) {
|
||||
!fileChromePath.Equals(chromePath)) {
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
|
@ -5165,7 +5165,7 @@ nsXULDocument::StartFastLoad()
|
|||
xio->mInputStream = nsnull;
|
||||
|
||||
#ifdef DEBUG
|
||||
file->MoveTo(nsnull, "Invalid.mfasl");
|
||||
file->MoveTo(nsnull, NS_LITERAL_CSTRING("Invalid.mfasl"));
|
||||
#else
|
||||
file->Remove(PR_FALSE);
|
||||
#endif
|
||||
|
@ -5185,7 +5185,7 @@ nsXULDocument::StartFastLoad()
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = objectOutput->Write32(XUL_FASTLOAD_FILE_VERSION);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = objectOutput->WriteStringZ(chromePath);
|
||||
rv = objectOutput->WriteStringZ(chromePath.get());
|
||||
}
|
||||
|
||||
// Remove here even though some errors above will lead to a FastLoad
|
||||
|
@ -5308,7 +5308,7 @@ nsXULDocument::AbortFastLoads()
|
|||
// Now rename or remove the file.
|
||||
if (file) {
|
||||
#ifdef DEBUG
|
||||
file->MoveTo(nsnull, "Aborted.mfasl");
|
||||
file->MoveTo(nsnull, NS_LITERAL_CSTRING("Aborted.mfasl"));
|
||||
#else
|
||||
file->Remove(PR_FALSE);
|
||||
#endif
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsEscape.h"
|
||||
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIPlatformCharset.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
|
@ -357,7 +356,7 @@ nsresult nsDefaultURIFixup::ConvertFileToStringURI(nsString& aIn,
|
|||
// platform.
|
||||
|
||||
nsCOMPtr<nsILocalFile> filePath;
|
||||
nsCAutoString file;
|
||||
nsresult rv;
|
||||
|
||||
// this is not the real fix but a temporary fix
|
||||
// in order to really fix the problem, we need to change the
|
||||
|
@ -380,14 +379,13 @@ nsresult nsDefaultURIFixup::ConvertFileToStringURI(nsString& aIn,
|
|||
// all the Unicode data come in is correctly converted.
|
||||
if (PossiblyByteExpandedFileName(aIn)) {
|
||||
// removes high byte
|
||||
file.AssignWithConversion(aIn);
|
||||
rv = NS_NewNativeLocalFile(NS_LossyConvertUCS2toASCII(aIn), PR_FALSE, getter_AddRefs(filePath));
|
||||
}
|
||||
else {
|
||||
// converts from Unicode to FS Charset
|
||||
ConvertStringURIToFileCharset(aIn, file);
|
||||
// input is unicode
|
||||
rv = NS_NewLocalFile(NS_ConvertUCS2toUTF8(aIn), PR_FALSE, getter_AddRefs(filePath));
|
||||
}
|
||||
|
||||
nsresult rv = NS_NewLocalFile(file.get(), PR_FALSE, getter_AddRefs(filePath));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
NS_GetURLSpecFromFile(filePath, aOut);
|
||||
|
@ -449,37 +447,6 @@ const char * nsDefaultURIFixup::GetCharsetForUrlBar()
|
|||
return charset;
|
||||
}
|
||||
|
||||
nsresult nsDefaultURIFixup::ConvertStringURIToFileCharset(nsString& aIn,
|
||||
nsCString& aOut)
|
||||
{
|
||||
aOut = "";
|
||||
// We probably should cache ccm here.
|
||||
// get a charset converter from the manager
|
||||
nsCOMPtr<nsICharsetConverterManager> ccm(do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID));
|
||||
NS_ENSURE_TRUE(ccm, NS_ERROR_FAILURE);
|
||||
|
||||
// for file url, we need to convert the nsString to the file system
|
||||
// charset before we pass to NS_NewURI
|
||||
NS_ConvertASCIItoUCS2 fsCharset(GetFileSystemCharset());
|
||||
nsCOMPtr<nsIUnicodeEncoder> fsEncoder;
|
||||
NS_ENSURE_SUCCESS(ccm->GetUnicodeEncoder(&fsCharset,
|
||||
getter_AddRefs(fsEncoder)), NS_ERROR_FAILURE);
|
||||
|
||||
PRInt32 bufLen = 0;
|
||||
NS_ENSURE_SUCCESS(fsEncoder->GetMaxLength(aIn.get(), aIn.Length(),
|
||||
&bufLen), NS_ERROR_FAILURE);
|
||||
aOut.SetCapacity(bufLen+1);
|
||||
PRInt32 srclen = aIn.Length();
|
||||
NS_ENSURE_SUCCESS(fsEncoder->Convert(aIn.get(), &srclen,
|
||||
(char*)aOut.get(), &bufLen), NS_ERROR_FAILURE);
|
||||
|
||||
((char*)aOut.get())[bufLen]='\0';
|
||||
aOut.SetLength(bufLen);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsDefaultURIFixup::KeywordURIFixup(const PRUnichar* aStringURI,
|
||||
nsIURI** aURI)
|
||||
{
|
||||
|
|
|
@ -46,7 +46,6 @@ private:
|
|||
/* additional members */
|
||||
nsresult FileURIFixup(const PRUnichar* aStringURI, nsIURI** aURI);
|
||||
nsresult ConvertFileToStringURI(nsString& aIn, nsCString& aOut);
|
||||
nsresult ConvertStringURIToFileCharset(nsString& aIn, nsCString& aOut);
|
||||
nsresult KeywordURIFixup(const PRUnichar* aStringURI, nsIURI** aURI);
|
||||
PRBool PossiblyByteExpandedFileName(nsString& aIn);
|
||||
PRBool MakeAlternateURI(nsIURI *aURI);
|
||||
|
|
|
@ -667,10 +667,10 @@ LRESULT CMozillaBrowser::OnSaveAs(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL
|
|||
_makepath(szDataPath, drive, dir, szDataFile, "");
|
||||
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
NS_NewLocalFile(T2A(szFile), TRUE, getter_AddRefs(file));
|
||||
NS_NewNativeLocalFile(nsDependentCString(T2A(szFile)), TRUE, getter_AddRefs(file));
|
||||
|
||||
nsCOMPtr<nsILocalFile> dataPath;
|
||||
NS_NewLocalFile(szDataPath, TRUE, getter_AddRefs(dataPath));
|
||||
NS_NewNativeLocalFile(nsDependentCString(szDataPath), TRUE, getter_AddRefs(dataPath));
|
||||
|
||||
persist->SaveDocument(nsnull, file, dataPath, nsnull, 0, 0);
|
||||
}
|
||||
|
@ -987,7 +987,7 @@ HRESULT CMozillaBrowser::Initialize()
|
|||
// Create an object to represent the path
|
||||
nsCOMPtr<nsILocalFile> binDir;
|
||||
USES_CONVERSION;
|
||||
NS_NewLocalFile(T2A(szBinDirPath), TRUE, getter_AddRefs(binDir));
|
||||
NS_NewNativeLocalFile(nsDependentCString(T2A(szBinDirPath)), TRUE, getter_AddRefs(binDir));
|
||||
rv = NS_InitEmbedding(binDir, provider);
|
||||
|
||||
// Load preferences service
|
||||
|
|
|
@ -353,7 +353,7 @@ EmbedPrivate::PushStartup(void)
|
|||
nsCOMPtr<nsILocalFile> binDir;
|
||||
|
||||
if (sCompPath) {
|
||||
rv = NS_NewLocalFile(sCompPath, 1, getter_AddRefs(binDir));
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(sCompPath), 1, getter_AddRefs(binDir));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
}
|
||||
|
@ -788,7 +788,7 @@ EmbedPrivate::StartupProfile(void)
|
|||
PRBool exists = PR_FALSE;
|
||||
PRBool isDir = PR_FALSE;
|
||||
profileDir = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
rv = profileDir->InitWithPath(sProfileDir);
|
||||
rv = profileDir->InitWithNativePath(nsDependentCString(sProfileDir));
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
profileDir->Exists(&exists);
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "ApplIDs.h"
|
||||
|
||||
static char* GetResCString(PRInt32 stringIndex, Str255& buf);
|
||||
static const nsACString &GetResCString(PRInt32 stringIndex, Str255& buf);
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -84,13 +84,13 @@ CAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile
|
|||
{
|
||||
rv = GetProductDirectory(getter_AddRefs(localFile));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = localFile->Append(GetResCString(str_AppRegistryName, strBuf));
|
||||
rv = localFile->AppendNative(GetResCString(str_AppRegistryName, strBuf));
|
||||
}
|
||||
else if (nsCRT::strcmp(prop, NS_APP_DEFAULTS_50_DIR) == 0)
|
||||
{
|
||||
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = localFile->AppendRelativePath(GetResCString(str_DefaultsDirName, strBuf));
|
||||
rv = localFile->AppendRelativeNativePath(GetResCString(str_DefaultsDirName, strBuf));
|
||||
}
|
||||
else if (nsCRT::strcmp(prop, NS_APP_PREF_DEFAULTS_50_DIR) == 0)
|
||||
{
|
||||
|
@ -211,7 +211,7 @@ NS_METHOD CAppFileLocationProvider::GetProductDirectory(nsILocalFile **aLocalFil
|
|||
rv = directoryService->Get(prop, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = localDir->AppendRelativePath(mProductDirName);
|
||||
rv = localDir->AppendRelativeNativePath(nsDependentCString(mProductDirName));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = localDir->Exists(&exists);
|
||||
if (NS_SUCCEEDED(rv) && !exists)
|
||||
|
@ -259,12 +259,12 @@ NS_METHOD CAppFileLocationProvider::GetDefaultUserProfileRoot(nsILocalFile **aLo
|
|||
// Static Routines
|
||||
//****************************************************************************************
|
||||
|
||||
static char* GetResCString(PRInt32 stringIndex, Str255& buf)
|
||||
static const nsACString &GetResCString(PRInt32 stringIndex, Str255& buf)
|
||||
{
|
||||
GetIndString(buf, STRx_FileLocProviderStrings, stringIndex);
|
||||
if (!buf[0]) {
|
||||
NS_ASSERTION(PR_FALSE, "Directory name resource is missing.");
|
||||
return nsnull;
|
||||
return nsCString();
|
||||
}
|
||||
|
||||
// Because of different availability of Pascal to C conversion routines
|
||||
|
@ -273,5 +273,5 @@ static char* GetResCString(PRInt32 stringIndex, Str255& buf)
|
|||
memmove(buf, buf + 1, len);
|
||||
buf[len] = '\0';
|
||||
|
||||
return (char *)buf;
|
||||
return nsDependentCString((char *)buf);
|
||||
}
|
||||
|
|
|
@ -415,16 +415,13 @@ nsresult CProfileManager::OpenAppRegistry(nsIRegistry **aRegistry)
|
|||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFile> regFile;
|
||||
nsXPIDLCString regFilePath;
|
||||
|
||||
rv = NS_GetSpecialDirectory(NS_APP_APPLICATION_REGISTRY_FILE, getter_AddRefs(regFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = regFile->GetPath(getter_Copies(regFilePath));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIRegistry> registry(do_CreateInstance(NS_REGISTRY_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = registry->Open(regFilePath);
|
||||
rv = registry->Open(regFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*aRegistry = registry;
|
||||
|
|
|
@ -302,7 +302,7 @@ nsHelperAppDialog.prototype = {
|
|||
var parentObject = fileObject.parent;
|
||||
if (parentObject)
|
||||
{
|
||||
pathString = parentObject.unicodePath;
|
||||
pathString = parentObject.path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -329,10 +329,10 @@ nsHelperAppDialog.prototype = {
|
|||
this.updateApplicationName(applicationDescription);
|
||||
this.givenDefaultApp = true;
|
||||
}
|
||||
else if (this.chosenApp && this.chosenApp.unicodePath)
|
||||
else if (this.chosenApp && this.chosenApp.path)
|
||||
{
|
||||
// If a user-chosen application, show its path.
|
||||
this.updateApplicationName(this.chosenApp.unicodePath);
|
||||
this.updateApplicationName(this.chosenApp.path);
|
||||
this.choseApp = true;
|
||||
}
|
||||
else
|
||||
|
@ -401,7 +401,7 @@ nsHelperAppDialog.prototype = {
|
|||
{
|
||||
// only enable the OK button if we have a default app to use or if
|
||||
// the user chose an app....
|
||||
if ((this.choseApp && this.chosenApp.unicodePath) || this.givenDefaultApp)
|
||||
if ((this.choseApp && this.chosenApp.path) || this.givenDefaultApp)
|
||||
ok = true;
|
||||
}
|
||||
|
||||
|
@ -475,7 +475,7 @@ nsHelperAppDialog.prototype = {
|
|||
this.chosenApp = fp.file;
|
||||
// Update dialog.
|
||||
|
||||
this.updateApplicationName(this.chosenApp.unicodePath);
|
||||
this.updateApplicationName(this.chosenApp.path);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -375,7 +375,7 @@ nsProgressDialog.prototype = {
|
|||
}
|
||||
} else {
|
||||
// Target is the destination file.
|
||||
this.setValue( "target", this.target.unicodePath );
|
||||
this.setValue( "target", this.target.path );
|
||||
}
|
||||
|
||||
// Set source field.
|
||||
|
@ -476,7 +476,7 @@ nsProgressDialog.prototype = {
|
|||
|
||||
// Get filename from target file.
|
||||
fileName: function() {
|
||||
return this.target ? this.target.unicodeLeafName : "";
|
||||
return this.target ? this.target.leafName : "";
|
||||
},
|
||||
|
||||
// Set the dialog title.
|
||||
|
|
|
@ -320,7 +320,7 @@ function loadDialog()
|
|||
dialog.timeLeft.setAttribute("value", formatSeconds( 0 ));
|
||||
|
||||
dialog.location.setAttribute("value", sourceUrl.spec );
|
||||
dialog.fileName.setAttribute( "value", targetFile.unicodePath );
|
||||
dialog.fileName.setAttribute( "value", targetFile.path );
|
||||
|
||||
var prefs = Components.classes[prefContractID].getService(Components.interfaces.nsIPrefBranch);
|
||||
if (prefs)
|
||||
|
@ -403,7 +403,7 @@ function onLoad() {
|
|||
const lfContractID = "@mozilla.org/file/local;1";
|
||||
const lfIID = Components.interfaces.nsILocalFile;
|
||||
filesFolder = Components .classes[lfContractID].createInstance(lfIID);
|
||||
filesFolder.initWithUnicodePath(persistArgs.target.unicodePath);
|
||||
filesFolder.initWithPath(persistArgs.target.path);
|
||||
|
||||
var nameWithoutExtension = filesFolder.leafName;
|
||||
nameWithoutExtension = nameWithoutExtension.substring(0, nameWithoutExtension.lastIndexOf("."));
|
||||
|
|
|
@ -839,15 +839,15 @@ nsresult nsWebBrowserPersist::SendErrorStatusChange(
|
|||
nsAutoString path;
|
||||
if (file)
|
||||
{
|
||||
nsXPIDLString filePath;
|
||||
file->GetUnicodePath(getter_Copies(filePath));
|
||||
path = filePath;
|
||||
nsCAutoString filePath;
|
||||
file->GetPath(filePath);
|
||||
path = NS_ConvertUTF8toUCS2(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsCAutoString fileurl;
|
||||
aURI->GetSpec(fileurl);
|
||||
path.Assign(NS_ConvertUTF8toUCS2(fileurl));
|
||||
path = NS_ConvertUTF8toUCS2(fileurl);
|
||||
}
|
||||
|
||||
nsAutoString msgId;
|
||||
|
@ -1263,13 +1263,13 @@ nsresult nsWebBrowserPersist::SaveDocumentInternal(
|
|||
break;
|
||||
}
|
||||
|
||||
nsXPIDLCString dirName;
|
||||
dataDirParent->GetLeafName(getter_Copies(dirName));
|
||||
nsCAutoString dirName;
|
||||
dataDirParent->GetNativeLeafName(dirName);
|
||||
|
||||
nsCAutoString newRelativePathToData;
|
||||
newRelativePathToData = dirName.get();
|
||||
newRelativePathToData.Append("/");
|
||||
newRelativePathToData.Append(relativePathToData);
|
||||
newRelativePathToData = dirName
|
||||
+ NS_LITERAL_CSTRING("/")
|
||||
+ relativePathToData;
|
||||
relativePathToData = newRelativePathToData;
|
||||
|
||||
nsCOMPtr<nsIFile> newDataDirParent;
|
||||
|
@ -1283,7 +1283,7 @@ nsresult nsWebBrowserPersist::SaveDocumentInternal(
|
|||
nsCOMPtr<nsIURL> pathToBaseURL(do_QueryInterface(aFile));
|
||||
if (pathToBaseURL)
|
||||
{
|
||||
nsXPIDLCString relativePath; // nsACString
|
||||
nsCAutoString relativePath; // nsACString
|
||||
if (NS_SUCCEEDED(pathToBaseURL->GetRelativeSpec(aDataPath, relativePath)))
|
||||
{
|
||||
mCurrentDataPathIsRelative = PR_TRUE;
|
||||
|
@ -1532,7 +1532,7 @@ nsWebBrowserPersist::CalculateAndAppendFileExt(nsIURI *aURI, nsIChannel *aChanne
|
|||
|
||||
if (localFile)
|
||||
{
|
||||
localFile->SetLeafName(newFileName.get());
|
||||
localFile->SetNativeLeafName(newFileName);
|
||||
|
||||
// Resync the URI with the file after the extension has been appended
|
||||
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(aURI, &rv);
|
||||
|
|
|
@ -693,12 +693,12 @@ void CBrowserView::OnFileSaveAs()
|
|||
if(persist)
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
NS_NewLocalFile(T2A(pStrFullPath), TRUE, getter_AddRefs(file));
|
||||
NS_NewNativeLocalFile(nsDependentCString(T2A(pStrFullPath)), TRUE, getter_AddRefs(file));
|
||||
|
||||
nsCOMPtr<nsILocalFile> dataPath;
|
||||
if (pStrDataPath)
|
||||
{
|
||||
NS_NewLocalFile(pStrDataPath, TRUE, getter_AddRefs(dataPath));
|
||||
NS_NewNativeLocalFile(nsDependentCString(pStrDataPath), TRUE, getter_AddRefs(dataPath));
|
||||
}
|
||||
|
||||
if(bSaveAll)
|
||||
|
@ -839,7 +839,7 @@ void CBrowserView::OnSaveLinkAs()
|
|||
if(persist)
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
NS_NewLocalFile(strFullPath.GetBuffer(0), TRUE, getter_AddRefs(file));
|
||||
NS_NewNativeLocalFile(nsDependentCString(strFullPath.GetBuffer(0)), TRUE, getter_AddRefs(file));
|
||||
persist->SaveURI(linkURI, nsnull, file);
|
||||
}
|
||||
}
|
||||
|
@ -885,7 +885,7 @@ void CBrowserView::OnSaveImageAs()
|
|||
if(persist)
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
NS_NewLocalFile(strFullPath.GetBuffer(0), TRUE, getter_AddRefs(file));
|
||||
NS_NewNativeLocalFile(nsDependentCString(strFullPath.GetBuffer(0)), TRUE, getter_AddRefs(file));
|
||||
persist->SaveURI(linkURI, nsnull, file);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ FILE * CMostRecentUrls::GetFD(const char * aMode)
|
|||
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(file));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsILocalFile> local_file(do_QueryInterface(file));
|
||||
local_file->Append("urls.txt");
|
||||
local_file->Append(NS_LITERAL_CSTRING("urls.txt"));
|
||||
local_file->OpenANSIFileDesc(aMode, &fd);
|
||||
}
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ NS_IMETHODIMP CHelperAppLauncherDialog::Show(nsIHelperAppLauncher *aLauncher,
|
|||
m_FileName = dlg.m_OpenWithAppName;
|
||||
|
||||
nsCOMPtr<nsILocalFile> openWith;
|
||||
nsresult rv = NS_NewLocalFile(m_FileName, PR_FALSE, getter_AddRefs(openWith));
|
||||
nsresult rv = NS_NewNativeLocalFile(nsDependentCString(m_FileName), PR_FALSE, getter_AddRefs(openWith));
|
||||
if (NS_FAILED(rv))
|
||||
return aLauncher->LaunchWithApplication(nsnull, PR_FALSE);
|
||||
else
|
||||
|
@ -279,7 +279,7 @@ NS_IMETHODIMP CHelperAppLauncherDialog::PromptForSaveToFile(nsISupports *aWindow
|
|||
{
|
||||
m_FileName = cf.GetPathName(); // Will be like: c:\tmp\junk.exe
|
||||
|
||||
return NS_NewLocalFile(m_FileName, PR_FALSE, _retval);
|
||||
return NS_NewNativeLocalFile(nsDependentCString(m_FileName), PR_FALSE, _retval);
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -36,16 +36,16 @@
|
|||
|
||||
// WARNING: These hard coded names need to go away. They need to
|
||||
// come from localizable resources
|
||||
#define APP_REGISTRY_NAME "registry.dat"
|
||||
#define APP_REGISTRY_NAME NS_LITERAL_CSTRING("registry.dat")
|
||||
|
||||
#define PROFILE_ROOT_DIR_NAME "Profiles"
|
||||
#define DEFAULTS_DIR_NAME "defaults"
|
||||
#define DEFAULTS_PREF_DIR_NAME "pref"
|
||||
#define DEFAULTS_PROFILE_DIR_NAME "profile"
|
||||
#define RES_DIR_NAME "res"
|
||||
#define CHROME_DIR_NAME "chrome"
|
||||
#define PLUGINS_DIR_NAME "plugins"
|
||||
#define SEARCH_DIR_NAME "searchplugins"
|
||||
#define PROFILE_ROOT_DIR_NAME NS_LITERAL_CSTRING("Profiles")
|
||||
#define DEFAULTS_DIR_NAME NS_LITERAL_CSTRING("defaults")
|
||||
#define DEFAULTS_PREF_DIR_NAME NS_LITERAL_CSTRING("pref")
|
||||
#define DEFAULTS_PROFILE_DIR_NAME NS_LITERAL_CSTRING("profile")
|
||||
#define RES_DIR_NAME NS_LITERAL_CSTRING("res")
|
||||
#define CHROME_DIR_NAME NS_LITERAL_CSTRING("chrome")
|
||||
#define PLUGINS_DIR_NAME NS_LITERAL_CSTRING("plugins")
|
||||
#define SEARCH_DIR_NAME NS_LITERAL_CSTRING("searchplugins")
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -221,7 +221,7 @@ NS_METHOD winEmbedFileLocProvider::GetProductDirectory(nsILocalFile **aLocalFile
|
|||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = localDir->AppendRelativePath(mProductDirName);
|
||||
rv = localDir->AppendRelativeNativePath(nsDependentCString(mProductDirName));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = localDir->Exists(&exists);
|
||||
if (NS_SUCCEEDED(rv) && !exists)
|
||||
|
|
|
@ -427,12 +427,12 @@ void SaveWebPage(nsIWebBrowser *aWebBrowser)
|
|||
nsCOMPtr<nsIWebBrowserPersist> persist(do_QueryInterface(aWebBrowser));
|
||||
|
||||
nsCOMPtr<nsILocalFile> file;
|
||||
NS_NewLocalFile(szFile, TRUE, getter_AddRefs(file));
|
||||
NS_NewNativeLocalFile(nsDependentCString(szFile), TRUE, getter_AddRefs(file));
|
||||
|
||||
nsCOMPtr<nsILocalFile> dataPath;
|
||||
if (pszDataPath)
|
||||
{
|
||||
NS_NewLocalFile(pszDataPath, TRUE, getter_AddRefs(dataPath));
|
||||
NS_NewNativeLocalFile(nsDependentCString(pszDataPath), TRUE, getter_AddRefs(dataPath));
|
||||
}
|
||||
|
||||
persist->SaveDocument(nsnull, file, dataPath, nsnull, 0, 0);
|
||||
|
|
|
@ -212,7 +212,7 @@ COOKIE_DeletePersistentUserData(void)
|
|||
nsCOMPtr<nsIFile> cookiesFile;
|
||||
res = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(cookiesFile));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = cookiesFile->Append(kCookiesFileName);
|
||||
res = cookiesFile->AppendNative(nsDependentCString(kCookiesFileName));
|
||||
if (NS_SUCCEEDED(res))
|
||||
(void) cookiesFile->Remove(PR_FALSE);
|
||||
}
|
||||
|
|
|
@ -684,7 +684,7 @@ PERMISSION_DeletePersistentUserData(void)
|
|||
nsCOMPtr<nsIFile> cookiesPermFile;
|
||||
res = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(cookiesPermFile));
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
res = cookiesPermFile->Append(kCookiesPermFileName);
|
||||
res = cookiesPermFile->AppendNative(nsDependentCString(kCookiesPermFileName));
|
||||
if (NS_SUCCEEDED(res))
|
||||
(void) cookiesPermFile->Remove(PR_FALSE);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "nsIStringBundle.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "prmem.h"
|
||||
|
||||
|
@ -128,11 +129,7 @@ CKutil_ProfileDirectory(nsFileSpec& dirSpec) {
|
|||
|
||||
// TODO: When the calling code can take an nsIFile,
|
||||
// this conversion to nsFileSpec can be avoided.
|
||||
nsXPIDLCString pathBuf;
|
||||
aFile->GetPath(getter_Copies(pathBuf));
|
||||
res = NS_NewFileSpec(getter_AddRefs(tempSpec));
|
||||
if (NS_FAILED(res)) return res;
|
||||
res = tempSpec->SetNativePath(pathBuf);
|
||||
res = NS_NewFileSpecFromIFile(aFile, getter_AddRefs(tempSpec));
|
||||
if (NS_FAILED(res)) return res;
|
||||
res = tempSpec->GetFileSpec(&dirSpec);
|
||||
|
||||
|
|
|
@ -171,9 +171,9 @@ inFileSearch::GetStringResultAt(PRInt32 aIndex, nsAString& _retval)
|
|||
}
|
||||
|
||||
if (file) {
|
||||
nsXPIDLCString temp;
|
||||
mLastResult->GetPath(getter_Copies(temp));
|
||||
_retval = NS_ConvertASCIItoUCS2(temp);
|
||||
nsCAutoString temp;
|
||||
mLastResult->GetPath(temp);
|
||||
_retval = NS_ConvertUTF8toUCS2(temp);
|
||||
if (mReturnRelativePaths)
|
||||
MakePathRelative(_retval);
|
||||
} else {
|
||||
|
@ -543,11 +543,10 @@ inFileSearch::GetNextDirectory(nsISimpleEnumerator* aEnum)
|
|||
PRBool
|
||||
inFileSearch::MatchFile(nsIFile* aFile)
|
||||
{
|
||||
char* fileName;
|
||||
aFile->GetLeafName(&fileName);
|
||||
nsCAutoString fileName;
|
||||
aFile->GetLeafName(fileName);
|
||||
|
||||
nsAutoString temp;
|
||||
temp.AssignWithConversion(fileName);
|
||||
NS_ConvertUTF8toUCS2 temp(fileName);
|
||||
|
||||
PRUnichar* fileNameUnicode = ToNewUnicode(temp);
|
||||
|
||||
|
@ -558,6 +557,7 @@ inFileSearch::MatchFile(nsIFile* aFile)
|
|||
if (match) return PR_TRUE;
|
||||
}
|
||||
|
||||
// XXX are we leaking fileNameUnicode?
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
@ -610,10 +610,9 @@ inFileSearch::MakePathRelative(nsAString& aPath)
|
|||
{
|
||||
|
||||
// get an nsAutoString version of the search path
|
||||
char* temp;
|
||||
mSearchPath->GetPath(&temp);
|
||||
nsAutoString searchPath;
|
||||
searchPath.AssignWithConversion(temp);
|
||||
nsCAutoString temp;
|
||||
mSearchPath->GetPath(temp);
|
||||
NS_ConvertUTF8toUCS2 searchPath(temp);
|
||||
|
||||
nsAutoString result;
|
||||
PRUint32 len = searchPath.Length();
|
||||
|
|
|
@ -512,7 +512,7 @@ BoxModelViewer.prototype =
|
|||
var encoder = XPCU.createInstance("@mozilla.org/inspector/png-encoder;1", "inIPNGEncoder");
|
||||
var path = FilePickerUtils.pickFile("Save Image as PNG", "", ["filterAll"], "Save");
|
||||
if (path)
|
||||
encoder.writePNG(this.mBitmap, path.unicodePath, 24);
|
||||
encoder.writePNG(this.mBitmap, path.path, 24);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -445,7 +445,7 @@ nsresult nsAutoConfig::readOfflineFile()
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
failoverFile->Append("failover.jsc");
|
||||
failoverFile->Append(NS_LITERAL_CSTRING("failover.jsc"));
|
||||
rv = evaluateLocalFile(failoverFile);
|
||||
if (NS_FAILED(rv))
|
||||
NS_WARNING("Couldn't open failover.jsc, going back to default prefs");
|
||||
|
@ -491,7 +491,7 @@ nsresult nsAutoConfig::writeFailoverFile()
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
failoverFile->Append("failover.jsc");
|
||||
failoverFile->Append(NS_LITERAL_CSTRING("failover.jsc"));
|
||||
|
||||
rv = NS_NewLocalFileOutputStream(getter_AddRefs(outStr), failoverFile);
|
||||
if (NS_FAILED(rv))
|
||||
|
|
|
@ -221,18 +221,18 @@ nsresult nsReadConfig::openAndEvaluateJSFile(const char *aFileName,
|
|||
return rv;
|
||||
|
||||
#ifdef XP_MAC
|
||||
jsFile->Append("Essential Files");
|
||||
jsFile->Append(NS_LITERAL_CSTRING("Essential Files"));
|
||||
#endif
|
||||
} else {
|
||||
rv = NS_GetSpecialDirectory(NS_APP_DEFAULTS_50_DIR,
|
||||
getter_AddRefs(jsFile));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = jsFile->Append("autoconfig");
|
||||
rv = jsFile->Append(NS_LITERAL_CSTRING("autoconfig"));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
rv = jsFile->Append(aFileName);
|
||||
rv = jsFile->Append(nsDependentCString(aFileName));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
@ -259,9 +259,9 @@ nsresult nsReadConfig::openAndEvaluateJSFile(const char *aFileName,
|
|||
for (PRUint32 i = 0; i < amt; i++)
|
||||
buf[i] -= obscure_value;
|
||||
}
|
||||
nsXPIDLCString path;
|
||||
nsCAutoString path;
|
||||
|
||||
jsFile->GetPath(getter_Copies(path));
|
||||
jsFile->GetNativePath(path);
|
||||
nsCAutoString fileURL;
|
||||
fileURL = NS_LITERAL_CSTRING("file:///") + path;
|
||||
rv = EvaluateAdminConfigScript(buf, amt, fileURL.get(),
|
||||
|
|
|
@ -105,7 +105,7 @@ function futils_nosepicker(initialPath, typeList, attribs)
|
|||
{
|
||||
localFile =
|
||||
classes[LOCALFILE_CTRID].createInstance(nsILocalFile);
|
||||
localFile.initWithUnicodePath(initialPath);
|
||||
localFile.initWithPath(initialPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -224,7 +224,7 @@ function LocalFile(file, mode, perms, tmp)
|
|||
if (typeof file == "string")
|
||||
{
|
||||
this.localFile = classes[LOCALFILE_CTRID].createInstance(nsILocalFile);
|
||||
this.localFile.initWithUnicodePath(file);
|
||||
this.localFile.initWithPath(file);
|
||||
}
|
||||
else if (file instanceof nsILocalFile)
|
||||
{
|
||||
|
|
|
@ -345,7 +345,7 @@ function getURLSpecFromFile (file)
|
|||
{
|
||||
var fileObj =
|
||||
Components.classes[LOCALFILE_CTRID].createInstance(nsILocalFile);
|
||||
fileObj.initWithUnicodePath(file);
|
||||
fileObj.initWithPath(file);
|
||||
file = fileObj;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDocument.h"
|
||||
|
@ -1280,20 +1281,18 @@ PUBLIC nsresult Wallet_ProfileDirectory(nsFileSpec& dirSpec) {
|
|||
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIFile> aFile;
|
||||
nsXPIDLCString pathBuf;
|
||||
nsCAutoString pathBuf;
|
||||
nsCOMPtr<nsIFileSpec> tempSpec;
|
||||
|
||||
res = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(aFile));
|
||||
if (NS_FAILED(res)) return res;
|
||||
res = aFile->GetPath(getter_Copies(pathBuf));
|
||||
|
||||
res = NS_NewFileSpecFromIFile(aFile, getter_AddRefs(tempSpec));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// TODO: Change the function to return an nsIFile
|
||||
// and not do this conversion
|
||||
res = NS_NewFileSpec(getter_AddRefs(tempSpec));
|
||||
if (NS_FAILED(res)) return res;
|
||||
res = tempSpec->SetNativePath(pathBuf);
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
res = tempSpec->GetFileSpec(&dirSpec);
|
||||
|
||||
return res;
|
||||
|
@ -1303,22 +1302,20 @@ PUBLIC nsresult Wallet_DefaultsDirectory(nsFileSpec& dirSpec) {
|
|||
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIFile> aFile;
|
||||
nsXPIDLCString pathBuf;
|
||||
nsCAutoString pathBuf;
|
||||
nsCOMPtr<nsIFileSpec> tempSpec;
|
||||
|
||||
res = NS_GetSpecialDirectory(NS_APP_DEFAULTS_50_DIR, getter_AddRefs(aFile));
|
||||
if (NS_FAILED(res)) return res;
|
||||
res = aFile->Append("wallet");
|
||||
res = aFile->Append(NS_LITERAL_CSTRING("wallet"));
|
||||
if (NS_FAILED(res)) return res;
|
||||
res = aFile->GetPath(getter_Copies(pathBuf));
|
||||
|
||||
res = NS_NewFileSpecFromIFile(aFile, getter_AddRefs(tempSpec));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// TODO: Change the function to return an nsIFile
|
||||
// and not do this conversion
|
||||
res = NS_NewFileSpec(getter_AddRefs(tempSpec));
|
||||
if (NS_FAILED(res)) return res;
|
||||
res = tempSpec->SetNativePath(pathBuf);
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
res = tempSpec->GetFileSpec(&dirSpec);
|
||||
|
||||
return res;
|
||||
|
|
|
@ -1208,7 +1208,7 @@ NS_IMETHODIMP mozXMLTermSession::ExportHTML(const PRUnichar* aFilename,
|
|||
XMLT_LOG(mozXMLTermSession::ExportHTML,0,
|
||||
("Exporting %d\n", mCountExportHTML));
|
||||
|
||||
result = localFile->InitWithUnicodePath(filename.get());
|
||||
result = localFile->InitWithPath(NS_ConvertUCS2toUTF8(filename));
|
||||
if (NS_FAILED(result))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ public:
|
|||
PRInt32 GetNextElement(const char** aName, const char** aValue);
|
||||
PRInt32 GetNextElement(const char** aName, const char** aValue,
|
||||
char *aBuffer, PRUint32 aBufferLen);
|
||||
PRBool OpenForRead(const nsACString& aCatalogName);
|
||||
PRBool OpenTmpForWrite(const nsACString& aCatalogName);
|
||||
PRBool OpenForRead(const nsACString& aCatalogName); // native charset
|
||||
PRBool OpenTmpForWrite(const nsACString& aCatalogName); // native charset
|
||||
PRBool PutElement(const char* aName, const char* aValue);
|
||||
PRBool PutEndGroup(const char* aType);
|
||||
PRBool PutStartGroup(const char* aType);
|
||||
|
|
|
@ -677,6 +677,7 @@ nsFT2FontCatalog::doGetDirsPrefEnumCallback(const char* aName, void* aClosure)
|
|||
dce = (nsDirCatalogEntry *)calloc(1, sizeof(nsDirCatalogEntry));
|
||||
if (!dce)
|
||||
return;
|
||||
// native charset?!
|
||||
mPref->CopyCharPref(aName, (char **)&dce->mDirName);
|
||||
if (!dce->mDirName)
|
||||
return;
|
||||
|
@ -713,21 +714,20 @@ nsFT2FontCatalog::GetFontCatalog(FT_Library lib, nsFontCatalog *aFontCatalog,
|
|||
{
|
||||
int i;
|
||||
nsresult rv;
|
||||
nsXPIDLCString font_summaries_dir_path;
|
||||
nsXPIDLCString font_download_dir_path;
|
||||
nsCAutoString font_summaries_dir_path;
|
||||
nsCAutoString font_download_dir_path;
|
||||
PRBool exists;
|
||||
nsCOMPtr<nsIFile> font_download_dir;
|
||||
nsCOMPtr<nsIFile> font_summaries_dir, font_download_dir;
|
||||
|
||||
if (lib) {
|
||||
//
|
||||
// Get the dir for downloaded fonts
|
||||
//
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR,
|
||||
getter_AddRefs(font_download_dir));
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR, getter_AddRefs(font_download_dir));
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
|
||||
rv = font_download_dir->Append(FONT_DOWNLOAD_SUBDIR);
|
||||
rv = font_download_dir->AppendNative(FONT_DOWNLOAD_SUBDIR);
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
exists = PR_FALSE;
|
||||
|
@ -740,23 +740,21 @@ nsFT2FontCatalog::GetFontCatalog(FT_Library lib, nsFontCatalog *aFontCatalog,
|
|||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
}
|
||||
rv = font_download_dir->GetPath(getter_Copies(font_download_dir_path));
|
||||
rv = font_download_dir->GetNativePath(font_download_dir_path);
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
|
||||
//
|
||||
// Get the user dir for font catalogs
|
||||
//
|
||||
nsCOMPtr<nsIFile> font_summaries_dir;
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR,
|
||||
getter_AddRefs(font_summaries_dir));
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR, getter_AddRefs(font_summaries_dir));
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
|
||||
rv = font_summaries_dir->Append(FONT_DOWNLOAD_SUBDIR);
|
||||
rv = font_summaries_dir->AppendNative(FONT_DOWNLOAD_SUBDIR);
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
rv = font_summaries_dir->Append(FONT_SUMMARIES_SUBDIR);
|
||||
rv = font_summaries_dir->AppendNative(FONT_SUMMARIES_SUBDIR);
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
exists = PR_FALSE;
|
||||
|
@ -769,24 +767,22 @@ nsFT2FontCatalog::GetFontCatalog(FT_Library lib, nsFontCatalog *aFontCatalog,
|
|||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
}
|
||||
rv = font_summaries_dir->GetPath(getter_Copies(font_summaries_dir_path));
|
||||
rv = font_summaries_dir->GetNativePath(font_summaries_dir_path);
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
|
||||
//
|
||||
// Get the font summaries for the public font dirs
|
||||
//
|
||||
nsCAutoString fs_dir(font_summaries_dir_path);
|
||||
for (i=0; i<aOldDirCatalog->numDirs; i++) {
|
||||
nsCAutoString dir_name(aOldDirCatalog->dirs[i]->mDirName);
|
||||
HandleFontDir(lib, aFontCatalog, fs_dir, dir_name);
|
||||
HandleFontDir(lib, aFontCatalog, font_summaries_dir_path,
|
||||
nsDependentCString(aOldDirCatalog->dirs[i]->mDirName));
|
||||
}
|
||||
|
||||
//
|
||||
// Get the font summaries for the downloaded/private font dir
|
||||
//
|
||||
nsCAutoString fdown_dir(font_download_dir_path);
|
||||
HandleFontDir(lib, aFontCatalog, fs_dir, fdown_dir);
|
||||
HandleFontDir(lib, aFontCatalog, font_summaries_dir_path, font_download_dir_path);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -887,8 +883,8 @@ cleanup_and_return:
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsFT2FontCatalog::GetFontSummaryName(const nsACString &aFontDirName,
|
||||
const nsACString &aFontSummariesDir,
|
||||
nsFT2FontCatalog::GetFontSummaryName(const nsACString &aFontDirName, // native charset
|
||||
const nsACString &aFontSummariesDir, // native charset
|
||||
nsACString &aFontSummaryFileName,
|
||||
nsACString
|
||||
&aFallbackFontSummaryFileName)
|
||||
|
@ -906,16 +902,16 @@ nsFT2FontCatalog::GetFontSummaryName(const nsACString &aFontDirName,
|
|||
// or the "private" one in our $HOME/.mozilla/fontsummaries dir
|
||||
//
|
||||
font_dir = new nsLocalFile();
|
||||
font_dir->InitWithPath(PromiseFlatCString(aFontDirName).get());
|
||||
font_dir->InitWithNativePath(aFontDirName);
|
||||
rv = font_dir->IsWritable(&public_dir_writable);
|
||||
if (NS_SUCCEEDED(rv) && public_dir_writable) {
|
||||
FONT_CATALOG_PRINTF(("can write \"%s\"", PromiseFlatCString(aFontDirName).get()));
|
||||
nsCOMPtr<nsILocalFile> summary_file = new nsLocalFile();
|
||||
summary_file->InitWithPath(PromiseFlatCString(aFontDirName).get());
|
||||
summary_file->Append(PUBLIC_FONT_SUMMARY_NAME);
|
||||
char *font_summary_path;
|
||||
summary_file->GetPath(&font_summary_path);
|
||||
FONT_CATALOG_PRINTF(("font_summary_path = \"%s\"", font_summary_path));
|
||||
summary_file->InitWithNativePath(aFontDirName);
|
||||
summary_file->AppendNative(PUBLIC_FONT_SUMMARY_NAME);
|
||||
nsCAutoString font_summary_path;
|
||||
summary_file->GetNativePath(font_summary_path);
|
||||
FONT_CATALOG_PRINTF(("font_summary_path = \"%s\"", font_summary_path.get()));
|
||||
rv = summary_file->Exists(&exists);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (!exists) {
|
||||
|
@ -923,11 +919,11 @@ nsFT2FontCatalog::GetFontSummaryName(const nsACString &aFontDirName,
|
|||
aFontSummaryFileName = font_summary_path;
|
||||
}
|
||||
else {
|
||||
FONT_CATALOG_PRINTF(("font summary \"%s\" exists", font_summary_path));
|
||||
FONT_CATALOG_PRINTF(("font summary \"%s\" exists", font_summary_path.get()));
|
||||
rv = summary_file->IsWritable(&public_summary_writable);
|
||||
if (NS_SUCCEEDED(rv) && public_summary_writable) {
|
||||
FONT_CATALOG_PRINTF(("font summary \"%s\" is writable",
|
||||
font_summary_path));
|
||||
font_summary_path.get()));
|
||||
public_summary_writable = PR_TRUE;
|
||||
aFontSummaryFileName = font_summary_path;
|
||||
}
|
||||
|
@ -1054,12 +1050,12 @@ nsFT2FontCatalog::GetRange2CharSetName(unsigned long aBit)
|
|||
PRBool
|
||||
nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
|
||||
nsFontCatalog *aFontCatalog,
|
||||
const nsACString &aFontSummariesDir,
|
||||
const nsACString &aFontDirName)
|
||||
const nsACString &aFontSummariesDir, // native charset
|
||||
const nsACString &aFontDirName) // native charset
|
||||
{
|
||||
int i, status = -1;
|
||||
PRBool rslt, current;
|
||||
char *fileName;
|
||||
nsCAutoString fileName;
|
||||
nsHashtable* fontFileNamesHash = nsnull;
|
||||
nsHashtable* fallbackFceHash = nsnull;
|
||||
nsresult rv;
|
||||
|
@ -1068,7 +1064,7 @@ nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
|
|||
PRBool moreFilesInDir = PR_FALSE;
|
||||
nsCOMPtr<nsIFile> dir;
|
||||
nsCOMPtr<nsILocalFile> dirLocal;
|
||||
nsCOMPtr<nsIFile> dirEntry;
|
||||
nsCOMPtr<nsILocalFile> dirEntry;
|
||||
nsCOMPtr<nsISimpleEnumerator> dirIterator;
|
||||
PRBool summary_needs_update = PR_FALSE;
|
||||
nsFontCatalogEntry *fce;
|
||||
|
@ -1115,7 +1111,7 @@ nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
|
|||
//
|
||||
dir = new nsLocalFile();
|
||||
dirLocal = do_QueryInterface(dir);
|
||||
dirLocal->InitWithPath(PromiseFlatCString(aFontDirName).get());
|
||||
dirLocal->InitWithNativePath(aFontDirName);
|
||||
rv = dir->GetDirectoryEntries(getter_AddRefs(dirIterator));
|
||||
if (NS_FAILED(rv)) {
|
||||
FONT_CATALOG_PRINTF(("failed to open dir (get iterator) for %s",
|
||||
|
@ -1141,20 +1137,19 @@ nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
|
|||
goto cleanup_and_return;
|
||||
}
|
||||
//char *path;
|
||||
dirEntry->GetPath(&fileName);
|
||||
FONT_CATALOG_PRINTF(("dirEntry = \"%s\"", fileName));
|
||||
dirEntry->GetNativePath(fileName);
|
||||
FONT_CATALOG_PRINTF(("dirEntry = \"%s\"", fileName.get()));
|
||||
rv = dirEntry->IsFile(&isFile);
|
||||
if (NS_SUCCEEDED(rv) && isFile) {
|
||||
PRInt64 modtime;
|
||||
dirEntry->GetLastModifiedTime(&modtime);
|
||||
current = AddFceIfCurrent(fileName, fontFileNamesHash,
|
||||
current = AddFceIfCurrent(fileName.get(), fontFileNamesHash,
|
||||
modtime, dirFontCatalog);
|
||||
if (!current) {
|
||||
// Ignore the font summary itself
|
||||
nsDependentCString name(fileName);
|
||||
if (name.Equals(fontSummaryFilename) ||
|
||||
name.Equals(fallbackFontSummaryFilename)) {
|
||||
FONT_CATALOG_PRINTF(("font summary %s is not a font", fileName));
|
||||
if (fileName.Equals(fontSummaryFilename) ||
|
||||
fileName.Equals(fallbackFontSummaryFilename)) {
|
||||
FONT_CATALOG_PRINTF(("font summary %s is not a font", fileName.get()));
|
||||
current = PR_TRUE;
|
||||
}
|
||||
// If not in font summary, try the fallback summary
|
||||
|
@ -1168,7 +1163,7 @@ nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
|
|||
}
|
||||
if (fallbackFceHash) {
|
||||
summary_needs_update = PR_TRUE;
|
||||
current = AddFceIfCurrent(fileName, fallbackFceHash,
|
||||
current = AddFceIfCurrent(fileName.get(), fallbackFceHash,
|
||||
modtime, dirFontCatalog);
|
||||
}
|
||||
}
|
||||
|
@ -1180,7 +1175,7 @@ nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
|
|||
if (!current) {
|
||||
summary_needs_update = PR_TRUE;
|
||||
HandleFontFile(aFreeTypeLibrary, dirFontCatalog,
|
||||
fileName);
|
||||
fileName.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,10 +64,10 @@ typedef unsigned short FT_UShort;
|
|||
|
||||
class nsFontNodeArray;
|
||||
|
||||
#define PUBLIC_FONT_SUMMARY_NAME ".mozilla_font_summary.ndb"
|
||||
#define FONT_SUMMARIES_SUBDIR "catalog"
|
||||
#define FONT_DOWNLOAD_SUBDIR "fonts"
|
||||
#define FONT_SUMMARIES_EXTENSION ".ndb"
|
||||
#define PUBLIC_FONT_SUMMARY_NAME NS_LITERAL_CSTRING(".mozilla_font_summary.ndb")
|
||||
#define FONT_SUMMARIES_SUBDIR NS_LITERAL_CSTRING("catalog")
|
||||
#define FONT_DOWNLOAD_SUBDIR NS_LITERAL_CSTRING("fonts")
|
||||
#define FONT_SUMMARIES_EXTENSION NS_LITERAL_CSTRING(".ndb")
|
||||
#define FONT_SUMMARY_VERSION_TAG "FontSummaryVersion"
|
||||
#define FONT_SUMMARY_VERSION_MAJOR 1
|
||||
#define FONT_SUMMARY_VERSION_MINOR 0
|
||||
|
@ -97,7 +97,7 @@ typedef struct nsTTFontFamilyEncoderInfo {
|
|||
} nsTTFontFamilyEncoderInfo;
|
||||
|
||||
typedef struct {
|
||||
const char *mDirName;
|
||||
const char *mDirName; // encoded in the native charset
|
||||
} nsDirCatalogEntry;
|
||||
|
||||
|
||||
|
|
|
@ -324,9 +324,8 @@ FSSpec spec;
|
|||
return false;
|
||||
}
|
||||
|
||||
char *fullModuleName = nsnull;
|
||||
mozFile->Append("Essential Files");
|
||||
mozFile->Append("PrintDialogPDE.plugin");
|
||||
mozFile->Append(NS_LITERAL_CSTRING("Essential Files"));
|
||||
mozFile->Append(NS_LITERAL_CSTRING("PrintDialogPDE.plugin"));
|
||||
nsCOMPtr<nsILocalFileMac> mozMacFile(do_QueryInterface(mozFile));
|
||||
mozMacFile->GetFSSpec(&spec);
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@ nsNameValuePairDB::~nsNameValuePairDB()
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsNameValuePairDB::OpenForRead(const nsACString & aCatalogName)
|
||||
nsNameValuePairDB::OpenForRead(const nsACString & aCatalogName) // native charset
|
||||
{
|
||||
nsresult result;
|
||||
|
||||
|
@ -334,7 +334,7 @@ nsNameValuePairDB::OpenForRead(const nsACString & aCatalogName)
|
|||
if (NS_FAILED(result))
|
||||
goto error_return;
|
||||
|
||||
local_file->InitWithPath(PromiseFlatCString(aCatalogName).get());
|
||||
local_file->InitWithNativePath(aCatalogName);
|
||||
local_file->OpenANSIFileDesc("r", &mFile);
|
||||
if (mFile && CheckHeader())
|
||||
return PR_TRUE;
|
||||
|
@ -346,17 +346,14 @@ error_return:
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsNameValuePairDB::OpenTmpForWrite(const nsACString& aCatalogName)
|
||||
nsNameValuePairDB::OpenTmpForWrite(const nsACString& aCatalogName) // native charset
|
||||
{
|
||||
nsCAutoString name(aCatalogName);
|
||||
name.Append(".tmp");
|
||||
|
||||
nsresult result;
|
||||
nsCOMPtr<nsILocalFile> local_file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID,
|
||||
&result);
|
||||
if (NS_FAILED(result))
|
||||
return PR_FALSE;
|
||||
local_file->InitWithPath(name.get());
|
||||
local_file->InitWithNativePath(aCatalogName + NS_LITERAL_CSTRING(".tmp"));
|
||||
local_file->OpenANSIFileDesc("w+", &mFile);
|
||||
if (mFile == nsnull)
|
||||
return PR_FALSE;
|
||||
|
@ -455,8 +452,8 @@ nsNameValuePairDB::RenameTmp(const char* aCatalogName)
|
|||
nsCOMPtr<nsILocalFile> current_file;
|
||||
nsCOMPtr<nsILocalFile> tmp_file;
|
||||
nsCAutoString parent_dir;
|
||||
nsXPIDLCString parent_path;
|
||||
nsXPIDLCString cur_path;
|
||||
nsCAutoString parent_path;
|
||||
nsCAutoString cur_path;
|
||||
|
||||
//
|
||||
// Split the parent dir and file name
|
||||
|
@ -475,8 +472,8 @@ nsNameValuePairDB::RenameTmp(const char* aCatalogName)
|
|||
dir = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
goto Rename_Error;
|
||||
dir->InitWithPath(parent_dir.get());
|
||||
dir->GetPath(getter_Copies(parent_path));
|
||||
dir->InitWithNativePath(parent_dir);
|
||||
dir->GetNativePath(parent_path);
|
||||
|
||||
if (!mAtEndOfGroup || mError)
|
||||
goto Rename_Error;
|
||||
|
@ -488,7 +485,7 @@ nsNameValuePairDB::RenameTmp(const char* aCatalogName)
|
|||
tmp_file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
goto Rename_Error;
|
||||
tmp_file->InitWithPath(tmp_name.get());
|
||||
tmp_file->InitWithNativePath(tmp_name);
|
||||
tmp_file->Exists(&exists);
|
||||
if (!exists)
|
||||
goto Rename_Error;
|
||||
|
@ -500,7 +497,7 @@ nsNameValuePairDB::RenameTmp(const char* aCatalogName)
|
|||
old_file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
goto Rename_Error;
|
||||
old_file->InitWithPath(old_name.get());
|
||||
old_file->InitWithNativePath(old_name);
|
||||
|
||||
//
|
||||
// Check we have a current copy
|
||||
|
@ -508,15 +505,15 @@ nsNameValuePairDB::RenameTmp(const char* aCatalogName)
|
|||
current_file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
goto Rename_Error;
|
||||
current_file->InitWithPath(current_name.get());
|
||||
current_file->InitWithNativePath(current_name);
|
||||
current_file->Exists(&exists);
|
||||
if (exists) {
|
||||
//
|
||||
// Rename the current copy to old
|
||||
//
|
||||
current_file->GetPath(getter_Copies(cur_path));
|
||||
current_file->GetNativePath(cur_path);
|
||||
old_name.Right(old_name_tail, old_name.Length() - last_slash - 1);
|
||||
rv = current_file->MoveTo(dir, old_name_tail.get());
|
||||
rv = current_file->MoveToNative(dir, old_name_tail);
|
||||
if (NS_FAILED(rv))
|
||||
goto Rename_Error;
|
||||
}
|
||||
|
@ -525,7 +522,7 @@ nsNameValuePairDB::RenameTmp(const char* aCatalogName)
|
|||
// Rename the tmp to current
|
||||
//
|
||||
current_name.Right(current_name_tail, current_name.Length() - last_slash - 1);
|
||||
rv = tmp_file->MoveTo(dir, current_name_tail.get());
|
||||
rv = tmp_file->MoveToNative(dir, current_name_tail);
|
||||
if (NS_FAILED(rv))
|
||||
goto Rename_Error;
|
||||
|
||||
|
|
|
@ -677,6 +677,7 @@ nsFT2FontCatalog::doGetDirsPrefEnumCallback(const char* aName, void* aClosure)
|
|||
dce = (nsDirCatalogEntry *)calloc(1, sizeof(nsDirCatalogEntry));
|
||||
if (!dce)
|
||||
return;
|
||||
// native charset?!
|
||||
mPref->CopyCharPref(aName, (char **)&dce->mDirName);
|
||||
if (!dce->mDirName)
|
||||
return;
|
||||
|
@ -713,21 +714,20 @@ nsFT2FontCatalog::GetFontCatalog(FT_Library lib, nsFontCatalog *aFontCatalog,
|
|||
{
|
||||
int i;
|
||||
nsresult rv;
|
||||
nsXPIDLCString font_summaries_dir_path;
|
||||
nsXPIDLCString font_download_dir_path;
|
||||
nsCAutoString font_summaries_dir_path;
|
||||
nsCAutoString font_download_dir_path;
|
||||
PRBool exists;
|
||||
nsCOMPtr<nsIFile> font_download_dir;
|
||||
nsCOMPtr<nsIFile> font_summaries_dir, font_download_dir;
|
||||
|
||||
if (lib) {
|
||||
//
|
||||
// Get the dir for downloaded fonts
|
||||
//
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR,
|
||||
getter_AddRefs(font_download_dir));
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR, getter_AddRefs(font_download_dir));
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
|
||||
rv = font_download_dir->Append(FONT_DOWNLOAD_SUBDIR);
|
||||
rv = font_download_dir->AppendNative(FONT_DOWNLOAD_SUBDIR);
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
exists = PR_FALSE;
|
||||
|
@ -740,23 +740,21 @@ nsFT2FontCatalog::GetFontCatalog(FT_Library lib, nsFontCatalog *aFontCatalog,
|
|||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
}
|
||||
rv = font_download_dir->GetPath(getter_Copies(font_download_dir_path));
|
||||
rv = font_download_dir->GetNativePath(font_download_dir_path);
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
|
||||
//
|
||||
// Get the user dir for font catalogs
|
||||
//
|
||||
nsCOMPtr<nsIFile> font_summaries_dir;
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR,
|
||||
getter_AddRefs(font_summaries_dir));
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR, getter_AddRefs(font_summaries_dir));
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
|
||||
rv = font_summaries_dir->Append(FONT_DOWNLOAD_SUBDIR);
|
||||
rv = font_summaries_dir->AppendNative(FONT_DOWNLOAD_SUBDIR);
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
rv = font_summaries_dir->Append(FONT_SUMMARIES_SUBDIR);
|
||||
rv = font_summaries_dir->AppendNative(FONT_SUMMARIES_SUBDIR);
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
exists = PR_FALSE;
|
||||
|
@ -769,24 +767,22 @@ nsFT2FontCatalog::GetFontCatalog(FT_Library lib, nsFontCatalog *aFontCatalog,
|
|||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
}
|
||||
rv = font_summaries_dir->GetPath(getter_Copies(font_summaries_dir_path));
|
||||
rv = font_summaries_dir->GetNativePath(font_summaries_dir_path);
|
||||
if (NS_FAILED(rv))
|
||||
goto cleanup_and_return;
|
||||
|
||||
//
|
||||
// Get the font summaries for the public font dirs
|
||||
//
|
||||
nsCAutoString fs_dir(font_summaries_dir_path);
|
||||
for (i=0; i<aOldDirCatalog->numDirs; i++) {
|
||||
nsCAutoString dir_name(aOldDirCatalog->dirs[i]->mDirName);
|
||||
HandleFontDir(lib, aFontCatalog, fs_dir, dir_name);
|
||||
HandleFontDir(lib, aFontCatalog, font_summaries_dir_path,
|
||||
nsDependentCString(aOldDirCatalog->dirs[i]->mDirName));
|
||||
}
|
||||
|
||||
//
|
||||
// Get the font summaries for the downloaded/private font dir
|
||||
//
|
||||
nsCAutoString fdown_dir(font_download_dir_path);
|
||||
HandleFontDir(lib, aFontCatalog, fs_dir, fdown_dir);
|
||||
HandleFontDir(lib, aFontCatalog, font_summaries_dir_path, font_download_dir_path);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -887,8 +883,8 @@ cleanup_and_return:
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsFT2FontCatalog::GetFontSummaryName(const nsACString &aFontDirName,
|
||||
const nsACString &aFontSummariesDir,
|
||||
nsFT2FontCatalog::GetFontSummaryName(const nsACString &aFontDirName, // native charset
|
||||
const nsACString &aFontSummariesDir, // native charset
|
||||
nsACString &aFontSummaryFileName,
|
||||
nsACString
|
||||
&aFallbackFontSummaryFileName)
|
||||
|
@ -906,16 +902,16 @@ nsFT2FontCatalog::GetFontSummaryName(const nsACString &aFontDirName,
|
|||
// or the "private" one in our $HOME/.mozilla/fontsummaries dir
|
||||
//
|
||||
font_dir = new nsLocalFile();
|
||||
font_dir->InitWithPath(PromiseFlatCString(aFontDirName).get());
|
||||
font_dir->InitWithNativePath(aFontDirName);
|
||||
rv = font_dir->IsWritable(&public_dir_writable);
|
||||
if (NS_SUCCEEDED(rv) && public_dir_writable) {
|
||||
FONT_CATALOG_PRINTF(("can write \"%s\"", PromiseFlatCString(aFontDirName).get()));
|
||||
nsCOMPtr<nsILocalFile> summary_file = new nsLocalFile();
|
||||
summary_file->InitWithPath(PromiseFlatCString(aFontDirName).get());
|
||||
summary_file->Append(PUBLIC_FONT_SUMMARY_NAME);
|
||||
char *font_summary_path;
|
||||
summary_file->GetPath(&font_summary_path);
|
||||
FONT_CATALOG_PRINTF(("font_summary_path = \"%s\"", font_summary_path));
|
||||
summary_file->InitWithNativePath(aFontDirName);
|
||||
summary_file->AppendNative(PUBLIC_FONT_SUMMARY_NAME);
|
||||
nsCAutoString font_summary_path;
|
||||
summary_file->GetNativePath(font_summary_path);
|
||||
FONT_CATALOG_PRINTF(("font_summary_path = \"%s\"", font_summary_path.get()));
|
||||
rv = summary_file->Exists(&exists);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (!exists) {
|
||||
|
@ -923,11 +919,11 @@ nsFT2FontCatalog::GetFontSummaryName(const nsACString &aFontDirName,
|
|||
aFontSummaryFileName = font_summary_path;
|
||||
}
|
||||
else {
|
||||
FONT_CATALOG_PRINTF(("font summary \"%s\" exists", font_summary_path));
|
||||
FONT_CATALOG_PRINTF(("font summary \"%s\" exists", font_summary_path.get()));
|
||||
rv = summary_file->IsWritable(&public_summary_writable);
|
||||
if (NS_SUCCEEDED(rv) && public_summary_writable) {
|
||||
FONT_CATALOG_PRINTF(("font summary \"%s\" is writable",
|
||||
font_summary_path));
|
||||
font_summary_path.get()));
|
||||
public_summary_writable = PR_TRUE;
|
||||
aFontSummaryFileName = font_summary_path;
|
||||
}
|
||||
|
@ -1054,12 +1050,12 @@ nsFT2FontCatalog::GetRange2CharSetName(unsigned long aBit)
|
|||
PRBool
|
||||
nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
|
||||
nsFontCatalog *aFontCatalog,
|
||||
const nsACString &aFontSummariesDir,
|
||||
const nsACString &aFontDirName)
|
||||
const nsACString &aFontSummariesDir, // native charset
|
||||
const nsACString &aFontDirName) // native charset
|
||||
{
|
||||
int i, status = -1;
|
||||
PRBool rslt, current;
|
||||
char *fileName;
|
||||
nsCAutoString fileName;
|
||||
nsHashtable* fontFileNamesHash = nsnull;
|
||||
nsHashtable* fallbackFceHash = nsnull;
|
||||
nsresult rv;
|
||||
|
@ -1068,7 +1064,7 @@ nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
|
|||
PRBool moreFilesInDir = PR_FALSE;
|
||||
nsCOMPtr<nsIFile> dir;
|
||||
nsCOMPtr<nsILocalFile> dirLocal;
|
||||
nsCOMPtr<nsIFile> dirEntry;
|
||||
nsCOMPtr<nsILocalFile> dirEntry;
|
||||
nsCOMPtr<nsISimpleEnumerator> dirIterator;
|
||||
PRBool summary_needs_update = PR_FALSE;
|
||||
nsFontCatalogEntry *fce;
|
||||
|
@ -1115,7 +1111,7 @@ nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
|
|||
//
|
||||
dir = new nsLocalFile();
|
||||
dirLocal = do_QueryInterface(dir);
|
||||
dirLocal->InitWithPath(PromiseFlatCString(aFontDirName).get());
|
||||
dirLocal->InitWithNativePath(aFontDirName);
|
||||
rv = dir->GetDirectoryEntries(getter_AddRefs(dirIterator));
|
||||
if (NS_FAILED(rv)) {
|
||||
FONT_CATALOG_PRINTF(("failed to open dir (get iterator) for %s",
|
||||
|
@ -1141,20 +1137,19 @@ nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
|
|||
goto cleanup_and_return;
|
||||
}
|
||||
//char *path;
|
||||
dirEntry->GetPath(&fileName);
|
||||
FONT_CATALOG_PRINTF(("dirEntry = \"%s\"", fileName));
|
||||
dirEntry->GetNativePath(fileName);
|
||||
FONT_CATALOG_PRINTF(("dirEntry = \"%s\"", fileName.get()));
|
||||
rv = dirEntry->IsFile(&isFile);
|
||||
if (NS_SUCCEEDED(rv) && isFile) {
|
||||
PRInt64 modtime;
|
||||
dirEntry->GetLastModifiedTime(&modtime);
|
||||
current = AddFceIfCurrent(fileName, fontFileNamesHash,
|
||||
current = AddFceIfCurrent(fileName.get(), fontFileNamesHash,
|
||||
modtime, dirFontCatalog);
|
||||
if (!current) {
|
||||
// Ignore the font summary itself
|
||||
nsDependentCString name(fileName);
|
||||
if (name.Equals(fontSummaryFilename) ||
|
||||
name.Equals(fallbackFontSummaryFilename)) {
|
||||
FONT_CATALOG_PRINTF(("font summary %s is not a font", fileName));
|
||||
if (fileName.Equals(fontSummaryFilename) ||
|
||||
fileName.Equals(fallbackFontSummaryFilename)) {
|
||||
FONT_CATALOG_PRINTF(("font summary %s is not a font", fileName.get()));
|
||||
current = PR_TRUE;
|
||||
}
|
||||
// If not in font summary, try the fallback summary
|
||||
|
@ -1168,7 +1163,7 @@ nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
|
|||
}
|
||||
if (fallbackFceHash) {
|
||||
summary_needs_update = PR_TRUE;
|
||||
current = AddFceIfCurrent(fileName, fallbackFceHash,
|
||||
current = AddFceIfCurrent(fileName.get(), fallbackFceHash,
|
||||
modtime, dirFontCatalog);
|
||||
}
|
||||
}
|
||||
|
@ -1180,7 +1175,7 @@ nsFT2FontCatalog::HandleFontDir(FT_Library aFreeTypeLibrary,
|
|||
if (!current) {
|
||||
summary_needs_update = PR_TRUE;
|
||||
HandleFontFile(aFreeTypeLibrary, dirFontCatalog,
|
||||
fileName);
|
||||
fileName.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,10 +64,10 @@ typedef unsigned short FT_UShort;
|
|||
|
||||
class nsFontNodeArray;
|
||||
|
||||
#define PUBLIC_FONT_SUMMARY_NAME ".mozilla_font_summary.ndb"
|
||||
#define FONT_SUMMARIES_SUBDIR "catalog"
|
||||
#define FONT_DOWNLOAD_SUBDIR "fonts"
|
||||
#define FONT_SUMMARIES_EXTENSION ".ndb"
|
||||
#define PUBLIC_FONT_SUMMARY_NAME NS_LITERAL_CSTRING(".mozilla_font_summary.ndb")
|
||||
#define FONT_SUMMARIES_SUBDIR NS_LITERAL_CSTRING("catalog")
|
||||
#define FONT_DOWNLOAD_SUBDIR NS_LITERAL_CSTRING("fonts")
|
||||
#define FONT_SUMMARIES_EXTENSION NS_LITERAL_CSTRING(".ndb")
|
||||
#define FONT_SUMMARY_VERSION_TAG "FontSummaryVersion"
|
||||
#define FONT_SUMMARY_VERSION_MAJOR 1
|
||||
#define FONT_SUMMARY_VERSION_MINOR 0
|
||||
|
@ -97,7 +97,7 @@ typedef struct nsTTFontFamilyEncoderInfo {
|
|||
} nsTTFontFamilyEncoderInfo;
|
||||
|
||||
typedef struct {
|
||||
const char *mDirName;
|
||||
const char *mDirName; // encoded in the native charset
|
||||
} nsDirCatalogEntry;
|
||||
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@ nsNameValuePairDB::~nsNameValuePairDB()
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsNameValuePairDB::OpenForRead(const nsACString & aCatalogName)
|
||||
nsNameValuePairDB::OpenForRead(const nsACString & aCatalogName) // native charset
|
||||
{
|
||||
nsresult result;
|
||||
|
||||
|
@ -334,7 +334,7 @@ nsNameValuePairDB::OpenForRead(const nsACString & aCatalogName)
|
|||
if (NS_FAILED(result))
|
||||
goto error_return;
|
||||
|
||||
local_file->InitWithPath(PromiseFlatCString(aCatalogName).get());
|
||||
local_file->InitWithNativePath(aCatalogName);
|
||||
local_file->OpenANSIFileDesc("r", &mFile);
|
||||
if (mFile && CheckHeader())
|
||||
return PR_TRUE;
|
||||
|
@ -346,17 +346,14 @@ error_return:
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsNameValuePairDB::OpenTmpForWrite(const nsACString& aCatalogName)
|
||||
nsNameValuePairDB::OpenTmpForWrite(const nsACString& aCatalogName) // native charset
|
||||
{
|
||||
nsCAutoString name(aCatalogName);
|
||||
name.Append(".tmp");
|
||||
|
||||
nsresult result;
|
||||
nsCOMPtr<nsILocalFile> local_file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID,
|
||||
&result);
|
||||
if (NS_FAILED(result))
|
||||
return PR_FALSE;
|
||||
local_file->InitWithPath(name.get());
|
||||
local_file->InitWithNativePath(aCatalogName + NS_LITERAL_CSTRING(".tmp"));
|
||||
local_file->OpenANSIFileDesc("w+", &mFile);
|
||||
if (mFile == nsnull)
|
||||
return PR_FALSE;
|
||||
|
@ -455,8 +452,8 @@ nsNameValuePairDB::RenameTmp(const char* aCatalogName)
|
|||
nsCOMPtr<nsILocalFile> current_file;
|
||||
nsCOMPtr<nsILocalFile> tmp_file;
|
||||
nsCAutoString parent_dir;
|
||||
nsXPIDLCString parent_path;
|
||||
nsXPIDLCString cur_path;
|
||||
nsCAutoString parent_path;
|
||||
nsCAutoString cur_path;
|
||||
|
||||
//
|
||||
// Split the parent dir and file name
|
||||
|
@ -475,8 +472,8 @@ nsNameValuePairDB::RenameTmp(const char* aCatalogName)
|
|||
dir = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
goto Rename_Error;
|
||||
dir->InitWithPath(parent_dir.get());
|
||||
dir->GetPath(getter_Copies(parent_path));
|
||||
dir->InitWithNativePath(parent_dir);
|
||||
dir->GetNativePath(parent_path);
|
||||
|
||||
if (!mAtEndOfGroup || mError)
|
||||
goto Rename_Error;
|
||||
|
@ -488,7 +485,7 @@ nsNameValuePairDB::RenameTmp(const char* aCatalogName)
|
|||
tmp_file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
goto Rename_Error;
|
||||
tmp_file->InitWithPath(tmp_name.get());
|
||||
tmp_file->InitWithNativePath(tmp_name);
|
||||
tmp_file->Exists(&exists);
|
||||
if (!exists)
|
||||
goto Rename_Error;
|
||||
|
@ -500,7 +497,7 @@ nsNameValuePairDB::RenameTmp(const char* aCatalogName)
|
|||
old_file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
goto Rename_Error;
|
||||
old_file->InitWithPath(old_name.get());
|
||||
old_file->InitWithNativePath(old_name);
|
||||
|
||||
//
|
||||
// Check we have a current copy
|
||||
|
@ -508,15 +505,15 @@ nsNameValuePairDB::RenameTmp(const char* aCatalogName)
|
|||
current_file = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
goto Rename_Error;
|
||||
current_file->InitWithPath(current_name.get());
|
||||
current_file->InitWithNativePath(current_name);
|
||||
current_file->Exists(&exists);
|
||||
if (exists) {
|
||||
//
|
||||
// Rename the current copy to old
|
||||
//
|
||||
current_file->GetPath(getter_Copies(cur_path));
|
||||
current_file->GetNativePath(cur_path);
|
||||
old_name.Right(old_name_tail, old_name.Length() - last_slash - 1);
|
||||
rv = current_file->MoveTo(dir, old_name_tail.get());
|
||||
rv = current_file->MoveToNative(dir, old_name_tail);
|
||||
if (NS_FAILED(rv))
|
||||
goto Rename_Error;
|
||||
}
|
||||
|
@ -525,7 +522,7 @@ nsNameValuePairDB::RenameTmp(const char* aCatalogName)
|
|||
// Rename the tmp to current
|
||||
//
|
||||
current_name.Right(current_name_tail, current_name.Length() - last_slash - 1);
|
||||
rv = tmp_file->MoveTo(dir, current_name_tail.get());
|
||||
rv = tmp_file->MoveToNative(dir, current_name_tail);
|
||||
if (NS_FAILED(rv))
|
||||
goto Rename_Error;
|
||||
|
||||
|
|
|
@ -734,7 +734,7 @@ mozJSComponentLoader::AutoRegisterComponent(PRInt32 when,
|
|||
|
||||
const char jsExtension[] = ".js";
|
||||
int jsExtensionLen = 3;
|
||||
nsXPIDLCString leafName;
|
||||
nsCAutoString leafName;
|
||||
|
||||
*registered = PR_FALSE;
|
||||
|
||||
|
@ -743,28 +743,28 @@ mozJSComponentLoader::AutoRegisterComponent(PRInt32 when,
|
|||
if (NS_FAILED(rv = component->IsFile(&isFile)) || !isFile)
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(rv = component->GetLeafName(getter_Copies(leafName))))
|
||||
if (NS_FAILED(rv = component->GetNativeLeafName(leafName)))
|
||||
return rv;
|
||||
int len = PL_strlen(leafName);
|
||||
int len = leafName.Length();
|
||||
|
||||
/* if it's not *.js, return now */
|
||||
if (len < jsExtensionLen || // too short
|
||||
PL_strcasecmp(leafName + len - jsExtensionLen, jsExtension))
|
||||
PL_strcasecmp(leafName.get() + len - jsExtensionLen, jsExtension))
|
||||
return NS_OK;
|
||||
|
||||
#ifdef DEBUG_shaver_off
|
||||
fprintf(stderr, "mJCL: registering JS component %s\n",
|
||||
(const char *)leafName);
|
||||
leafName.get());
|
||||
#endif
|
||||
|
||||
rv = AttemptRegistration(component, PR_FALSE);
|
||||
#ifdef DEBUG_shaver_off
|
||||
if (NS_SUCCEEDED(rv))
|
||||
fprintf(stderr, "registered module %s\n", (const char *)leafName);
|
||||
fprintf(stderr, "registered module %s\n", leafName.get());
|
||||
else if (rv == NS_ERROR_FACTORY_REGISTER_AGAIN)
|
||||
fprintf(stderr, "deferred module %s\n", (const char *)leafName);
|
||||
fprintf(stderr, "deferred module %s\n", leafName.get());
|
||||
else
|
||||
fprintf(stderr, "failed to register %s\n", (const char *)leafName);
|
||||
fprintf(stderr, "failed to register %s\n", leafName.get());
|
||||
#endif
|
||||
*registered = (PRBool) NS_SUCCEEDED(rv);
|
||||
return NS_OK;
|
||||
|
@ -781,7 +781,7 @@ mozJSComponentLoader::AutoUnregisterComponent(PRInt32 when,
|
|||
|
||||
const char jsExtension[] = ".js";
|
||||
int jsExtensionLen = 3;
|
||||
nsXPIDLCString leafName;
|
||||
nsCAutoString leafName;
|
||||
|
||||
*unregistered = PR_FALSE;
|
||||
|
||||
|
@ -790,21 +790,21 @@ mozJSComponentLoader::AutoUnregisterComponent(PRInt32 when,
|
|||
if (NS_FAILED(rv = component->IsFile(&isFile)) || !isFile)
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(rv = component->GetLeafName(getter_Copies(leafName))))
|
||||
if (NS_FAILED(rv = component->GetNativeLeafName(leafName)))
|
||||
return rv;
|
||||
int len = PL_strlen(leafName);
|
||||
int len = leafName.Length();
|
||||
|
||||
/* if it's not *.js, return now */
|
||||
if (len < jsExtensionLen || // too short
|
||||
PL_strcasecmp(leafName + len - jsExtensionLen, jsExtension))
|
||||
PL_strcasecmp(leafName.get() + len - jsExtensionLen, jsExtension))
|
||||
return NS_OK;
|
||||
|
||||
rv = UnregisterComponent(component);
|
||||
#ifdef DEBUG_dp
|
||||
if (NS_SUCCEEDED(rv))
|
||||
fprintf(stderr, "unregistered module %s\n", (const char *)leafName);
|
||||
fprintf(stderr, "unregistered module %s\n", leafName.get());
|
||||
else
|
||||
fprintf(stderr, "failed to unregister %s\n", (const char *)leafName);
|
||||
fprintf(stderr, "failed to unregister %s\n", leafName.get());
|
||||
#endif
|
||||
*unregistered = (PRBool) NS_SUCCEEDED(rv);
|
||||
return NS_OK;
|
||||
|
@ -852,9 +852,9 @@ mozJSComponentLoader::AttemptRegistration(nsIFile *component,
|
|||
// get the file name
|
||||
if (component)
|
||||
{
|
||||
nsXPIDLCString leafName;
|
||||
component->GetLeafName(getter_Copies(leafName));
|
||||
fileName.AssignWithConversion(leafName);
|
||||
nsCAutoString leafName;
|
||||
component->GetLeafName(leafName);
|
||||
fileName.Assign(NS_ConvertUTF8toUCS2(leafName));
|
||||
}
|
||||
|
||||
// this string can't come from a string bundle, because we
|
||||
|
|
|
@ -304,13 +304,12 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
|
|||
|
||||
nsCOMPtr<nsILocalFile> currentFile = do_CreateInstance("@mozilla.org/file/local;1");
|
||||
if (currentFile && !defaultName.IsEmpty()) {
|
||||
result = currentFile->InitWithUnicodePath(defaultName.get());
|
||||
result = currentFile->InitWithPath(NS_ConvertUCS2toUTF8(defaultName));
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
PRUnichar *leafName = nsnull;
|
||||
currentFile->GetUnicodeLeafName(&leafName);
|
||||
if (leafName) {
|
||||
filePicker->SetDefaultString(leafName);
|
||||
nsMemory::Free(leafName);
|
||||
nsCAutoString leafName;
|
||||
currentFile->GetLeafName(leafName);
|
||||
if (!leafName.IsEmpty()) {
|
||||
filePicker->SetDefaultString(NS_ConvertUTF8toUCS2(leafName).get());
|
||||
}
|
||||
|
||||
// set directory
|
||||
|
@ -336,12 +335,11 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
|
|||
nsCOMPtr<nsILocalFile> localFile;
|
||||
result = filePicker->GetFile(getter_AddRefs(localFile));
|
||||
if (localFile) {
|
||||
PRUnichar *nativePath = nsnull;
|
||||
result = localFile->GetUnicodePath(&nativePath);
|
||||
if (nativePath) {
|
||||
nsAutoString pathName(nativePath);
|
||||
nsCAutoString unicodePath;
|
||||
result = localFile->GetPath(unicodePath);
|
||||
if (!unicodePath.IsEmpty()) {
|
||||
NS_ConvertUTF8toUCS2 pathName(unicodePath);
|
||||
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, pathName);
|
||||
nsMemory::Free(nativePath);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -304,13 +304,12 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
|
|||
|
||||
nsCOMPtr<nsILocalFile> currentFile = do_CreateInstance("@mozilla.org/file/local;1");
|
||||
if (currentFile && !defaultName.IsEmpty()) {
|
||||
result = currentFile->InitWithUnicodePath(defaultName.get());
|
||||
result = currentFile->InitWithPath(NS_ConvertUCS2toUTF8(defaultName));
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
PRUnichar *leafName = nsnull;
|
||||
currentFile->GetUnicodeLeafName(&leafName);
|
||||
if (leafName) {
|
||||
filePicker->SetDefaultString(leafName);
|
||||
nsMemory::Free(leafName);
|
||||
nsCAutoString leafName;
|
||||
currentFile->GetLeafName(leafName);
|
||||
if (!leafName.IsEmpty()) {
|
||||
filePicker->SetDefaultString(NS_ConvertUTF8toUCS2(leafName).get());
|
||||
}
|
||||
|
||||
// set directory
|
||||
|
@ -336,12 +335,11 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
|
|||
nsCOMPtr<nsILocalFile> localFile;
|
||||
result = filePicker->GetFile(getter_AddRefs(localFile));
|
||||
if (localFile) {
|
||||
PRUnichar *nativePath = nsnull;
|
||||
result = localFile->GetUnicodePath(&nativePath);
|
||||
if (nativePath) {
|
||||
nsAutoString pathName(nativePath);
|
||||
nsCAutoString unicodePath;
|
||||
result = localFile->GetPath(unicodePath);
|
||||
if (!unicodePath.IsEmpty()) {
|
||||
NS_ConvertUTF8toUCS2 pathName(unicodePath);
|
||||
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, pathName);
|
||||
nsMemory::Free(nativePath);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1175,19 +1175,15 @@ nsAbSync::AnalyzeAllRecords(nsIAddrDatabase *aDatabase, nsIAbDirectory *director
|
|||
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(historyFile));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = historyFile->Append("absync.dat");
|
||||
rv = historyFile->Append(NS_LITERAL_CSTRING("absync.dat"));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// TODO: Convert the rest of the code to use
|
||||
// nsIFile and avoid this conversion hack.
|
||||
do
|
||||
{
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = historyFile->GetPath(getter_Copies(pathBuf));
|
||||
rv = NS_NewFileSpecFromIFile(historyFile, getter_AddRefs(mHistoryFile));
|
||||
if (NS_FAILED(rv)) break;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(mHistoryFile));
|
||||
if (NS_FAILED(rv)) break;
|
||||
rv = mHistoryFile->SetNativePath(pathBuf);
|
||||
}
|
||||
while (0);
|
||||
|
||||
|
@ -1227,7 +1223,7 @@ nsAbSync::AnalyzeAllRecords(nsIAddrDatabase *aDatabase, nsIAbDirectory *director
|
|||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(lockFile));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = lockFile->Append((const char *)"absync.lck");
|
||||
rv = lockFile->Append(NS_LITERAL_CSTRING("absync.lck"));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
||||
|
@ -1235,12 +1231,8 @@ nsAbSync::AnalyzeAllRecords(nsIAddrDatabase *aDatabase, nsIAbDirectory *director
|
|||
// nsIFile and avoid this conversion hack.
|
||||
do
|
||||
{
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = lockFile->GetPath(getter_Copies(pathBuf));
|
||||
rv = NS_NewFileSpecFromIFile(lockFile, getter_AddRefs(mLockFile));
|
||||
if (NS_FAILED(rv)) break;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(mLockFile));
|
||||
if (NS_FAILED(rv)) break;
|
||||
rv = mLockFile->SetNativePath(pathBuf);
|
||||
}
|
||||
while (0);
|
||||
|
||||
|
|
|
@ -698,7 +698,7 @@ nsAbSyncPostEngine::FireURLRequest(nsIURI *aURL, const char *postData)
|
|||
if (!httpChannel)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postStream), PR_FALSE, postData, 0))){
|
||||
if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postStream), PR_FALSE, nsDependentCString(postData), 0))){
|
||||
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel));
|
||||
NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel");
|
||||
uploadChannel->SetUploadStream(postStream, nsnull, -1);
|
||||
|
|
|
@ -236,7 +236,7 @@ NS_IMETHODIMP nsAbLDAPProcessReplicationData::Abort()
|
|||
if(NS_SUCCEEDED(rv)) {
|
||||
// now put back the backed up replicated file if aborted
|
||||
if(mBackupReplicationFile && mDirServerInfo->replInfo)
|
||||
rv = mBackupReplicationFile->MoveTo(nsnull, mDirServerInfo->replInfo->fileName);
|
||||
rv = mBackupReplicationFile->MoveToNative(nsnull, nsDependentCString(mDirServerInfo->replInfo->fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -472,7 +472,7 @@ nsresult nsAbLDAPProcessReplicationData::OnLDAPSearchResult(nsILDAPMessage *aMes
|
|||
// now put back the backed up replicated file
|
||||
if(mBackupReplicationFile && mDirServerInfo->replInfo)
|
||||
{
|
||||
rv = mBackupReplicationFile->MoveTo(nsnull, mDirServerInfo->replInfo->fileName);
|
||||
rv = mBackupReplicationFile->MoveToNative(nsnull, nsDependentCString(mDirServerInfo->replInfo->fileName));
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Replication Backup File Move back on Failure failed");
|
||||
}
|
||||
}
|
||||
|
@ -526,7 +526,14 @@ nsresult nsAbLDAPProcessReplicationData::OpenABForReplicatedDir(PRBool aCreate)
|
|||
// clone the existing one for a much better performance - for Download All.
|
||||
// And also important in case if replication fails we donot lose user's existing
|
||||
// replicated data for both Download all and Changelog.
|
||||
rv = mReplicationFile->Clone(getter_AddRefs(mBackupReplicationFile));
|
||||
nsCOMPtr<nsIFile> clone;
|
||||
rv = mReplicationFile->Clone(getter_AddRefs(clone));
|
||||
if(NS_FAILED(rv)) {
|
||||
delete dbPath;
|
||||
Done(PR_FALSE);
|
||||
return rv;
|
||||
}
|
||||
mBackupReplicationFile = do_QueryInterface(clone, &rv);
|
||||
if(NS_FAILED(rv)) {
|
||||
delete dbPath;
|
||||
Done(PR_FALSE);
|
||||
|
@ -538,8 +545,8 @@ nsresult nsAbLDAPProcessReplicationData::OpenABForReplicatedDir(PRBool aCreate)
|
|||
Done(PR_FALSE);
|
||||
return rv;
|
||||
}
|
||||
nsXPIDLCString backupFileLeafName;
|
||||
rv = mBackupReplicationFile->GetLeafName(getter_Copies(backupFileLeafName));
|
||||
nsCAutoString backupFileLeafName;
|
||||
rv = mBackupReplicationFile->GetLeafName(backupFileLeafName);
|
||||
if(NS_FAILED(rv)) {
|
||||
delete dbPath;
|
||||
Done(PR_FALSE);
|
||||
|
@ -555,25 +562,25 @@ nsresult nsAbLDAPProcessReplicationData::OpenABForReplicatedDir(PRBool aCreate)
|
|||
|
||||
if(aCreate) {
|
||||
// set backup file to existing replication file for move
|
||||
mBackupReplicationFile->SetLeafName(mDirServerInfo->replInfo->fileName);
|
||||
rv = mBackupReplicationFile->MoveTo(nsnull, backupFileLeafName.get());
|
||||
mBackupReplicationFile->SetNativeLeafName(nsDependentCString(mDirServerInfo->replInfo->fileName));
|
||||
rv = mBackupReplicationFile->MoveTo(nsnull, backupFileLeafName);
|
||||
// set the backup file leaf name now
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mBackupReplicationFile->SetLeafName(backupFileLeafName.get());
|
||||
mBackupReplicationFile->SetLeafName(backupFileLeafName);
|
||||
}
|
||||
else {
|
||||
// set backup file to existing replication file for copy
|
||||
mBackupReplicationFile->SetLeafName(mDirServerInfo->replInfo->fileName);
|
||||
mBackupReplicationFile->SetLeafName(nsDependentCString(mDirServerInfo->replInfo->fileName));
|
||||
// specify the parent here specifically,
|
||||
// passing nsnull to copy to the same dir actually renames existing file
|
||||
// instead of making another copy of the existing file.
|
||||
nsCOMPtr<nsIFile> parent;
|
||||
rv = mBackupReplicationFile->GetParent(getter_AddRefs(parent));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = mBackupReplicationFile->CopyTo(parent, backupFileLeafName.get());
|
||||
rv = mBackupReplicationFile->CopyTo(parent, backupFileLeafName);
|
||||
// set the backup file leaf name now
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mBackupReplicationFile->SetLeafName(backupFileLeafName.get());
|
||||
mBackupReplicationFile->SetLeafName(backupFileLeafName);
|
||||
}
|
||||
if(NS_FAILED(rv)) {
|
||||
delete dbPath;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIAbLDAPReplicationQuery.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsDirPrefs.h"
|
||||
|
||||
class nsAbLDAPProcessReplicationData : public nsIAbLDAPProcessReplicationData
|
||||
|
@ -63,7 +64,7 @@ protected :
|
|||
|
||||
nsCOMPtr<nsIAddrDatabase> mReplicationDB;
|
||||
nsCOMPtr <nsILocalFile> mReplicationFile;
|
||||
nsCOMPtr <nsIFile> mBackupReplicationFile;
|
||||
nsCOMPtr <nsILocalFile> mBackupReplicationFile;
|
||||
|
||||
// state of processing, protocol used and count of results
|
||||
PRInt32 mState;
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "nsAddrBookSession.h"
|
||||
#include "nsIAddrBookSession.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIDirectoryService.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
@ -179,14 +180,15 @@ NS_IMETHODIMP nsAddrBookSession::GetUserProfileDirectory(nsFileSpec * *userDir)
|
|||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFile> profileDir;
|
||||
nsXPIDLCString pathBuf;
|
||||
nsCAutoString pathBuf;
|
||||
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profileDir));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = profileDir->GetPath(getter_Copies(pathBuf));
|
||||
|
||||
rv = profileDir->GetNativePath(pathBuf);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*userDir = new nsFileSpec(pathBuf);
|
||||
*userDir = new nsFileSpec(pathBuf.get());
|
||||
NS_ENSURE_TRUE(*userDir, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -1323,8 +1323,8 @@ NS_IMETHODIMP nsAddressBook::ExportAddressBook(nsIAbDirectory *aDirectory)
|
|||
}
|
||||
}
|
||||
|
||||
nsXPIDLCString leafName;
|
||||
rv = localFile->GetLeafName(getter_Copies(leafName));
|
||||
nsCAutoString leafName;
|
||||
rv = localFile->GetLeafName(leafName);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// we're looking for .tab, .txt, .csv, .ldi or .ldif
|
||||
|
|
|
@ -869,7 +869,7 @@ function getFormElementValue(formElement) {
|
|||
if (formElement.value) {
|
||||
var localfile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
|
||||
|
||||
localfile.initWithUnicodePath(formElement.value);
|
||||
localfile.initWithPath(formElement.value);
|
||||
return localfile;
|
||||
}
|
||||
else {
|
||||
|
@ -952,7 +952,7 @@ function setFormElementValue(formElement, value) {
|
|||
if (value) {
|
||||
var localfile = value.QueryInterface(Components.interfaces.nsILocalFile);
|
||||
try {
|
||||
formElement.value = localfile.unicodePath;
|
||||
formElement.value = localfile.path;
|
||||
} catch (ex) {
|
||||
dump("Still need to fix uninitialized nsIFile problem!\n");
|
||||
}
|
||||
|
|
|
@ -431,7 +431,7 @@ function finishAccount(account, accountData) {
|
|||
var sigFileName = accountData.signatureFileName;
|
||||
|
||||
var sigFile = gMailSession.getDataFilesDir("messenger");
|
||||
sigFile.appendUnicode(sigFileName);
|
||||
sigFile.append(sigFileName);
|
||||
destIdentity.signature = sigFile;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ function selectFile()
|
|||
var ret = fp.show();
|
||||
if (ret == nsIFilePicker.returnOK) {
|
||||
var folderField = document.getElementById("identity.signature");
|
||||
folderField.value = fp.file.unicodePath;
|
||||
folderField.value = fp.file.path;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -199,13 +199,13 @@ nsresult nsMsgFilterService::BackUpFilterFile(nsIFileSpec *aFilterFile, nsIMsgWi
|
|||
nsCOMPtr <nsILocalFile> backupFile;
|
||||
rv = NS_FileSpecToIFile(&parentDirSpec, getter_AddRefs(backupFile));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
backupFile->Append("rulesbackup.dat");
|
||||
backupFile->Append(NS_LITERAL_CSTRING("rulesbackup.dat"));
|
||||
PRBool exists;
|
||||
backupFile->Exists(&exists);
|
||||
if (exists)
|
||||
backupFile->Remove(PR_FALSE);
|
||||
|
||||
return localFilterFile->CopyTo(localParentDir, "rulesbackup.dat");
|
||||
return localFilterFile->CopyTo(localParentDir, NS_LITERAL_CSTRING("rulesbackup.dat"));
|
||||
}
|
||||
|
||||
nsresult nsMsgFilterService::AlertBackingUpFilterFile(nsIMsgWindow *aMsgWindow)
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsILocalFile.h"
|
||||
#ifdef XP_MAC
|
||||
#include "nsIAppleFileDecoder.h"
|
||||
#endif
|
||||
|
@ -206,31 +207,27 @@ ConvertBufToPlainText(nsString &aConBuf)
|
|||
|
||||
nsresult ConvertAndSanitizeFileName(const char * displayName, PRUnichar ** unicodeResult, char ** result)
|
||||
{
|
||||
char * unescapedName = PL_strdup(displayName);
|
||||
if (!unescapedName)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsCAutoString unescapedName(displayName);
|
||||
|
||||
/* we need to convert the UTF-8 fileName to platform specific character set.
|
||||
The display name is in UTF-8 because it has been escaped from JS
|
||||
*/
|
||||
nsUnescape(unescapedName);
|
||||
nsAutoString ucs2Str = NS_ConvertUTF8toUCS2(unescapedName);
|
||||
PR_FREEIF(unescapedName);
|
||||
NS_UnescapeURL(unescapedName);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
#if defined(XP_MAC)
|
||||
/* We need to truncate the name to 31 characters, this even on MacOS X until the file API
|
||||
correctly support long file name. Using a nsILocalFIle will do the trick...
|
||||
correctly support long file name. Using a nsILocalFile will do the trick...
|
||||
*/
|
||||
nsCOMPtr<nsILocalFile> aLocalFile(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(aLocalFile->SetUnicodeLeafName(ucs2Str.get())))
|
||||
if (NS_SUCCEEDED(aLocalFile->SetLeafName(unescapedName)))
|
||||
{
|
||||
PRUnichar * tempStr;
|
||||
aLocalFile->GetUnicodeLeafName(&tempStr);
|
||||
ucs2Str.Adopt(tempStr);
|
||||
aLocalFile->GetLeafName(unescapedName);
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_ConvertUTF8toUCS2 ucs2Str(unescapedName);
|
||||
|
||||
// replace platform specific path separator and illegale characters to avoid any confusion
|
||||
ucs2Str.ReplaceChar(FILE_PATH_SEPARATOR FILE_ILLEGAL_CHARACTERS, '-');
|
||||
|
||||
|
@ -525,7 +522,7 @@ nsMessenger::PromptIfFileExists(nsFileSpec &fileSpec)
|
|||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
nsXPIDLCString filePath;
|
||||
nsCAutoString filePath;
|
||||
|
||||
rv = filePicker->GetFile(getter_AddRefs(localFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -533,9 +530,10 @@ nsMessenger::PromptIfFileExists(nsFileSpec &fileSpec)
|
|||
rv = SetLastSaveDirectory(localFile);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = localFile->GetPath(getter_Copies(filePath));
|
||||
rv = localFile->GetNativePath(filePath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
fileSpec = (const char*) filePath;
|
||||
|
||||
fileSpec = filePath.get();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
@ -788,7 +786,7 @@ nsMessenger::SaveAttachment(const char * contentType, const char * url,
|
|||
|
||||
PRInt16 dialogResult;
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
nsCOMPtr <nsILocalFile> lastSaveDir;
|
||||
nsCOMPtr<nsILocalFile> lastSaveDir;
|
||||
nsCOMPtr<nsIFileSpec> fileSpec;
|
||||
nsXPIDLCString filePath;
|
||||
nsXPIDLString defaultDisplayString;
|
||||
|
@ -826,12 +824,10 @@ nsMessenger::SaveAttachment(const char * contentType, const char * url,
|
|||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
(void)SetLastSaveDirectory(localFile);
|
||||
|
||||
rv = localFile->GetPath(getter_Copies(filePath));
|
||||
fileSpec = do_CreateInstance("@mozilla.org/filespec;1", &rv);
|
||||
|
||||
rv = NS_NewFileSpecFromIFile(localFile, getter_AddRefs(fileSpec));
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
fileSpec->SetNativePath(filePath);
|
||||
rv = SaveAttachment(fileSpec, unescapedUrl, messageUri, contentType, nsnull);
|
||||
|
||||
done:
|
||||
|
@ -880,8 +876,8 @@ nsMessenger::SaveAllAttachments(PRUint32 count,
|
|||
rv = SetLastSaveDirectory(localFile);
|
||||
if (NS_FAILED(rv))
|
||||
goto done;
|
||||
|
||||
rv = localFile->GetPath(getter_Copies(dirName));
|
||||
|
||||
rv = localFile->GetNativePath(dirName);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(fileSpec));
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
@ -978,10 +974,9 @@ nsMessenger::SaveAs(const char* url, PRBool asFile, nsIMsgIdentity* identity, ns
|
|||
if (NS_FAILED(rv))
|
||||
goto done;
|
||||
|
||||
nsXPIDLCString tmpFileName;
|
||||
rv = localFile->GetLeafName(getter_Copies(tmpFileName));
|
||||
nsCAutoString fileName;
|
||||
rv = localFile->GetLeafName(fileName);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
nsCAutoString fileName(tmpFileName);
|
||||
|
||||
// First, check if they put ANY extension on the file, if not,
|
||||
// then we should look at the type of file they have chosen and
|
||||
|
@ -1003,11 +998,9 @@ nsMessenger::SaveAs(const char* url, PRBool asFile, nsIMsgIdentity* identity, ns
|
|||
// XXX argh! converting from nsILocalFile to nsFileSpec ... oh baby, lets drop from unicode to ascii too
|
||||
// nsXPIDLString path;
|
||||
// localFile->GetUnicodePath(getter_Copies(path));
|
||||
nsXPIDLCString path;
|
||||
localFile->GetPath(getter_Copies(path));
|
||||
nsCOMPtr<nsIFileSpec> fileSpec = do_CreateInstance("@mozilla.org/filespec;1", &rv);
|
||||
nsCOMPtr<nsIFileSpec> fileSpec;
|
||||
rv = NS_NewFileSpecFromIFile(localFile, getter_AddRefs(fileSpec));
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
fileSpec->SetNativePath(path);
|
||||
|
||||
aListener = new nsSaveMsgListener(fileSpec, this);
|
||||
if (!aListener) {
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
@ -559,14 +560,8 @@ nsMessengerMigrator::CreateLocalMailAccount(PRBool migrating)
|
|||
// Convert the nsILocalFile into an nsIFileSpec
|
||||
// TODO: convert users os nsIFileSpec to nsILocalFile
|
||||
// and avoid this step.
|
||||
nsXPIDLCString mailDirPath;
|
||||
rv = mailDir->GetPath(getter_Copies(mailDirPath));
|
||||
rv = NS_NewFileSpecFromIFile(mailDir, getter_AddRefs(mailDirSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(mailDirSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = mailDirSpec->SetNativePath(mailDirPath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
// set the default local path for "none"
|
||||
rv = server->SetDefaultLocalPath(mailDirSpec);
|
||||
|
@ -1180,17 +1175,12 @@ nsMessengerMigrator::MigrateLocalMailAccount()
|
|||
rv = mailDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString mailDirPath;
|
||||
nsCOMPtr<nsIFileSpec> mailDirSpec;
|
||||
|
||||
// Convert the nsILocalFile into an nsIFileSpec
|
||||
// TODO: convert users of nsIFileSpec to nsILocalFile
|
||||
// and avoid this step.
|
||||
rv = mailDir->GetPath(getter_Copies(mailDirPath));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(mailDirSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = mailDirSpec->SetNativePath(mailDirPath);
|
||||
rv = NS_NewFileSpecFromIFile(mailDir, getter_AddRefs(mailDirSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// set the default local path for "none"
|
||||
|
@ -1294,15 +1284,11 @@ nsMessengerMigrator::MigrateMovemailAccount(nsIMsgIdentity *identity)
|
|||
if (NS_FAILED(rv)) {
|
||||
// we wan't <profile>/Mail
|
||||
nsCOMPtr<nsIFile> aFile;
|
||||
nsXPIDLCString pathBuf;
|
||||
|
||||
rv = NS_GetSpecialDirectory(NS_APP_MAIL_50_DIR, getter_AddRefs(aFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = aFile->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(mailDir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = mailDir->SetNativePath((const char *)pathBuf);
|
||||
|
||||
NS_NewFileSpecFromIFile(aFile, getter_AddRefs(mailDir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
@ -1447,17 +1433,12 @@ nsMessengerMigrator::MigratePopAccount(nsIMsgIdentity *identity)
|
|||
rv = mailDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString mailDirPath;
|
||||
nsCOMPtr<nsIFileSpec> mailDirSpec;
|
||||
|
||||
// Convert the nsILocalFile into an nsIFileSpec
|
||||
// TODO: convert users os nsIFileSpec to nsILocalFile
|
||||
// and avoid this step.
|
||||
rv = mailDir->GetPath(getter_Copies(mailDirPath));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(mailDirSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = mailDirSpec->SetNativePath(mailDirPath);
|
||||
rv = NS_NewFileSpecFromIFile(mailDir, getter_AddRefs(mailDirSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// set the default local path for "pop3"
|
||||
|
@ -1747,17 +1728,12 @@ nsMessengerMigrator::MigrateImapAccount(nsIMsgIdentity *identity, const char *ho
|
|||
rv = imapMailDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString pathBuf;
|
||||
nsCOMPtr<nsIFileSpec> imapMailDirSpec;
|
||||
|
||||
// Convert the nsILocalFile into an nsIFileSpec
|
||||
// TODO: convert users os nsIFileSpec to nsILocalFile
|
||||
// and avoid this step.
|
||||
rv = imapMailDir->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(imapMailDirSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = imapMailDirSpec->SetNativePath(pathBuf);
|
||||
rv = NS_NewFileSpecFromIFile(imapMailDir, getter_AddRefs(imapMailDirSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// we only need to do this once
|
||||
|
@ -1946,15 +1922,8 @@ nsMessengerMigrator::migrateAddressBookPrefEnum(const char *aPref, void *aClosur
|
|||
if (NS_FAILED(rv) || !ab4xFile) return;
|
||||
|
||||
// TODO: Change users of nsIFileSpec to nsIFile and avoid this.
|
||||
{
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = ab4xFile->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(ab4xFileSpec));
|
||||
if (NS_FAILED(rv)) return;
|
||||
rv = ab4xFileSpec->SetNativePath(pathBuf);
|
||||
if (NS_FAILED(rv)) return;
|
||||
}
|
||||
rv = NS_NewFileSpecFromIFile(ab4xFile, getter_AddRefs(ab4xFileSpec));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
rv = ab4xFileSpec->AppendRelativeUnixPath((const char *)abFileName);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"ab migration failed: failed to append filename");
|
||||
|
@ -1966,22 +1935,15 @@ nsMessengerMigrator::migrateAddressBookPrefEnum(const char *aPref, void *aClosur
|
|||
// do the migration in a subdirectory of temp, to prevent
|
||||
// collision (between multiple users), deleting TMPDIR
|
||||
// and privacy issues (where the temp ldif files are readable)
|
||||
rv = tmpLDIFFile->Append("addr-migrate");
|
||||
rv = tmpLDIFFile->Append(NS_LITERAL_CSTRING("addr-migrate"));
|
||||
if (NS_FAILED(rv) || !tmpLDIFFile) return;
|
||||
|
||||
rv = tmpLDIFFile->CreateUnique(nsIFile::DIRECTORY_TYPE, 0700);
|
||||
if (NS_FAILED(rv) || !tmpLDIFFile) return;
|
||||
|
||||
// TODO: Change users of nsIFileSpec to nsIFile and avoid this.
|
||||
{
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = tmpLDIFFile->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(tmpLDIFFileSpec));
|
||||
if (NS_FAILED(rv)) return;
|
||||
rv = tmpLDIFFileSpec->SetNativePath(pathBuf);
|
||||
if (NS_FAILED(rv)) return;
|
||||
}
|
||||
rv = NS_NewFileSpecFromIFile(tmpLDIFFile, getter_AddRefs(tmpLDIFFileSpec));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
// get the csid from the prefs
|
||||
nsCAutoString csidPrefName;
|
||||
|
@ -2124,10 +2086,10 @@ nsMessengerMigrator::MigrateNewsAccounts(nsIMsgIdentity *identity)
|
|||
|
||||
// TODO: convert users os nsIFileSpec to nsILocalFile
|
||||
// and avoid this step.
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = newsDir->GetPath(getter_Copies(pathBuf));
|
||||
nsCAutoString pathBuf;
|
||||
rv = newsDir->GetNativePath(pathBuf);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
newsHostsDir = pathBuf;
|
||||
newsHostsDir = pathBuf.get();
|
||||
|
||||
#ifdef USE_NEWSRC_MAP_FILE
|
||||
// if we are using the fat file, it lives in the newsHostsDir.
|
||||
|
@ -2264,10 +2226,10 @@ nsMessengerMigrator::MigrateNewsAccounts(nsIMsgIdentity *identity)
|
|||
newsDir = prefLocal;
|
||||
|
||||
{
|
||||
nsXPIDLCString pathBuf;
|
||||
newsDir->GetPath(getter_Copies(pathBuf));
|
||||
nsCAutoString pathBuf;
|
||||
newsDir->GetNativePath(pathBuf);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
newsrcDir = (const char *)pathBuf;
|
||||
newsrcDir = pathBuf.get();
|
||||
}
|
||||
|
||||
for (nsDirectoryIterator i(newsrcDir, PR_FALSE); i.Exists(); i++) {
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
#define XP_SHEnumerateUnreadMailAccounts "SHEnumerateUnreadMailAccountsW"
|
||||
#define ShellNotifyWideVersion "Shell_NotifyIconW"
|
||||
#define UNREADMAILNODEKEY "Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\"
|
||||
#define SHELL32_DLL "shell32.dll"
|
||||
#define SHELL32_DLL NS_LITERAL_CSTRING("shell32.dll")
|
||||
#define DOUBLE_QUOTE "\""
|
||||
#define PROFILE_COMMANDLINE_ARG " -p "
|
||||
#define MAIL_COMMANDLINE_ARG " -mail"
|
||||
|
@ -399,13 +399,11 @@ nsMessengerWinIntegration::Init()
|
|||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
// get path to shell dll.
|
||||
nsXPIDLCString shellFile;
|
||||
rv = systemDir->GetPath(getter_Copies(shellFile));
|
||||
nsCAutoString shellFile;
|
||||
rv = systemDir->GetNativePath(shellFile);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
mShellDllPath.Assign(shellFile);
|
||||
mShellDllPath.Append("\\");
|
||||
mShellDllPath.Append(SHELL32_DLL);
|
||||
mShellDllPath.Assign(shellFile + NS_LITERAL_CSTRING("\\") + SHELL32_DLL);
|
||||
|
||||
// load shell dll. If no such dll found, return
|
||||
HMODULE hModule = ::LoadLibrary(mShellDllPath.get());
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
#include "nsFileStream.h"
|
||||
#include "nsMsgUtils.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsISmtpService.h"
|
||||
|
@ -954,12 +955,7 @@ nsresult nsMsgAccountManager::GetFolderCache(nsIMsgFolderCache* *aFolderCache)
|
|||
|
||||
// TODO: Make nsIMsgFolderCache::Init take an nsIFile and
|
||||
// avoid this conversion.
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = cacheFile->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(cacheFileSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = cacheFileSpec->SetNativePath(pathBuf);
|
||||
rv = NS_NewFileSpecFromIFile(cacheFile, getter_AddRefs(cacheFileSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
m_msgFolderCache->Init(cacheFileSpec);
|
||||
|
|
|
@ -565,7 +565,7 @@ nsMsgMailSession::GetSelectedLocaleDataDir(nsIFile *defaultsDir)
|
|||
rv = defaultsDir->Clone(getter_AddRefs(localeDataDir));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = localeDataDir->AppendUnicode(localeName);
|
||||
rv = localeDataDir->Append(NS_ConvertUCS2toUTF8(localeName));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = localeDataDir->Exists(&localeDirExists);
|
||||
|
@ -573,7 +573,7 @@ nsMsgMailSession::GetSelectedLocaleDataDir(nsIFile *defaultsDir)
|
|||
|
||||
if (localeDirExists) {
|
||||
// use locale provider instead
|
||||
rv = defaultsDir->AppendUnicode(localeName);
|
||||
rv = defaultsDir->Append(NS_ConvertUCS2toUTF8(localeName));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
}
|
||||
}
|
||||
|
@ -603,7 +603,7 @@ nsMsgMailSession::GetDataFilesDir(const char* dirName, nsIFile **dataFilesDir)
|
|||
getter_AddRefs(defaultsDir));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
rv = defaultsDir->Append(dirName);
|
||||
rv = defaultsDir->AppendNative(nsDependentCString(dirName));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = GetSelectedLocaleDataDir(defaultsDir);
|
||||
|
||||
|
|
|
@ -452,15 +452,11 @@ nsMsgIncomingServer::GetFileValue(const char* prefname,
|
|||
|
||||
nsCOMPtr<nsILocalFile> prefLocal;
|
||||
nsCOMPtr<nsIFileSpec> outSpec;
|
||||
nsXPIDLCString pathBuf;
|
||||
|
||||
nsresult rv = m_prefs->GetFileXPref(fullPrefName.get(), getter_AddRefs(prefLocal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(outSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = prefLocal->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = outSpec->SetNativePath((const char *)pathBuf);
|
||||
|
||||
rv = NS_NewFileSpecFromIFile(prefLocal, getter_AddRefs(outSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*spec = outSpec;
|
||||
|
|
|
@ -110,6 +110,7 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsMsgSimulateError.h"
|
||||
#include "nsIAddrDatabase.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
// Defines....
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
@ -3063,7 +3064,7 @@ nsMsgCompose::ProcessSignature(nsIMsgIdentity *identity, nsString *aMsgBody)
|
|||
// are doing plain text compose, we should insert some sort of message
|
||||
// saying "Image Signature Omitted" or something.
|
||||
//
|
||||
nsXPIDLCString sigNativePath;
|
||||
nsCAutoString sigNativePath;
|
||||
PRBool useSigFile = PR_FALSE;
|
||||
PRBool htmlSig = PR_FALSE;
|
||||
PRBool imageSig = PR_FALSE;
|
||||
|
@ -3075,12 +3076,15 @@ nsMsgCompose::ProcessSignature(nsIMsgIdentity *identity, nsString *aMsgBody)
|
|||
rv = identity->GetAttachSignature(&useSigFile);
|
||||
if (NS_SUCCEEDED(rv) && useSigFile)
|
||||
{
|
||||
useSigFile = PR_FALSE; // by default, assume no signature file!
|
||||
|
||||
nsCOMPtr<nsILocalFile> sigFile;
|
||||
rv = identity->GetSignature(getter_AddRefs(sigFile));
|
||||
if (NS_SUCCEEDED(rv) && sigFile)
|
||||
rv = sigFile->GetPath(getter_Copies(sigNativePath));
|
||||
else
|
||||
useSigFile = PR_FALSE; //No signature file! therefore turn it off.
|
||||
if (NS_SUCCEEDED(rv) && sigFile) {
|
||||
rv = sigFile->GetNativePath(sigNativePath);
|
||||
if (NS_SUCCEEDED(rv) && !sigNativePath.IsEmpty())
|
||||
useSigFile = PR_TRUE; // ok, there's a signature file
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3090,7 +3094,7 @@ nsMsgCompose::ProcessSignature(nsIMsgIdentity *identity, nsString *aMsgBody)
|
|||
if ((!useSigFile) || NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
nsFileSpec testSpec(sigNativePath);
|
||||
nsFileSpec testSpec(sigNativePath.get());
|
||||
|
||||
// If this file doesn't really exist, just bail!
|
||||
if (!testSpec.Exists())
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "nsMsgImapCID.h"
|
||||
#include "nsImapMailFolder.h"
|
||||
#include "nsIEnumerator.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIFolderListener.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRDFService.h"
|
||||
|
@ -164,8 +165,8 @@ nsresult RecursiveCopy(nsIFile* srcDir, nsIFile* destDir)
|
|||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> newChild(do_QueryInterface(destClone));
|
||||
nsXPIDLCString leafName;
|
||||
dirEntry->GetLeafName(getter_Copies(leafName));
|
||||
nsCAutoString leafName;
|
||||
dirEntry->GetLeafName(leafName);
|
||||
newChild->AppendRelativePath(leafName);
|
||||
rv = newChild->Exists(&exists);
|
||||
if (NS_SUCCEEDED(rv) && !exists)
|
||||
|
@ -174,7 +175,7 @@ nsresult RecursiveCopy(nsIFile* srcDir, nsIFile* destDir)
|
|||
}
|
||||
}
|
||||
else
|
||||
rv = dirEntry->CopyTo(destDir, nsnull);
|
||||
rv = dirEntry->CopyTo(destDir, nsCString());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1431,11 +1432,9 @@ NS_IMETHODIMP nsImapMailFolder::RenameLocal(const char *newName, nsIMsgFolder *p
|
|||
nsCOMPtr<nsILocalFile> destDir = (do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCString oldPathStr (dirSpec.GetNativePathCString());
|
||||
srcDir->InitWithPath(oldPathStr.get());
|
||||
srcDir->InitWithNativePath(nsDependentCString(dirSpec.GetNativePathCString()));
|
||||
|
||||
nsCString newPathStr (parentPath.GetNativePathCString());
|
||||
destDir->InitWithPath(newPathStr.get());
|
||||
destDir->InitWithNativePath(nsDependentCString(parentPath.GetNativePathCString()));
|
||||
|
||||
rv = RecursiveCopy(srcDir, destDir);
|
||||
|
||||
|
|
|
@ -3593,13 +3593,9 @@ nsImapService::GetDefaultLocalPath(nsIFileSpec ** aResult)
|
|||
|
||||
// Make the resulting nsIFileSpec
|
||||
// TODO: Convert arg to nsILocalFile and avoid this
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = localFile->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIFileSpec> outSpec;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(outSpec));
|
||||
rv = NS_NewFileSpecFromIFile(localFile, getter_AddRefs(outSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
outSpec->SetNativePath(pathBuf);
|
||||
|
||||
if (!havePref || !exists)
|
||||
rv = SetDefaultLocalPath(outSpec);
|
||||
|
|
|
@ -89,7 +89,7 @@ nsComm4xProfile::GetMailDir(const PRUnichar *profileName, char **_retval)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr <nsILocalFile> profileLocation;
|
||||
profileLocation = do_QueryInterface(file);
|
||||
rv = profileLocation->Append(PREF_FILE_NAME_IN_4x);
|
||||
rv = profileLocation->Append(NS_LITERAL_CSTRING(PREF_FILE_NAME_IN_4x));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRBool exists = PR_FALSE;
|
||||
rv = profileLocation->Exists(&exists);
|
||||
|
@ -100,9 +100,12 @@ nsComm4xProfile::GetMailDir(const PRUnichar *profileName, char **_retval)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
if (prefValue) {
|
||||
#ifdef XP_MAC
|
||||
rv = profileLocation->SetPersistentDescriptor(prefValue.get());
|
||||
rv = profileLocation->SetPersistentDescriptor(prefValue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = profileLocation->GetPath(_retval);
|
||||
nsCAutoString nativePath;
|
||||
rv = profileLocation->GetNativePath(nativePath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
*_retval = ToNewCString(nativePath);
|
||||
#else
|
||||
*_retval = ToNewCString(prefValue);
|
||||
#endif
|
||||
|
@ -112,9 +115,12 @@ nsComm4xProfile::GetMailDir(const PRUnichar *profileName, char **_retval)
|
|||
nsCOMPtr <nsIFile> mailLocation;
|
||||
rv = resolvedLocation->Clone(getter_AddRefs(mailLocation));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = mailLocation->Append("Mail");
|
||||
rv = mailLocation->Append(NS_LITERAL_CSTRING("Mail"));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = mailLocation->GetPath(_retval);
|
||||
nsCAutoString nativePath;
|
||||
rv = mailLocation->GetNativePath(nativePath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
*_retval = ToNewCString(nativePath);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -594,13 +594,9 @@ nsMovemailService::GetDefaultLocalPath(nsIFileSpec ** aResult)
|
|||
|
||||
// Make the resulting nsIFileSpec
|
||||
// TODO: Convert arg to nsILocalFile and avoid this
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = localFile->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIFileSpec> outSpec;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(outSpec));
|
||||
rv = NS_NewFileSpecFromIFile(localFile, getter_AddRefs(outSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
outSpec->SetNativePath(pathBuf);
|
||||
|
||||
if (!havePref || !exists)
|
||||
rv = SetDefaultLocalPath(outSpec);
|
||||
|
|
|
@ -117,7 +117,7 @@ NS_IMETHODIMP nsNoIncomingServer::CopyDefaultMessages(const char *folderNameOnDi
|
|||
// check if bin/defaults/messenger/<folderNameOnDisk>
|
||||
// (or bin/defaults/messenger/<locale>/<folderNameOnDisk> if we had a locale provide) exists.
|
||||
// it doesn't have to exist. if it doesn't, return
|
||||
rv = defaultMessagesFile->Append(folderNameOnDisk);
|
||||
rv = defaultMessagesFile->AppendNative(nsDependentCString(folderNameOnDisk));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = defaultMessagesFile->Exists(&exists);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -137,7 +137,7 @@ NS_IMETHODIMP nsNoIncomingServer::CopyDefaultMessages(const char *folderNameOnDi
|
|||
nsCOMPtr<nsIFile> testDir;
|
||||
rv = localParentDir->Clone(getter_AddRefs(testDir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = testDir->Append(folderNameOnDisk);
|
||||
rv = testDir->AppendNative(nsDependentCString(folderNameOnDisk));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = testDir->Exists(&exists);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -156,7 +156,7 @@ NS_IMETHODIMP nsNoIncomingServer::CopyDefaultMessages(const char *folderNameOnDi
|
|||
#ifdef DEBUG_sspitzer
|
||||
printf("copy default %s\n",folderNameOnDisk);
|
||||
#endif
|
||||
rv = defaultMessagesFile->CopyTo(localParentDir, nsnull);
|
||||
rv = defaultMessagesFile->CopyTo(localParentDir, nsCString());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
|
|
|
@ -115,13 +115,9 @@ nsNoneService::GetDefaultLocalPath(nsIFileSpec ** aResult)
|
|||
|
||||
// Make the resulting nsIFileSpec
|
||||
// TODO: Convert arg to nsILocalFile and avoid this
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = localFile->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIFileSpec> outSpec;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(outSpec));
|
||||
rv = NS_NewFileSpecFromIFile(localFile, getter_AddRefs(outSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
outSpec->SetNativePath(pathBuf);
|
||||
|
||||
if (!havePref || !exists)
|
||||
rv = SetDefaultLocalPath(outSpec);
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "nsMsgMessageFlags.h"
|
||||
#include "nsIDBFolderInfo.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsMsgLocalFolderHdrs.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsMsgDBCID.h"
|
||||
|
@ -1554,13 +1555,14 @@ nsOutputFileStream * nsParseNewMailState::GetLogFile ()
|
|||
nsCOMPtr<nsIFile> logDir;
|
||||
NS_GetSpecialDirectory(NS_APP_MAIL_50_DIR, getter_AddRefs(logDir));
|
||||
|
||||
nsXPIDLCString pathBuf;
|
||||
logDir->Append("filter.log");
|
||||
nsresult rv = logDir->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return nsnull;
|
||||
nsCOMPtr<nsIFileSpec> outSpec;
|
||||
logDir->Append(NS_LITERAL_CSTRING("filter.log"));
|
||||
|
||||
nsCAutoString pathBuf;
|
||||
nsresult rv = logDir->GetNativePath(pathBuf);
|
||||
if (NS_FAILED(rv)) return nsnull;
|
||||
|
||||
nsFileSpec logFile(pathBuf.get());
|
||||
|
||||
nsFileSpec logFile(pathBuf);
|
||||
m_logFile = new nsOutputFileStream(logFile, PR_WRONLY | PR_CREATE_FILE, 00600);
|
||||
}
|
||||
return m_logFile;
|
||||
|
|
|
@ -483,13 +483,9 @@ nsPop3Service::GetDefaultLocalPath(nsIFileSpec ** aResult)
|
|||
|
||||
// Make the resulting nsIFileSpec
|
||||
// TODO: Convert arg to nsILocalFile and avoid this
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = localFile->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIFileSpec> outSpec;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(outSpec));
|
||||
rv = NS_NewFileSpecFromIFile(localFile, getter_AddRefs(outSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
outSpec->SetNativePath(pathBuf);
|
||||
|
||||
if (!havePref || !exists)
|
||||
rv = SetDefaultLocalPath(outSpec);
|
||||
|
|
|
@ -518,9 +518,9 @@ nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32
|
|||
{
|
||||
// check if attachment exists
|
||||
if (aIsUnicode)
|
||||
pFile->InitWithUnicodePath (aFiles[i].lpszPathName) ;
|
||||
pFile->InitWithPath (NS_ConvertUCS2toUTF8(aFiles[i].lpszPathName)) ;
|
||||
else
|
||||
pFile->InitWithPath ((char *) aFiles[i].lpszPathName) ;
|
||||
pFile->InitWithNativePath (nsDependentCString((const char*)aFiles[i].lpszPathName)) ;
|
||||
PRBool bExist ;
|
||||
rv = pFile->Exists(&bExist) ;
|
||||
if (NS_FAILED(rv) || (!bExist) ) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ;
|
||||
|
@ -540,33 +540,35 @@ nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32
|
|||
rv = NS_FileSpecToIFile(&tmpDir, getter_AddRefs(pTempPath)) ;
|
||||
if(NS_FAILED(rv) || !pTempPath) return rv ;
|
||||
// temp dir path
|
||||
nsXPIDLString tempPath ;
|
||||
rv = pTempPath->GetUnicodePath (getter_Copies(tempPath)) ;
|
||||
nsCAutoString tempPath ;
|
||||
rv = pTempPath->GetPath (tempPath) ;
|
||||
if(NS_FAILED(rv) || tempPath.IsEmpty()) return rv ;
|
||||
|
||||
// filename of the file attachment
|
||||
nsXPIDLString leafName ;
|
||||
pFile->GetUnicodeLeafName (getter_Copies(leafName)) ;
|
||||
nsCAutoString leafName ;
|
||||
pFile->GetLeafName (leafName) ;
|
||||
if(NS_FAILED(rv) || leafName.IsEmpty()) return rv ;
|
||||
// full path of the file attachment
|
||||
nsXPIDLString path ;
|
||||
pFile->GetUnicodePath (getter_Copies(path)) ;
|
||||
nsCAutoString path ;
|
||||
pFile->GetPath (path) ;
|
||||
if(NS_FAILED(rv) || path.IsEmpty()) return rv ;
|
||||
|
||||
// dir path of the file attachment
|
||||
nsAutoString dirPath (path.get()) ;
|
||||
nsCAutoString dirPath (path.get()) ;
|
||||
PRInt32 offset = dirPath.Find (leafName.get()) ;
|
||||
if (offset != kNotFound && offset > 1)
|
||||
dirPath.SetLength(offset-1) ;
|
||||
// see if the attachment dir path (only) is same as temp path
|
||||
if (!Compare(tempPath, dirPath, nsCaseInsensitiveStringComparator()))
|
||||
// XXX need nsCaseInsensitiveUTF8StringComparator()
|
||||
if (!Compare(NS_ConvertUTF8toUCS2(tempPath),
|
||||
NS_ConvertUTF8toUCS2(dirPath),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
// if not already existing, create another temp dir for mapi within Win temp dir
|
||||
nsAutoString strTempDir ;
|
||||
strTempDir += tempPath.get() ;
|
||||
nsCAutoString strTempDir ;
|
||||
// this is windows only so we can do "\\"
|
||||
strTempDir.AppendWithConversion("\\moz_mapi") ;
|
||||
pTempDir->InitWithUnicodePath (strTempDir.get()) ;
|
||||
strTempDir = tempPath + NS_LITERAL_CSTRING("\\moz_mapi");
|
||||
pTempDir->InitWithPath (strTempDir) ;
|
||||
pTempDir->Exists (&bExist) ;
|
||||
if (!bExist)
|
||||
{
|
||||
|
@ -582,21 +584,25 @@ nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32
|
|||
// rename or copy the existing temp file with the real file name
|
||||
if (aIsUnicode)
|
||||
{
|
||||
NS_ConvertUCS2toUTF8 fileNameUTF8(aFiles[i].lpszFileName);
|
||||
// check if the user is sending a temporary unsaved file, in this case
|
||||
// the leaf name of the PathName and the FileName (real filename) would be same
|
||||
// if so copy the file (this will create a copy file) and then send else move would do nothing
|
||||
// and the calling app would delete the file and then send will fail.
|
||||
if (!Compare(nsDependentString(aFiles[i].lpszFileName), nsDependentString(leafName), nsCaseInsensitiveStringComparator()))
|
||||
// XXX need nsCaseInsensitiveUTF8StringComparator()
|
||||
if (!Compare(nsDependentString(aFiles[i].lpszFileName),
|
||||
NS_ConvertUTF8toUCS2(leafName),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
rv = pFile->CopyToUnicode(pTempDir, aFiles[i].lpszFileName) ;
|
||||
pFile->InitWithUnicodePath(strTempDir.get()) ;
|
||||
pFile->AppendUnicode (aFiles[i].lpszFileName) ;
|
||||
rv = pFile->CopyTo(pTempDir, fileNameUTF8);
|
||||
pFile->InitWithPath(strTempDir) ;
|
||||
pFile->Append(fileNameUTF8);
|
||||
}
|
||||
else
|
||||
{
|
||||
// else if user is sending an already existing file open in the application
|
||||
// just move the file to one with real file name, better performance
|
||||
rv = pFile->MoveToUnicode(nsnull, aFiles[i].lpszFileName) ;
|
||||
rv = pFile->MoveTo(nsnull, fileNameUTF8);
|
||||
// now create an empty file with the temp filename so that
|
||||
// the calling apps donot crash if they dont find their temp file
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
@ -613,18 +619,22 @@ nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32
|
|||
// convert to Unicode using Platform charset
|
||||
rv = ConvertToUnicode(nsMsgI18NFileSystemCharset(), (char *) aFiles[i].lpszFileName, fileName);
|
||||
if (NS_FAILED(rv)) return rv ;
|
||||
nsDependentCString fileNameNative((char *) aFiles[i].lpszFileName);
|
||||
// now compare the unicode filename string
|
||||
if (!Compare(fileName, leafName, nsCaseInsensitiveStringComparator()))
|
||||
// XXX need nsCaseInsensitiveUTF8StringComparator()
|
||||
if (!Compare(fileName,
|
||||
NS_ConvertUTF8toUCS2(leafName),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
rv = pFile->CopyTo(pTempDir, (char *) aFiles[i].lpszFileName) ;
|
||||
pFile->InitWithUnicodePath(strTempDir.get()) ;
|
||||
pFile->Append ((char *) aFiles[i].lpszFileName) ;
|
||||
rv = pFile->CopyToNative(pTempDir, fileNameNative);
|
||||
pFile->InitWithPath(strTempDir) ;
|
||||
pFile->AppendNative (fileNameNative);
|
||||
}
|
||||
else
|
||||
{
|
||||
// else if user is sending an already existing file open in the application
|
||||
// just move the file to one with real file name, better performance
|
||||
rv = pFile->MoveTo(nsnull, (char *) aFiles[i].lpszFileName) ;
|
||||
rv = pFile->MoveToNative(nsnull, fileNameNative);
|
||||
// now create an empty file with the temp filename so that
|
||||
// the calling apps donot crash if they dont find their temp file
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
@ -780,7 +790,7 @@ nsresult nsMapiHook::PopulateCompFieldsForSendDocs(nsIMsgCompFields * aCompField
|
|||
{
|
||||
nsCOMPtr <nsILocalFile> pFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ;
|
||||
if (NS_FAILED(rv) || (!pFile) ) return rv ;
|
||||
pFile->InitWithUnicodePath (strFilePaths.get()) ;
|
||||
pFile->InitWithPath (NS_ConvertUCS2toUTF8(strFilePaths)) ;
|
||||
|
||||
PRBool bExist ;
|
||||
rv = pFile->Exists(&bExist) ;
|
||||
|
@ -816,7 +826,7 @@ nsresult nsMapiHook::PopulateCompFieldsForSendDocs(nsIMsgCompFields * aCompField
|
|||
newFilePaths += offset + strDelimChars.Length() ;
|
||||
}
|
||||
|
||||
pFile->InitWithUnicodePath (RemainingPaths.get()) ;
|
||||
pFile->InitWithPath (NS_ConvertUCS2toUTF8(RemainingPaths)) ;
|
||||
|
||||
#ifdef RAJIV_DEBUG
|
||||
printf ("File : %S \n", RemainingPaths.get()) ;
|
||||
|
|
|
@ -366,7 +366,7 @@ nsresult nsMapiRegistryUtils::CopyMozMapiToWinSysDir()
|
|||
|
||||
nsCOMPtr<nsILocalFile> pCurrentMapiFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv) || !pCurrentMapiFile) return rv;
|
||||
pCurrentMapiFile->InitWithPath(filePath.get());
|
||||
pCurrentMapiFile->InitWithNativePath(filePath);
|
||||
|
||||
nsCOMPtr<nsIFile> pMozMapiFile;
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
|
@ -377,7 +377,7 @@ nsresult nsMapiRegistryUtils::CopyMozMapiToWinSysDir()
|
|||
getter_AddRefs(pMozMapiFile));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
pMozMapiFile->Append("mozMapi32.dll");
|
||||
pMozMapiFile->Append(NS_LITERAL_CSTRING("mozMapi32.dll"));
|
||||
|
||||
PRBool bExist;
|
||||
rv = pMozMapiFile->Exists(&bExist);
|
||||
|
@ -390,15 +390,15 @@ nsresult nsMapiRegistryUtils::CopyMozMapiToWinSysDir()
|
|||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
filePath.Assign(buffer);
|
||||
filePath.Append("\\Mapi32.dll");
|
||||
pCurrentMapiFile->InitWithPath(filePath.get());
|
||||
filePath.Append(NS_LITERAL_CSTRING("\\Mapi32.dll"));
|
||||
pCurrentMapiFile->InitWithNativePath(filePath);
|
||||
rv = pCurrentMapiFile->Exists(&bExist);
|
||||
if (NS_SUCCEEDED(rv) && bExist)
|
||||
{
|
||||
rv = pCurrentMapiFile->MoveTo(nsnull, "Mapi32_moz_bak.dll");
|
||||
rv = pCurrentMapiFile->MoveTo(nsnull, NS_LITERAL_CSTRING("Mapi32_moz_bak.dll"));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCAutoString fullFilePath(buffer);
|
||||
fullFilePath.Append("\\Mapi32_moz_bak.dll");
|
||||
fullFilePath.Append(NS_LITERAL_CSTRING("\\Mapi32_moz_bak.dll"));
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
"Mapi_backup_dll",
|
||||
|
@ -409,10 +409,10 @@ nsresult nsMapiRegistryUtils::CopyMozMapiToWinSysDir()
|
|||
}
|
||||
}
|
||||
|
||||
NS_NAMED_LITERAL_STRING(fileName, "Mapi32.dll");
|
||||
NS_NAMED_LITERAL_CSTRING(fileName, "Mapi32.dll");
|
||||
filePath.Assign(buffer);
|
||||
pCurrentMapiFile->InitWithPath(filePath.get());
|
||||
rv = pMozMapiFile->CopyToUnicode(pCurrentMapiFile, fileName.get());
|
||||
pCurrentMapiFile->InitWithNativePath(filePath);
|
||||
rv = pMozMapiFile->CopyTo(pCurrentMapiFile, fileName);
|
||||
if (NS_FAILED(rv))
|
||||
RestoreBackedUpMapiDll();
|
||||
return rv;
|
||||
|
@ -430,16 +430,16 @@ nsresult nsMapiRegistryUtils::RestoreBackedUpMapiDll()
|
|||
|
||||
nsCAutoString filePath(buffer);
|
||||
nsCAutoString previousFileName(buffer);
|
||||
filePath.Append("\\Mapi32.dll");
|
||||
previousFileName.Append("\\Mapi32_moz_bak.dll");
|
||||
filePath.Append(NS_LITERAL_CSTRING("\\Mapi32.dll"));
|
||||
previousFileName.Append(NS_LITERAL_CSTRING("\\Mapi32_moz_bak.dll"));
|
||||
|
||||
nsCOMPtr <nsILocalFile> pCurrentMapiFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv) || !pCurrentMapiFile) return NS_ERROR_FAILURE;
|
||||
pCurrentMapiFile->InitWithPath(filePath.get());
|
||||
pCurrentMapiFile->InitWithNativePath(filePath);
|
||||
|
||||
nsCOMPtr<nsILocalFile> pPreviousMapiFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv) || !pPreviousMapiFile) return NS_ERROR_FAILURE;
|
||||
pPreviousMapiFile->InitWithPath(previousFileName.get());
|
||||
pPreviousMapiFile->InitWithNativePath(previousFileName);
|
||||
|
||||
PRBool bExist;
|
||||
rv = pCurrentMapiFile->Exists(&bExist);
|
||||
|
@ -450,7 +450,7 @@ nsresult nsMapiRegistryUtils::RestoreBackedUpMapiDll()
|
|||
|
||||
rv = pPreviousMapiFile->Exists(&bExist);
|
||||
if (NS_SUCCEEDED(rv) && bExist)
|
||||
rv = pPreviousMapiFile->MoveTo(nsnull, "Mapi32.dll");
|
||||
rv = pPreviousMapiFile->MoveTo(nsnull, NS_LITERAL_CSTRING("Mapi32.dll"));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
DeleteRegistryValue(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
|
|
|
@ -271,13 +271,9 @@ nsNntpIncomingServer::GetNewsrcRootPath(nsIFileSpec **aNewsrcRootPath)
|
|||
|
||||
// Make the resulting nsIFileSpec
|
||||
// TODO: Convert arg to nsILocalFile and avoid this
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = localFile->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIFileSpec> outSpec;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(outSpec));
|
||||
rv = NS_NewFileSpecFromIFile(localFile, getter_AddRefs(outSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
outSpec->SetNativePath(pathBuf);
|
||||
|
||||
if (!havePref || !exists)
|
||||
rv = SetNewsrcRootPath(outSpec);
|
||||
|
|
|
@ -1369,13 +1369,9 @@ nsNntpService::GetDefaultLocalPath(nsIFileSpec ** aResult)
|
|||
|
||||
// Make the resulting nsIFileSpec
|
||||
// TODO: Convert arg to nsILocalFile and avoid this
|
||||
nsXPIDLCString pathBuf;
|
||||
rv = localFile->GetPath(getter_Copies(pathBuf));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIFileSpec> outSpec;
|
||||
rv = NS_NewFileSpec(getter_AddRefs(outSpec));
|
||||
rv = NS_NewFileSpecFromIFile(localFile, getter_AddRefs(outSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
outSpec->SetNativePath(pathBuf);
|
||||
|
||||
if (!havePref || !exists)
|
||||
rv = SetDefaultLocalPath(outSpec);
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsJARInputStream.h"
|
||||
#include "nsJAR.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -275,16 +275,15 @@ nsJAR::Extract(const char *zipEntry, nsIFile* outFile)
|
|||
else
|
||||
{
|
||||
#if defined(XP_UNIX)
|
||||
nsXPIDLCString path;
|
||||
|
||||
rv = outFile->GetPath(getter_Copies(path));
|
||||
nsCAutoString path;
|
||||
rv = outFile->GetNativePath(path);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
if (item->flags & ZIFLAG_SYMLINK)
|
||||
{
|
||||
err = mZip.ResolveSymlink(path,item);
|
||||
err = mZip.ResolveSymlink(path.get(),item);
|
||||
}
|
||||
chmod(path, item->mode);
|
||||
chmod(path.get(), item->mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1205,8 +1204,8 @@ nsZipReaderCache::GetZip(nsIFile* zipFile, nsIZipReader* *result)
|
|||
mZipCacheLookups++;
|
||||
#endif
|
||||
|
||||
nsXPIDLCString path;
|
||||
rv = zipFile->GetPath(getter_Copies(path));
|
||||
nsCAutoString path;
|
||||
rv = zipFile->GetNativePath(path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCStringKey key(path);
|
||||
|
@ -1329,8 +1328,8 @@ nsZipReaderCache::ReleaseZip(nsJAR* zip)
|
|||
rv = oldest->GetFile(getter_AddRefs(zipFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString path;
|
||||
rv = zipFile->GetPath(getter_Copies(path));
|
||||
nsCAutoString path;
|
||||
rv = zipFile->GetNativePath(path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCStringKey key(path);
|
||||
|
@ -1338,7 +1337,7 @@ nsZipReaderCache::ReleaseZip(nsJAR* zip)
|
|||
NS_ASSERTION(removed, "botched");
|
||||
|
||||
#ifdef xDEBUG_jband
|
||||
printf("dumped %s from the jar cache\n", (const char*) path);
|
||||
printf("dumped %s from the jar cache\n", path.get());
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -136,7 +136,7 @@ nsIconChannel::Open(nsIInputStream **_retval)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, char ** aContentType, char ** aFileExtension)
|
||||
nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsACString &aContentType, nsACString &aFileExtension)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMozIconURI> iconURI (do_QueryInterface(mUrl, &rv));
|
||||
|
@ -251,11 +251,11 @@ nsIconChannel::GetLockedIcons(IconFamilyHandle icnFamily, PRUint32 desiredImageS
|
|||
NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
||||
{
|
||||
nsCOMPtr<nsIFile> localFile; // file we want an icon for
|
||||
nsXPIDLCString contentType;
|
||||
nsXPIDLCString fileExtension;
|
||||
nsCAutoString contentType;
|
||||
nsCAutoString fileExtension;
|
||||
PRUint32 desiredImageSize;
|
||||
nsresult rv = ExtractIconInfoFromUrl(getter_AddRefs(localFile), &desiredImageSize,
|
||||
getter_Copies(contentType), getter_Copies(fileExtension));
|
||||
contentType, fileExtension);
|
||||
if (NS_FAILED(rv)) return(rv);
|
||||
|
||||
// ensure that we DO NOT resolve aliases, very important for file views
|
||||
|
@ -333,13 +333,13 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports
|
|||
nsCOMPtr<nsIMIMEInfo> mimeInfo;
|
||||
if (mimeService)
|
||||
{
|
||||
if (*contentType.get())
|
||||
if (!contentType.IsEmpty())
|
||||
{
|
||||
mimeService->GetFromMIMEType(contentType, getter_AddRefs(mimeInfo));
|
||||
mimeService->GetFromMIMEType(contentType.get(), getter_AddRefs(mimeInfo));
|
||||
}
|
||||
if (!mimeInfo) // try to grab an extension for the dummy file in the url.
|
||||
{
|
||||
mimeService->GetFromExtension(fileExtension, getter_AddRefs(mimeInfo));
|
||||
mimeService->GetFromExtension(fileExtension.get(), getter_AddRefs(mimeInfo));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ protected:
|
|||
nsresult mStatus;
|
||||
|
||||
nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize,
|
||||
char ** aContentType, char ** aFileExtension);
|
||||
nsACString &aContentType, nsACString &aFileExtension);
|
||||
|
||||
nsresult GetLockedIconData(IconFamilyHandle iconFamilyH, PRUint32 iconType,
|
||||
Handle iconDataH, PRUint32 *iconDataSize);
|
||||
|
|
|
@ -41,6 +41,6 @@ interface nsIMozIconURI : nsIURI
|
|||
attribute nsIURI IconFile; // maybe null if there isn't a real file we are trying to fetch
|
||||
|
||||
attribute unsigned long imageSize; // measured by # of pixels in a row. defaults to 16.
|
||||
attribute string contentType; // may be an empty string
|
||||
readonly attribute string fileExtension;
|
||||
attribute ACString contentType; // may be an empty string
|
||||
readonly attribute ACString fileExtension;
|
||||
};
|
||||
|
|
|
@ -385,21 +385,21 @@ nsMozIconURI::SetImageSize(PRUint32 aImageSize) // measured by # of pixels in a
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMozIconURI::GetContentType(char ** aContentType)
|
||||
nsMozIconURI::GetContentType(nsACString &aContentType)
|
||||
{
|
||||
*aContentType = ToNewCString(mContentType);
|
||||
aContentType = mContentType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMozIconURI::SetContentType(const char * aContentType)
|
||||
nsMozIconURI::SetContentType(const nsACString &aContentType)
|
||||
{
|
||||
mContentType = aContentType;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMozIconURI::GetFileExtension(char ** aFileExtension)
|
||||
nsMozIconURI::GetFileExtension(nsACString &aFileExtension)
|
||||
{
|
||||
nsCAutoString fileExtension;
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -416,11 +416,7 @@ nsMozIconURI::GetFileExtension(char ** aFileExtension)
|
|||
{
|
||||
// unfortunately, this code doesn't give us the required '.' in front of the extension
|
||||
// so we have to do it ourselves..
|
||||
nsCAutoString tempFileExt;
|
||||
tempFileExt = ".";
|
||||
tempFileExt.Append(fileExt);
|
||||
|
||||
*aFileExtension = ToNewCString(tempFileExt);
|
||||
aFileExtension = NS_LITERAL_CSTRING(".") + fileExt;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +434,7 @@ nsMozIconURI::GetFileExtension(char ** aFileExtension)
|
|||
const char * fileExt = strrchr(chFileName, '.');
|
||||
if (!fileExt) return NS_ERROR_FAILURE; // no file extension to work from.
|
||||
else
|
||||
*aFileExtension = nsCRT::strdup(fileExt);
|
||||
aFileExtension = nsDependentCString(fileExt);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ void InvertRows(unsigned char * aInitialBuffer, PRUint32 sizeOfBuffer, PRUint32
|
|||
nsMemory::Free(temporaryRowHolder);
|
||||
}
|
||||
|
||||
nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, char ** aContentType, char ** aFileExtension)
|
||||
nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsACString &aContentType, nsACString &aFileExtension)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIMozIconURI> iconURI (do_QueryInterface(mUrl, &rv));
|
||||
|
@ -298,10 +298,10 @@ void ConvertMaskBitMap(unsigned char * aBitMaskBuffer, PBITMAPINFOHEADER pBitMap
|
|||
NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
|
||||
{
|
||||
nsXPIDLCString contentType;
|
||||
nsXPIDLCString filePath;
|
||||
nsCAutoString filePath;
|
||||
nsCOMPtr<nsIFile> localFile; // file we want an icon for
|
||||
PRUint32 desiredImageSize;
|
||||
nsresult rv = ExtractIconInfoFromUrl(getter_AddRefs(localFile), &desiredImageSize, getter_Copies(contentType), getter_Copies(filePath));
|
||||
nsresult rv = ExtractIconInfoFromUrl(getter_AddRefs(localFile), &desiredImageSize, contentType, filePath);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// if the file exists, we are going to use it's real attributes...otherwise we only want to use it for it's extension...
|
||||
|
@ -312,7 +312,7 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports
|
|||
|
||||
if (localFile)
|
||||
{
|
||||
localFile->GetPath(getter_Copies(filePath));
|
||||
localFile->GetNativePath(filePath);
|
||||
localFile->Exists(&fileExists);
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports
|
|||
else
|
||||
infoFlags |= SHGFI_SMALLICON;
|
||||
|
||||
if ( (!filePath.get()) && (contentType.get() && *contentType.get()) ) // if we have a content type without a file extension...then use it!
|
||||
if ( (filePath.IsEmpty()) && (contentType.get() && *contentType.get()) ) // if we have a content type without a file extension...then use it!
|
||||
{
|
||||
nsCOMPtr<nsIMIMEService> mimeService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
|
||||
nsCOMPtr<nsIMIMEInfo> mimeObject;
|
||||
|
@ -336,10 +336,7 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports
|
|||
nsXPIDLCString fileExt;
|
||||
mimeObject->GetPrimaryExtension(getter_Copies(fileExt));
|
||||
// we need to insert a '.' b4 the extension...
|
||||
nsCAutoString formattedFileExt;
|
||||
formattedFileExt = ".";
|
||||
formattedFileExt.Append(fileExt.get());
|
||||
filePath.Assign(formattedFileExt);
|
||||
filePath = NS_LITERAL_CSTRING(".") + fileExt;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ protected:
|
|||
nsCOMPtr<nsISupports> mOwner;
|
||||
nsresult mStatus;
|
||||
|
||||
nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, char ** aContentType, char ** aFileExtension);
|
||||
nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsACString &aContentType, nsACString &aFileExtension);
|
||||
};
|
||||
|
||||
#endif /* nsIconChannel_h___ */
|
||||
|
|
|
@ -357,7 +357,7 @@ NS_IMETHODIMP nsPrefBranch::GetComplexValue(const char *aPrefName, const nsIID &
|
|||
return rv;
|
||||
|
||||
nsCOMPtr<nsILocalFile> theFile;
|
||||
rv = NS_NewLocalFile(nsnull, PR_TRUE, getter_AddRefs(theFile));
|
||||
rv = NS_NewLocalFile(nsCString(), PR_TRUE, getter_AddRefs(theFile));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
rv = theFile->SetRelativeDescriptor(fromFile, Substring(++keyEnd, strEnd));
|
||||
|
@ -420,11 +420,11 @@ NS_IMETHODIMP nsPrefBranch::SetComplexValue(const char *aPrefName, const nsIID &
|
|||
|
||||
if (aType.Equals(NS_GET_IID(nsILocalFile))) {
|
||||
nsCOMPtr<nsILocalFile> file = do_QueryInterface(aValue);
|
||||
nsXPIDLCString descriptorString;
|
||||
nsCAutoString descriptorString;
|
||||
|
||||
rv = file->GetPersistentDescriptor(getter_Copies(descriptorString));
|
||||
rv = file->GetPersistentDescriptor(descriptorString);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = SetCharPref(aPrefName, descriptorString);
|
||||
rv = SetCharPref(aPrefName, descriptorString.get());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "nsICategoryManager.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIFileStreams.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsPrefBranch.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
@ -313,7 +314,7 @@ nsresult nsPrefService::UseDefaultPrefFile()
|
|||
// knows about NS_APP_PREFS_50_FILE. Put the file in NS_XPCOM_CURRENT_PROCESS_DIR.
|
||||
rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR, getter_AddRefs(aFile));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = aFile->Append("default_prefs.js");
|
||||
rv = aFile->Append(NS_LITERAL_CSTRING("default_prefs.js"));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
@ -333,11 +334,9 @@ nsresult nsPrefService::UseUserPrefFile()
|
|||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIFile> aFile;
|
||||
|
||||
static const char* userFiles[] = {"user.js"};
|
||||
|
||||
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(aFile));
|
||||
if (NS_SUCCEEDED(rv) && aFile) {
|
||||
rv = aFile->Append(userFiles[0]);
|
||||
rv = aFile->Append(NS_LITERAL_CSTRING("user.js"));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = openPrefFile(aFile, PR_FALSE, PR_FALSE, PR_FALSE);
|
||||
}
|
||||
|
@ -409,8 +408,8 @@ static nsresult openPrefFile(nsIFile* aFile, PRBool aIsErrorFatal,
|
|||
|
||||
#if MOZ_TIMELINE
|
||||
{
|
||||
nsXPIDLCString str;
|
||||
aFile->GetPath(getter_Copies(str));
|
||||
nsCAutoString str;
|
||||
aFile->GetNativePath(str);
|
||||
NS_TIMELINE_MARK_FUNCTION1("load pref file", str.get());
|
||||
}
|
||||
#endif
|
||||
|
@ -459,28 +458,24 @@ static nsresult openPrefFile(nsIFile* aFile, PRBool aIsErrorFatal,
|
|||
static int PR_CALLBACK
|
||||
inplaceSortCallback(const void *data1, const void *data2, void *privateData)
|
||||
{
|
||||
char *name1 = nsnull;
|
||||
char *name2 = nsnull;
|
||||
nsCAutoString name1;
|
||||
nsCAutoString name2;
|
||||
nsIFile *file1= *(nsIFile **)data1;
|
||||
nsIFile *file2= *(nsIFile **)data2;
|
||||
nsresult rv;
|
||||
int sortResult = 0;
|
||||
|
||||
rv = file1->GetLeafName(&name1);
|
||||
rv = file1->GetNativeLeafName(name1);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to get the leaf name");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = file2->GetLeafName(&name2);
|
||||
rv = file2->GetNativeLeafName(name2);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to get the leaf name");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (name1 && name2) {
|
||||
if (!name1.IsEmpty() && !name2.IsEmpty()) {
|
||||
// we want it so foo.js will come before foo-<bar>.js
|
||||
// "foo." is before "foo-", so we have to reverse the order to accomplish
|
||||
sortResult = PL_strcmp(name2,name1);
|
||||
sortResult = Compare(name2, name1); // XXX i18n
|
||||
}
|
||||
if (name1)
|
||||
nsCRT::free((char*)name1);
|
||||
if (name2)
|
||||
nsCRT::free((char*)name2);
|
||||
}
|
||||
}
|
||||
return sortResult;
|
||||
|
@ -544,20 +539,20 @@ JSBool pref_InitInitialObjects()
|
|||
|
||||
while (hasMoreElements) {
|
||||
PRBool shouldParse = PR_TRUE;
|
||||
char* leafName;
|
||||
nsCAutoString leafName;
|
||||
|
||||
dirIterator->GetNext(getter_AddRefs(aFile));
|
||||
dirIterator->HasMoreElements(&hasMoreElements);
|
||||
|
||||
rv = aFile->GetLeafName(&leafName);
|
||||
rv = aFile->GetNativeLeafName(leafName);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Skip non-js files
|
||||
if (PL_strstr(leafName, ".js") + PL_strlen(".js") != leafName + PL_strlen(leafName))
|
||||
if ((leafName.Length() < 3) || !Substring(leafName, leafName.Length() - 3, 3).Equals(NS_LITERAL_CSTRING(".js")))
|
||||
shouldParse = PR_FALSE;
|
||||
// Skip files in the special list.
|
||||
if (shouldParse) {
|
||||
for (int j = 0; j < (int) (sizeof(specialFiles) / sizeof(char *)); j++)
|
||||
if (!PL_strcmp(leafName, specialFiles[j]))
|
||||
if (!strcmp(leafName.get(), specialFiles[j]))
|
||||
shouldParse = PR_FALSE;
|
||||
}
|
||||
if (shouldParse) {
|
||||
|
@ -571,8 +566,6 @@ JSBool pref_InitInitialObjects()
|
|||
}
|
||||
}
|
||||
}
|
||||
if (leafName)
|
||||
nsCRT::free((char*)leafName);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -592,7 +585,7 @@ JSBool pref_InitInitialObjects()
|
|||
// because SetLeafName will not work here.
|
||||
rv = defaultPrefDir->Clone(getter_AddRefs(aFile));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = aFile->Append((char*)specialFiles[k]);
|
||||
rv = aFile->Append(nsDependentCString(specialFiles[k]));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = openPrefFile(aFile, PR_FALSE, PR_FALSE, PR_FALSE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "<platform>.js was not parsed successfully");
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "prmem.h"
|
||||
|
||||
// Definitions
|
||||
#define BACKUP_FILE_EXTENSION ".bak"
|
||||
#define BACKUP_FILE_EXTENSION NS_LITERAL_CSTRING(".bak")
|
||||
|
||||
|
||||
nsSafeSaveFile::nsSafeSaveFile(nsIFile *aTargetFile, PRInt32 aNumBackupCopies)
|
||||
|
@ -52,7 +52,7 @@ nsSafeSaveFile::nsSafeSaveFile(nsIFile *aTargetFile, PRInt32 aNumBackupCopies)
|
|||
nsresult rv;
|
||||
|
||||
// determine the actual filename (less the extension)
|
||||
rv = aTargetFile->GetLeafName(getter_Copies(mTargetFileName));
|
||||
rv = aTargetFile->GetLeafName(mTargetFileName);
|
||||
if (NS_FAILED(rv)) // yikes! out of memory
|
||||
return;
|
||||
|
||||
|
@ -60,14 +60,13 @@ nsSafeSaveFile::nsSafeSaveFile(nsIFile *aTargetFile, PRInt32 aNumBackupCopies)
|
|||
if (temp)
|
||||
mTargetNameLen = temp - mTargetFileName.get();
|
||||
else
|
||||
mTargetNameLen = strlen(mTargetFileName.get());
|
||||
mTargetNameLen = mTargetFileName.Length();
|
||||
|
||||
// create a new file object that points to the temp file
|
||||
tempFileName.Assign(mTargetFileName.get(), mTargetNameLen);
|
||||
tempFileName += ".tmp";
|
||||
tempFileName = Substring(mTargetFileName, 0, mTargetNameLen) + NS_LITERAL_CSTRING(".tmp");
|
||||
rv = aTargetFile->Clone(getter_AddRefs(mTempFile));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mTempFile->SetLeafName(tempFileName.get());
|
||||
mTempFile->SetLeafName(tempFileName);
|
||||
}
|
||||
|
||||
void nsSafeSaveFile::CleanupFailedSave(void)
|
||||
|
@ -80,7 +79,7 @@ void nsSafeSaveFile::CleanupFailedSave(void)
|
|||
|
||||
nsresult nsSafeSaveFile::GetSaveFile(nsIFile **_retval)
|
||||
{
|
||||
if (!mTargetFileName || !mTempFile)
|
||||
if (mTargetFileName.IsEmpty() || !mTempFile)
|
||||
return(NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
*_retval = mTempFile;
|
||||
|
@ -104,14 +103,13 @@ nsresult nsSafeSaveFile::PostProcessSave(void)
|
|||
|
||||
if (mBackupCount > 0) {
|
||||
// kill the (oldest) backup copy, if necessary
|
||||
fileName.Assign(mTargetFileName.get(), mTargetNameLen);
|
||||
fileName += BACKUP_FILE_EXTENSION;
|
||||
fileName = Substring(mTargetFileName, 0, mTargetNameLen) + BACKUP_FILE_EXTENSION;
|
||||
if (mBackupCount > 1)
|
||||
fileName.AppendInt(mBackupCount - 1);
|
||||
backupFile->SetLeafName(fileName.get());
|
||||
backupFile->SetLeafName(fileName);
|
||||
} else {
|
||||
// no backups desired, delete the previous save
|
||||
backupFile->SetLeafName(mTargetFileName.get());
|
||||
backupFile->SetLeafName(mTargetFileName);
|
||||
}
|
||||
|
||||
// remove the file as determined by the logic above
|
||||
|
@ -120,32 +118,31 @@ nsresult nsSafeSaveFile::PostProcessSave(void)
|
|||
// now manage the backup copies
|
||||
if (mBackupCount > 0) {
|
||||
PRInt32 backupCount = mBackupCount;
|
||||
fileName.Assign(mTargetFileName.get(), mTargetNameLen);
|
||||
fileName += BACKUP_FILE_EXTENSION;
|
||||
fileName = Substring(mTargetFileName, 0, mTargetNameLen) + BACKUP_FILE_EXTENSION;
|
||||
while (--backupCount > 0) {
|
||||
// bump all of the redundant backups up one (i.e. bak -> bak1, bak1 -> bak2, etc.)
|
||||
if (backupCount > 1)
|
||||
fileName.AppendInt(backupCount - 1);
|
||||
backupFile->SetLeafName(fileName.get());
|
||||
backupFile->SetLeafName(fileName);
|
||||
backupFile->Exists(&bExists);
|
||||
if (bExists) {
|
||||
fileName.Truncate(mTargetNameLen + (sizeof(BACKUP_FILE_EXTENSION) - 1));
|
||||
fileName.AppendInt(backupCount);
|
||||
// fail silently because it's not important enough to bail on the save for
|
||||
backupFile->MoveTo(0, fileName.get());
|
||||
backupFile->MoveTo(0, fileName);
|
||||
}
|
||||
fileName.Truncate(mTargetNameLen + (sizeof(BACKUP_FILE_EXTENSION) - 1));
|
||||
};
|
||||
|
||||
// rename the previous save to .bak (i.e. <filename.js> to <filename.bak>)
|
||||
backupFile->SetLeafName(mTargetFileName.get());
|
||||
rv = backupFile->MoveTo(0, fileName.get());
|
||||
backupFile->SetLeafName(mTargetFileName);
|
||||
rv = backupFile->MoveTo(0, fileName);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
// finally rename the temp file to the original name (i.e. <filename.tmp> to <filename.js>)
|
||||
rv = mTempFile->MoveTo(0, mTargetFileName.get());
|
||||
rv = mTempFile->MoveTo(0, mTargetFileName);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -166,12 +163,11 @@ nsresult nsSafeSaveFile::PurgeOldestBackup(void)
|
|||
return NS_ERROR_FILE_NOT_FOUND;
|
||||
|
||||
PRInt32 backupCount = mBackupCount;
|
||||
fileName.Assign(mTargetFileName.get(), mTargetNameLen);
|
||||
fileName += BACKUP_FILE_EXTENSION;
|
||||
fileName = Substring(mTargetFileName, 0, mTargetNameLen) + BACKUP_FILE_EXTENSION;
|
||||
while (--backupCount >= 0) {
|
||||
if (backupCount)
|
||||
fileName.AppendInt(backupCount);
|
||||
backupFile->SetLeafName(fileName.get());
|
||||
backupFile->SetLeafName(fileName);
|
||||
rv = backupFile->Remove(PR_FALSE);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
return NS_OK;
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
#include "nsIFile.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
class nsSafeSaveFile {
|
||||
public:
|
||||
|
@ -55,7 +54,7 @@ class nsSafeSaveFile {
|
|||
|
||||
private:
|
||||
nsCOMPtr<nsIFile> mTempFile;
|
||||
nsXPIDLCString mTargetFileName;
|
||||
nsCString mTargetFileName; // UTF-8
|
||||
PRInt32 mTargetNameLen;
|
||||
PRInt32 mBackupCount;
|
||||
};
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
#include "nsISupports.idl"
|
||||
#include "nsIEnumerator.idl"
|
||||
|
||||
interface nsIFile;
|
||||
|
||||
typedef PRUint32 nsRegistryKey;
|
||||
typedef long nsWellKnownRegistry;
|
||||
|
||||
|
@ -35,7 +37,7 @@ interface nsIRegistry : nsISupports
|
|||
// Dont use this one. This for internal use only.
|
||||
const long ApplicationCustomRegistry = -1;
|
||||
|
||||
void open(in string regFile);
|
||||
void open(in nsIFile regFile);
|
||||
void openWellKnownRegistry(in nsWellKnownRegistry regid);
|
||||
|
||||
void flush();
|
||||
|
|
|
@ -367,7 +367,7 @@ NS_IMPL_ISUPPORTS1( nsRegistryValue, nsIRegistryValue )
|
|||
| Vanilla nsRegistry constructor. |
|
||||
------------------------------------------------------------------------------*/
|
||||
nsRegistry::nsRegistry()
|
||||
: mReg(0), mCurRegFile(nsnull), mCurRegID(0) {
|
||||
: mReg(0), mCurRegID(0) {
|
||||
NS_INIT_REFCNT();
|
||||
#ifdef EXTRA_THREADSAFE
|
||||
mregLock = PR_NewLock();
|
||||
|
@ -382,8 +382,6 @@ nsRegistry::~nsRegistry() {
|
|||
if( mReg ) {
|
||||
Close();
|
||||
}
|
||||
if (mCurRegFile)
|
||||
nsCRT::free(mCurRegFile);
|
||||
#ifdef EXTRA_THREADSAFE
|
||||
if (mregLock) {
|
||||
PR_DestroyLock(mregLock);
|
||||
|
@ -397,7 +395,7 @@ nsRegistry::~nsRegistry() {
|
|||
| file. We first check to see if a registry file is already open and close |
|
||||
| it if so. |
|
||||
------------------------------------------------------------------------------*/
|
||||
NS_IMETHODIMP nsRegistry::Open( const char *regFile ) {
|
||||
NS_IMETHODIMP nsRegistry::Open( nsIFile *regFile ) {
|
||||
REGERR err = REGERR_OK;
|
||||
|
||||
// Check for default.
|
||||
|
@ -405,8 +403,12 @@ NS_IMETHODIMP nsRegistry::Open( const char *regFile ) {
|
|||
return OpenWellKnownRegistry(nsIRegistry::ApplicationRegistry);
|
||||
}
|
||||
|
||||
nsCAutoString regPath;
|
||||
nsresult rv = regFile->GetNativePath(regPath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef DEBUG_dp
|
||||
printf("nsRegistry: Opening registry %s\n", regFile);
|
||||
printf("nsRegistry: Opening registry %s\n", regPath.get());
|
||||
#endif /* DEBUG_dp */
|
||||
|
||||
if (mCurRegID != nsIRegistry::None && mCurRegID != nsIRegistry::ApplicationCustomRegistry)
|
||||
|
@ -418,7 +420,8 @@ NS_IMETHODIMP nsRegistry::Open( const char *regFile ) {
|
|||
// Do we have an open registry ?
|
||||
if (mCurRegID != nsIRegistry::None)
|
||||
{
|
||||
if (mCurRegFile && !nsCRT::strcmp(regFile, mCurRegFile))
|
||||
PRBool equals;
|
||||
if (mCurRegFile && NS_SUCCEEDED(mCurRegFile->Equals(regFile, &equals)) && equals)
|
||||
{
|
||||
// The right one is already open
|
||||
return NS_OK;
|
||||
|
@ -433,12 +436,14 @@ NS_IMETHODIMP nsRegistry::Open( const char *regFile ) {
|
|||
|
||||
// Open specified registry.
|
||||
PR_Lock(mregLock);
|
||||
err = NR_RegOpen((char*)regFile, &mReg );
|
||||
err = NR_RegOpen(NS_CONST_CAST(char*,regPath.get()), &mReg);
|
||||
PR_Unlock(mregLock);
|
||||
|
||||
mCurRegID = nsIRegistry::ApplicationCustomRegistry;
|
||||
|
||||
// No error checking for no mem. Trust me.
|
||||
mCurRegFile = nsCRT::strdup(regFile);
|
||||
if (NS_FAILED(regFile->Clone(getter_AddRefs(mCurRegFile))))
|
||||
mCurRegFile = nsnull; // not fatal
|
||||
|
||||
// Convert the result.
|
||||
return regerr2nsresult( err );
|
||||
|
@ -521,7 +526,7 @@ NS_IMETHODIMP nsRegistry::OpenWellKnownRegistry( nsWellKnownRegistry regid )
|
|||
nsCOMPtr<nsIFile> registryLocation;
|
||||
|
||||
PRBool foundReg = PR_FALSE;
|
||||
char *regFile = nsnull;
|
||||
nsCAutoString regFile;
|
||||
|
||||
switch ( (nsWellKnownRegistry) regid ) {
|
||||
case ApplicationComponentRegistry:
|
||||
|
@ -539,11 +544,11 @@ NS_IMETHODIMP nsRegistry::OpenWellKnownRegistry( nsWellKnownRegistry regid )
|
|||
if (registryLocation)
|
||||
{
|
||||
foundReg = PR_TRUE;
|
||||
registryLocation->GetPath(®File); // dougt fix...
|
||||
rv = registryLocation->GetNativePath(regFile); // dougt fix...
|
||||
// dveditz needs to fix his registry so that I can pass an
|
||||
// nsIFile interface and not hack
|
||||
if (!regFile)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -563,11 +568,11 @@ NS_IMETHODIMP nsRegistry::OpenWellKnownRegistry( nsWellKnownRegistry regid )
|
|||
if (registryLocation)
|
||||
{
|
||||
foundReg = PR_TRUE;
|
||||
registryLocation->GetPath(®File); // dougt fix...
|
||||
rv = registryLocation->GetNativePath(regFile); // dougt fix...
|
||||
// dveditz needs to fix his registry so that I can pass an
|
||||
// nsIFile interface and not hack
|
||||
if (!regFile)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -581,16 +586,13 @@ NS_IMETHODIMP nsRegistry::OpenWellKnownRegistry( nsWellKnownRegistry regid )
|
|||
}
|
||||
|
||||
#ifdef DEBUG_dp
|
||||
printf("nsRegistry: Opening std registry %s\n", regFile);
|
||||
printf("nsRegistry: Opening std registry %s\n", regFile.get());
|
||||
#endif /* DEBUG_dp */
|
||||
|
||||
PR_Lock(mregLock);
|
||||
err = NR_RegOpen((char*)regFile, &mReg );
|
||||
err = NR_RegOpen((char*)regFile.get(), &mReg );
|
||||
PR_Unlock(mregLock);
|
||||
|
||||
if (regFile)
|
||||
nsMemory::Free(regFile);
|
||||
|
||||
// Store the registry that was opened for optimizing future opens.
|
||||
mCurRegID = regid;
|
||||
|
||||
|
@ -618,8 +620,6 @@ NS_IMETHODIMP nsRegistry::Close() {
|
|||
err = NR_RegClose( mReg );
|
||||
PR_Unlock(mregLock);
|
||||
mReg = 0;
|
||||
if (mCurRegFile)
|
||||
nsCRT::free(mCurRegFile);
|
||||
mCurRegFile = nsnull;
|
||||
mCurRegID = 0;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
|
||||
#include "nsIRegistry.h"
|
||||
#include "NSReg.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
struct nsRegistry : public nsIRegistry, nsIRegistryGetter {
|
||||
// This class implements the nsISupports interface functions.
|
||||
|
@ -64,7 +66,7 @@ protected:
|
|||
#ifdef EXTRA_THREADSAFE
|
||||
PRLock *mregLock; // libreg isn't threadsafe. Use locks to synchronize.
|
||||
#endif
|
||||
char *mCurRegFile; // these are to prevent open from opening the registry again
|
||||
nsCOMPtr<nsIFile> mCurRegFile; // these are to prevent open from opening the registry again
|
||||
nsWellKnownRegistry mCurRegID;
|
||||
|
||||
NS_IMETHOD Close();
|
||||
|
|
|
@ -63,7 +63,7 @@ class nsMPFileLocProvider: public nsIDirectoryServiceProvider
|
|||
Initialize: Must be called after constructor.
|
||||
|
||||
profileParentDir -> The directory that is the parent dir of our profile folder.
|
||||
profileDirName -> The leaf name of our profile folder.
|
||||
profileDirName -> The leaf name of our profile folder (native charset).
|
||||
*/
|
||||
|
||||
virtual nsresult Initialize(nsIFile* profileParentDir, const char *profileDirName);
|
||||
|
|
|
@ -157,19 +157,19 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsMPFileLocProvider, nsIDirectoryServiceProvider)
|
|||
|
||||
// File Name Defines - Copied straight from nsProfile
|
||||
|
||||
#define PREFS_FILE_50_NAME "prefs.js"
|
||||
#define USER_CHROME_DIR_50_NAME "chrome"
|
||||
#define LOCAL_STORE_FILE_50_NAME "localstore.rdf"
|
||||
#define HISTORY_FILE_50_NAME "history.dat"
|
||||
#define PANELS_FILE_50_NAME "panels.rdf"
|
||||
#define MIME_TYPES_FILE_50_NAME "mimeTypes.rdf"
|
||||
#define BOOKMARKS_FILE_50_NAME "bookmarks.html"
|
||||
#define DOWNLOADS_FILE_50_NAME "downloads.rdf"
|
||||
#define SEARCH_FILE_50_NAME "search.rdf"
|
||||
#define MAIL_DIR_50_NAME "Mail"
|
||||
#define IMAP_MAIL_DIR_50_NAME "ImapMail"
|
||||
#define NEWS_DIR_50_NAME "News"
|
||||
#define MSG_FOLDER_CACHE_DIR_50_NAME "panacea.dat"
|
||||
#define PREFS_FILE_50_NAME NS_LITERAL_CSTRING("prefs.js")
|
||||
#define USER_CHROME_DIR_50_NAME NS_LITERAL_CSTRING("chrome")
|
||||
#define LOCAL_STORE_FILE_50_NAME NS_LITERAL_CSTRING("localstore.rdf")
|
||||
#define HISTORY_FILE_50_NAME NS_LITERAL_CSTRING("history.dat")
|
||||
#define PANELS_FILE_50_NAME NS_LITERAL_CSTRING("panels.rdf")
|
||||
#define MIME_TYPES_FILE_50_NAME NS_LITERAL_CSTRING("mimeTypes.rdf")
|
||||
#define BOOKMARKS_FILE_50_NAME NS_LITERAL_CSTRING("bookmarks.html")
|
||||
#define DOWNLOADS_FILE_50_NAME NS_LITERAL_CSTRING("downloads.rdf")
|
||||
#define SEARCH_FILE_50_NAME NS_LITERAL_CSTRING("search.rdf" )
|
||||
#define MAIL_DIR_50_NAME NS_LITERAL_CSTRING("Mail")
|
||||
#define IMAP_MAIL_DIR_50_NAME NS_LITERAL_CSTRING("ImapMail")
|
||||
#define NEWS_DIR_50_NAME NS_LITERAL_CSTRING("News")
|
||||
#define MSG_FOLDER_CACHE_DIR_50_NAME NS_LITERAL_CSTRING("panacea.dat")
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMPFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
|
||||
|
@ -341,14 +341,14 @@ nsresult RecursiveCopy(nsIFile* srcDir, nsIFile* destDir)
|
|||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> newChild(do_QueryInterface(destClone));
|
||||
nsXPIDLCString leafName;
|
||||
dirEntry->GetLeafName(getter_Copies(leafName));
|
||||
nsCAutoString leafName;
|
||||
dirEntry->GetLeafName(leafName);
|
||||
newChild->AppendRelativePath(leafName);
|
||||
rv = RecursiveCopy(dirEntry, newChild);
|
||||
}
|
||||
}
|
||||
else
|
||||
rv = dirEntry->CopyTo(destDir, nsnull);
|
||||
rv = dirEntry->CopyTo(destDir, nsCString());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ nsresult nsMPFileLocProvider::InitProfileDir(nsIFile *profileParentDir,
|
|||
|
||||
rv = profileParentDir->Clone(getter_AddRefs(profileDir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = profileDir->Append(profileDirName);
|
||||
rv = profileDir->AppendNative(nsDependentCString(profileDirName));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRBool exists;
|
||||
|
|
|
@ -142,7 +142,7 @@ NS_NewPluginPostDataStream(nsIInputStream **result,
|
|||
} else {
|
||||
nsCOMPtr<nsILocalFile> file; // tmp file will be deleted on release of stream
|
||||
nsCOMPtr<nsIInputStream> fileStream;
|
||||
if (NS_SUCCEEDED(rv = NS_NewLocalFile(data, PR_FALSE, getter_AddRefs(file))) &&
|
||||
if (NS_SUCCEEDED(rv = NS_NewNativeLocalFile(nsDependentCString(data), PR_FALSE, getter_AddRefs(file))) &&
|
||||
NS_SUCCEEDED(rv = NS_NewLocalFileInputStream(getter_AddRefs(fileStream),
|
||||
file,
|
||||
PR_RDONLY,
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include "nsCRT.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsDependentString.h"
|
||||
|
||||
#if defined (XP_WIN)
|
||||
#include <windows.h>
|
||||
|
@ -109,7 +110,7 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFil
|
|||
|
||||
result = ::RegQueryValueEx(keyloc, "Plugins Directory", NULL, &type, (LPBYTE)&path, &pathlen);
|
||||
if (result == ERROR_SUCCESS)
|
||||
rv = NS_NewLocalFile(path, PR_TRUE, getter_AddRefs(localFile));
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localFile));
|
||||
::RegCloseKey(keyloc);
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +177,7 @@ nsPluginDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFil
|
|||
if (newestPath[0] != 0)
|
||||
{
|
||||
PL_strcat(newestPath,"\\bin");
|
||||
rv = NS_NewLocalFile(newestPath, PR_TRUE, getter_AddRefs(localFile));
|
||||
rv = NS_NewNativeLocalFile(nsDependentCString(newestPath), PR_TRUE, getter_AddRefs(localFile));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@
|
|||
|
||||
// this is the name of the directory which will be created
|
||||
// to cache temporary files.
|
||||
static const char *kPluginTmpDirName = "plugtmp";
|
||||
#define kPluginTmpDirName NS_LITERAL_CSTRING("plugtmp")
|
||||
|
||||
// Version of cached plugin info
|
||||
// 0.01 first implementation
|
||||
|
@ -1175,10 +1175,10 @@ public:
|
|||
MakeByteRangeString(nsByteRange* aRangeList, nsACString &string, PRInt32 *numRequests);
|
||||
|
||||
void
|
||||
SetLocalCachedFile(const char* path);
|
||||
SetLocalCachedFile(nsIFile *file);
|
||||
|
||||
void
|
||||
GetLocalCachedFile(char** path);
|
||||
GetLocalCachedFile(nsIFile** file);
|
||||
|
||||
void
|
||||
SetLocalCachedFileStream(nsIOutputStream *stream);
|
||||
|
@ -1190,7 +1190,7 @@ private:
|
|||
|
||||
char* mContentType;
|
||||
char* mURL;
|
||||
char* mFilePath;
|
||||
nsCOMPtr<nsIFile> mCachedFile;
|
||||
PRBool mSeekable;
|
||||
PRUint32 mLength;
|
||||
PRUint32 mModified;
|
||||
|
@ -1231,11 +1231,11 @@ public:
|
|||
|
||||
nsresult InitializeFullPage(nsIPluginInstance *aInstance);
|
||||
|
||||
nsresult OnFileAvailable(const char* aFilename);
|
||||
nsresult OnFileAvailable(nsIFile* aFile);
|
||||
|
||||
nsILoadGroup* GetLoadGroup();
|
||||
|
||||
nsresult SetLocalFile(const char* aFilename);
|
||||
nsresult SetLocalFile(nsIFile* aFile);
|
||||
|
||||
private:
|
||||
nsresult SetUpCache(nsIURI* aURL); // todo: see about removing this...
|
||||
|
@ -1269,7 +1269,7 @@ private:
|
|||
nsIPluginHost *mHost;
|
||||
|
||||
// local file which was used to post data and which should be deleted after that
|
||||
char *mLocalFile;
|
||||
nsCOMPtr<nsIFile> mLocalFile;
|
||||
nsHashtable *mDataForwardToRequest;
|
||||
|
||||
public:
|
||||
|
@ -1289,7 +1289,6 @@ nsPluginStreamInfo::nsPluginStreamInfo()
|
|||
|
||||
mContentType = nsnull;
|
||||
mURL = nsnull;
|
||||
mFilePath = nsnull;
|
||||
mSeekable = PR_FALSE;
|
||||
mLength = 0;
|
||||
mModified = 0;
|
||||
|
@ -1312,17 +1311,10 @@ nsPluginStreamInfo::~nsPluginStreamInfo()
|
|||
mFileCacheOutputStream->Close();
|
||||
|
||||
// ONLY delete our cached file if we created it
|
||||
if(mLocallyCached && mFilePath)
|
||||
if(mLocallyCached && mCachedFile)
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
nsresult res = NS_NewLocalFile(mFilePath,
|
||||
PR_FALSE,
|
||||
getter_AddRefs(localFile));
|
||||
if(NS_SUCCEEDED(res))
|
||||
localFile->Remove(PR_FALSE);
|
||||
mCachedFile->Remove(PR_FALSE);
|
||||
}
|
||||
if (mFilePath)
|
||||
PL_strfree(mFilePath);
|
||||
|
||||
NS_IF_RELEASE(mPluginInstance);
|
||||
}
|
||||
|
@ -1569,23 +1561,18 @@ nsPluginStreamInfo::SetURL(const char* url)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
nsPluginStreamInfo::SetLocalCachedFile(const char* path)
|
||||
nsPluginStreamInfo::SetLocalCachedFile(nsIFile* file)
|
||||
{
|
||||
if(mFilePath != nsnull)
|
||||
PL_strfree(mFilePath);
|
||||
|
||||
mFilePath = PL_strdup(path);
|
||||
file->Clone(getter_AddRefs(mCachedFile));
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
nsPluginStreamInfo::GetLocalCachedFile(char** path)
|
||||
nsPluginStreamInfo::GetLocalCachedFile(nsIFile** file)
|
||||
{
|
||||
if (mFilePath)
|
||||
*path = PL_strdup(mFilePath);
|
||||
else
|
||||
*path = nsnull;
|
||||
*file = mCachedFile;
|
||||
NS_IF_ADDREF(*file);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1718,7 +1705,6 @@ nsPluginStreamListenerPeer::nsPluginStreamListenerPeer()
|
|||
mHost = nsnull;
|
||||
mStreamType = nsPluginStreamType_Normal;
|
||||
mStartBinding = PR_FALSE;
|
||||
mLocalFile = nsnull;
|
||||
mAbort = PR_FALSE;
|
||||
mRequestFailed = PR_FALSE;
|
||||
|
||||
|
@ -1735,8 +1721,11 @@ nsPluginStreamListenerPeer::~nsPluginStreamListenerPeer()
|
|||
nsCAutoString urlSpec;
|
||||
if(mURL != nsnull) (void)mURL->GetSpec(urlSpec);
|
||||
|
||||
nsCAutoString filePath;
|
||||
if(mLocalFile != nsnull) (void)mLocalFile->GetNativePath(filePath);
|
||||
|
||||
PR_LOG(nsPluginLogging::gPluginLog, PLUGIN_LOG_NORMAL,
|
||||
("nsPluginStreamListenerPeer::dtor this=%p, url=%s, POST_file=%s\n",this, urlSpec.get(), mLocalFile));
|
||||
("nsPluginStreamListenerPeer::dtor this=%p, url=%s, POST_file=%s\n",this, urlSpec.get(), filePath.get()));
|
||||
|
||||
PR_LogFlush();
|
||||
#endif
|
||||
|
@ -1751,13 +1740,8 @@ nsPluginStreamListenerPeer::~nsPluginStreamListenerPeer()
|
|||
// if we have mLocalFile (temp file used to post data) it should be
|
||||
// safe to delete it now, and hopefully the owner doesn't hold it.
|
||||
if(mLocalFile)
|
||||
{
|
||||
nsCOMPtr<nsILocalFile> localFile;
|
||||
nsresult res = NS_NewLocalFile(mLocalFile, PR_FALSE, getter_AddRefs(localFile));
|
||||
if(NS_SUCCEEDED(res))
|
||||
localFile->Remove(PR_FALSE);
|
||||
delete [] mLocalFile;
|
||||
}
|
||||
mLocalFile->Remove(PR_FALSE);
|
||||
|
||||
delete mDataForwardToRequest;
|
||||
}
|
||||
|
||||
|
@ -1931,18 +1915,15 @@ nsPluginStreamListenerPeer::SetupPluginCacheFile(nsIChannel* channel)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Create a file to save our stream into. Should we scramble the name?
|
||||
rv = pluginTmp->Append(filename.get());
|
||||
rv = pluginTmp->AppendNative(filename);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Yes, make it unique.
|
||||
rv = pluginTmp->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0777);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// save the file path off.
|
||||
nsXPIDLCString saveToFilename;
|
||||
(void) pluginTmp->GetPath(getter_Copies(saveToFilename));
|
||||
|
||||
mPluginStreamInfo->SetLocalCachedFile(saveToFilename);
|
||||
// save the file.
|
||||
mPluginStreamInfo->SetLocalCachedFile(pluginTmp);
|
||||
|
||||
// create a file output stream to write to...
|
||||
nsCOMPtr<nsIOutputStream> outstream;
|
||||
|
@ -2102,7 +2083,7 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request, nsISupports* aCo
|
|||
// it's possible for the server to not send a Content-Length. We should
|
||||
// still work in this case.
|
||||
if (NS_FAILED(rv)) {
|
||||
mPluginStreamInfo->SetLength(-1);
|
||||
mPluginStreamInfo->SetLength(PRUint32(-1));
|
||||
}
|
||||
else {
|
||||
mPluginStreamInfo->SetLength(length);
|
||||
|
@ -2355,11 +2336,10 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsXPIDLCString pathAndFilename;
|
||||
mPluginStreamInfo->GetLocalCachedFile(getter_Copies(pathAndFilename));
|
||||
nsCOMPtr<nsIFile> localFile;
|
||||
mPluginStreamInfo->GetLocalCachedFile(getter_AddRefs(localFile));
|
||||
|
||||
if (!pathAndFilename) {
|
||||
nsCOMPtr<nsIFile> localFile;
|
||||
if (!localFile) {
|
||||
nsCOMPtr<nsICachingChannel> cacheChannel = do_QueryInterface(request);
|
||||
if (cacheChannel) {
|
||||
cacheChannel->GetCacheFile(getter_AddRefs(localFile));
|
||||
|
@ -2370,13 +2350,10 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request,
|
|||
fileChannel->GetFile(getter_AddRefs(localFile));
|
||||
}
|
||||
}
|
||||
if (localFile) {
|
||||
localFile->GetPath(getter_Copies(pathAndFilename));
|
||||
}
|
||||
}
|
||||
|
||||
if (pathAndFilename && *pathAndFilename) {
|
||||
OnFileAvailable(pathAndFilename);
|
||||
if (localFile) {
|
||||
OnFileAvailable(localFile);
|
||||
}
|
||||
|
||||
if (mStartBinding)
|
||||
|
@ -2443,9 +2420,9 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
|
|||
// set seekability (seekable if the stream has a known length and if the
|
||||
// http server accepts byte ranges).
|
||||
PRBool bSeekable = PR_FALSE;
|
||||
PRUint32 length = -1;
|
||||
PRUint32 length = PRUint32(-1);
|
||||
mPluginStreamInfo->GetLength(&length);
|
||||
if ((length != -1) && httpChannel)
|
||||
if ((length != PRUint32(-1)) && httpChannel)
|
||||
{
|
||||
nsCAutoString range;
|
||||
if(NS_SUCCEEDED(httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("accept-ranges"), range)))
|
||||
|
@ -2507,13 +2484,22 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
|
|||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
nsresult
|
||||
nsPluginStreamListenerPeer::OnFileAvailable(const char* aFilename)
|
||||
nsPluginStreamListenerPeer::OnFileAvailable(nsIFile* aFile)
|
||||
{
|
||||
nsresult rv;
|
||||
if (!mPStreamListener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = mPStreamListener->OnFileAvailable((nsIPluginStreamInfo*)mPluginStreamInfo, aFilename);
|
||||
nsCAutoString path;
|
||||
rv = aFile->GetNativePath(path);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (path.IsEmpty()) {
|
||||
NS_WARNING("empty path");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = mPStreamListener->OnFileAvailable((nsIPluginStreamInfo*)mPluginStreamInfo, path.get());
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2547,25 +2533,18 @@ nsPluginStreamListenerPeer::VisitHeader(const nsACString &header, const nsACStri
|
|||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
nsresult nsPluginStreamListenerPeer::SetLocalFile(const char* aFilename)
|
||||
nsresult nsPluginStreamListenerPeer::SetLocalFile(nsIFile* aFile)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFilename);
|
||||
nsresult rv = NS_OK;
|
||||
NS_ENSURE_ARG_POINTER(aFile);
|
||||
|
||||
if(mLocalFile)
|
||||
{
|
||||
NS_ASSERTION(!mLocalFile, "nsPluginStreamListenerPeer::SetLocalFile -- path already set, cleaning...");
|
||||
delete [] mLocalFile;
|
||||
mLocalFile = nsnull;
|
||||
}
|
||||
|
||||
mLocalFile = new char[PL_strlen(aFilename) + 1];
|
||||
if(!mLocalFile)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PL_strcpy(mLocalFile, aFilename);
|
||||
|
||||
return rv;
|
||||
// clone file to prevent it from being changed out from under us
|
||||
return aFile->Clone(getter_AddRefs(mLocalFile));
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
@ -3894,9 +3873,9 @@ NS_IMETHODIMP nsPluginHostImpl::SetUpPluginInstance(const char *aMimeType,
|
|||
|
||||
if (NS_SUCCEEDED(result))
|
||||
{
|
||||
nsXPIDLCString path;
|
||||
binDirectory->GetPath(getter_Copies(path));
|
||||
restoreOrigDir = ::SetCurrentDirectory(path);
|
||||
nsCAutoString path;
|
||||
binDirectory->GetNativePath(path);
|
||||
restoreOrigDir = ::SetCurrentDirectory(path.get());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -4732,8 +4711,8 @@ nsresult nsPluginHostImpl::ScanPluginsDirectory(nsIFile * pluginsDir,
|
|||
*aPluginsChanged = PR_FALSE;
|
||||
|
||||
#ifdef PLUGIN_LOGGING
|
||||
nsXPIDLCString dirPath;
|
||||
pluginsDir->GetPath(getter_Copies(dirPath));
|
||||
nsCAutoString dirPath;
|
||||
pluginsDir->GetNativePath(dirPath);
|
||||
PLUGIN_LOG(PLUGIN_LOG_BASIC,
|
||||
("nsPluginHostImpl::ScanPluginsDirectory dir=%s\n", dirPath.get()));
|
||||
#endif
|
||||
|
@ -4751,15 +4730,15 @@ nsresult nsPluginHostImpl::ScanPluginsDirectory(nsIFile * pluginsDir,
|
|||
rv = iter->GetNext(getter_AddRefs(supports));
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
nsCOMPtr<nsIFile> dirEntry(do_QueryInterface(supports, &rv));
|
||||
nsCOMPtr<nsILocalFile> dirEntry(do_QueryInterface(supports, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
nsXPIDLCString filePath;
|
||||
rv = dirEntry->GetPath(getter_Copies(filePath));
|
||||
nsCAutoString filePath;
|
||||
rv = dirEntry->GetNativePath(filePath);
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
nsFileSpec file(filePath);
|
||||
nsFileSpec file(filePath.get());
|
||||
PRBool wasSymlink;
|
||||
file.ResolveSymlink(wasSymlink);
|
||||
|
||||
|
@ -5174,10 +5153,8 @@ void nsPluginHostImpl::ClearCachedPluginInfoList()
|
|||
|
||||
static nsresult
|
||||
cidToDllname(nsIComponentManager* aComponentManager, nsIRegistry* aRegistry,
|
||||
const char *aCID, char **dllName)
|
||||
const nsACString &aCID, nsACString &dllName)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(dllName);
|
||||
|
||||
// To figure out the filename of the plugin, we'll need to get the
|
||||
// plugin's CID, and then navigate through the XPCOM registry to
|
||||
// pull out the DLL name to which the CID is registered.
|
||||
|
@ -5452,13 +5429,13 @@ nsPluginHostImpl::LoadXPCOMPlugins(nsIComponentManager* aComponentManager, nsIFi
|
|||
nsRegistryKey key;
|
||||
node->GetKey(&key);
|
||||
|
||||
nsXPIDLCString filename;
|
||||
rv = cidToDllname(aComponentManager, registry, cid, getter_Copies(filename));
|
||||
nsCAutoString filename;
|
||||
rv = cidToDllname(aComponentManager, registry, cid, filename);
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
nsPluginTag* tag = nsnull;
|
||||
rv = LoadXPCOMPlugin(registry, filename, key, &tag);
|
||||
rv = LoadXPCOMPlugin(registry, filename.get(), key, &tag);
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
|
||||
|
@ -5984,14 +5961,14 @@ NS_IMETHODIMP nsPluginHostImpl::GetProgramPath(const char* *result)
|
|||
nsCOMPtr<nsIProperties> dirService(do_GetService(kDirectoryServiceContractID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIFile> programDir;
|
||||
rv = dirService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsIFile), getter_AddRefs(programDir));
|
||||
nsCOMPtr<nsILocalFile> programDir;
|
||||
rv = dirService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(programDir));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
char *temp;
|
||||
rv = programDir->GetPath(&temp);
|
||||
*result = temp;
|
||||
nsCAutoString temp;
|
||||
rv = programDir->GetNativePath(temp);
|
||||
*result = ToNewCString(temp);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -6006,14 +5983,14 @@ NS_IMETHODIMP nsPluginHostImpl::GetTempDirPath(const char* *result)
|
|||
nsCOMPtr<nsIProperties> dirService(do_GetService(kDirectoryServiceContractID, &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIFile> tempDir;
|
||||
rv = dirService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsIFile), getter_AddRefs(tempDir));
|
||||
nsCOMPtr<nsILocalFile> tempDir;
|
||||
rv = dirService->Get(NS_OS_TEMP_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(tempDir));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
char *temp;
|
||||
rv = tempDir->GetPath(&temp);
|
||||
*result = temp;
|
||||
nsCAutoString temp;
|
||||
rv = tempDir->GetNativePath(temp);
|
||||
*result = ToNewCString(temp);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -6404,14 +6381,14 @@ nsPluginHostImpl::CreateTmpFileToPost(const char *postDataURL, char **pTmpFileNa
|
|||
*pTmpFileName = 0;
|
||||
nsresult rv;
|
||||
PRInt64 fileSize;
|
||||
nsXPIDLCString filename;
|
||||
nsCAutoString filename;
|
||||
// stat file == get size & convert file:///c:/ to c: if needed
|
||||
nsCOMPtr<nsILocalFile> inFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv) ||
|
||||
(NS_FAILED(rv = NS_InitFileFromURLSpec(inFile, nsDependentCString(postDataURL))) &&
|
||||
NS_FAILED(rv = inFile->InitWithPath(postDataURL))) ||
|
||||
NS_FAILED(rv = inFile->InitWithNativePath(nsDependentCString(postDataURL)))) ||
|
||||
NS_FAILED(rv = inFile->GetFileSize(&fileSize)) ||
|
||||
NS_FAILED(rv = inFile->GetPath(getter_Copies(filename)))
|
||||
NS_FAILED(rv = inFile->GetNativePath(filename))
|
||||
)
|
||||
return rv;
|
||||
if (!LL_IS_ZERO(fileSize)) {
|
||||
|
@ -6435,11 +6412,9 @@ nsPluginHostImpl::CreateTmpFileToPost(const char *postDataURL, char **pTmpFileNa
|
|||
if (!dirExists)
|
||||
(void) tempFile->Create(nsIFile::DIRECTORY_TYPE, 0600);
|
||||
|
||||
nsXPIDLCString inFileName;
|
||||
inFile->GetLeafName(getter_Copies(inFileName));
|
||||
nsCAutoString tempFileName("post-");
|
||||
tempFileName += inFileName;
|
||||
rv = tempFile->Append(tempFileName.get());
|
||||
nsCAutoString inFileName;
|
||||
inFile->GetLeafName(inFileName);
|
||||
rv = tempFile->Append(NS_LITERAL_CSTRING("post-") + inFileName);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
@ -6497,7 +6472,9 @@ nsPluginHostImpl::CreateTmpFileToPost(const char *postDataURL, char **pTmpFileNa
|
|||
inStream->Close();
|
||||
outStream->Close();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
tempFile->GetPath(pTmpFileName);
|
||||
nsCAutoString path;
|
||||
if (NS_SUCCEEDED(tempFile->GetNativePath(path)))
|
||||
*pTmpFileName = ToNewCString(path);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
|
|
|
@ -276,7 +276,7 @@ NS_MakeAbsoluteURI(nsAString &result,
|
|||
inline nsresult
|
||||
NS_NewPostDataStream(nsIInputStream **result,
|
||||
PRBool isFile,
|
||||
const char *data,
|
||||
const nsACString &data,
|
||||
PRUint32 encodeFlags,
|
||||
nsIIOService* ioService = nsnull) // pass in nsIIOService to optimize callers
|
||||
{
|
||||
|
@ -297,7 +297,7 @@ NS_NewPostDataStream(nsIInputStream **result,
|
|||
}
|
||||
|
||||
// otherwise, create a string stream for the data
|
||||
return NS_NewCStringInputStream(result, nsDependentCString(data));
|
||||
return NS_NewCStringInputStream(result, data);
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
|
|
|
@ -129,9 +129,9 @@ static int PR_CALLBACK compare(const void* aElement1,
|
|||
coll->CompareString(kCollationStrengthDefault, str1, str2, &res);
|
||||
return res;*/
|
||||
#else
|
||||
nsXPIDLCString name1, name2;
|
||||
a->GetLeafName(getter_Copies(name1));
|
||||
b->GetLeafName(getter_Copies(name2));
|
||||
nsCAutoString name1, name2;
|
||||
a->GetNativeLeafName(name1);
|
||||
b->GetNativeLeafName(name2);
|
||||
|
||||
return Compare(name1, name2);
|
||||
#endif
|
||||
|
@ -150,11 +150,11 @@ nsDirectoryIndexStream::Init(nsIFile* aDir)
|
|||
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {
|
||||
nsXPIDLCString path;
|
||||
aDir->GetPath(getter_Copies(path));
|
||||
nsCAutoString path;
|
||||
aDir->GetNativePath(path);
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("nsDirectoryIndexStream[%p]: initialized on %s",
|
||||
this, (const char*) path));
|
||||
this, path.get()));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -327,11 +327,11 @@ nsDirectoryIndexStream::Read(char* aBuf, PRUint32 aCount, PRUint32* aReadCount)
|
|||
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) {
|
||||
nsXPIDLCString path;
|
||||
current->GetPath(getter_Copies(path));
|
||||
nsCAutoString path;
|
||||
current->GetNativePath(path);
|
||||
PR_LOG(gLog, PR_LOG_DEBUG,
|
||||
("nsDirectoryIndexStream[%p]: iterated %s",
|
||||
this, (const char*) path));
|
||||
this, path.get()));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -381,8 +381,8 @@ nsDirectoryIndexStream::Read(char* aBuf, PRUint32 aCount, PRUint32* aReadCount)
|
|||
mBuf.Append(' ');
|
||||
}
|
||||
#else
|
||||
nsXPIDLCString leafname;
|
||||
rv = current->GetLeafName(getter_Copies(leafname));
|
||||
nsCAutoString leafname;
|
||||
rv = current->GetNativeLeafName(leafname);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (!leafname.IsEmpty()) {
|
||||
char* escaped = nsEscape(leafname.get(), url_Path);
|
||||
|
|
|
@ -116,8 +116,6 @@ nsFileIO::nsFileIO()
|
|||
if (nsnull == gFileIOLog) {
|
||||
gFileIOLog = PR_NewLogModule("nsFileIO");
|
||||
}
|
||||
|
||||
mSpec = nsnull;
|
||||
#endif /* PR_LOGGING */
|
||||
}
|
||||
|
||||
|
@ -128,9 +126,6 @@ nsFileIO::~nsFileIO()
|
|||
PR_Close(mFD);
|
||||
mFD = nsnull;
|
||||
}
|
||||
#ifdef PR_LOGGING
|
||||
if (mSpec) nsCRT::free(mSpec);
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
|
@ -158,7 +153,7 @@ nsFileIO::Init(nsIFile* file, PRInt32 ioFlags, PRInt32 perm)
|
|||
mIOFlags = ioFlags;
|
||||
mPerm = perm;
|
||||
#ifdef PR_LOGGING
|
||||
nsresult rv = mFile->GetPath(&mSpec);
|
||||
nsresult rv = mFile->GetNativePath(mSpec);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "GetSpec failed");
|
||||
#endif
|
||||
return NS_OK;
|
||||
|
@ -205,7 +200,7 @@ nsFileIO::Open()
|
|||
}
|
||||
|
||||
PR_LOG(gFileIOLog, PR_LOG_DEBUG,
|
||||
("nsFileIO: logically opening %s", mSpec));
|
||||
("nsFileIO: logically opening %s", mSpec.get()));
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -277,7 +272,7 @@ nsFileIO::Close(nsresult status)
|
|||
if (mFile) {
|
||||
PR_LOG(gFileIOLog, PR_LOG_DEBUG,
|
||||
("nsFileIO: logically closing %s: status=%x",
|
||||
mSpec, status));
|
||||
mSpec.get(), status));
|
||||
mFile = nsnull;
|
||||
}
|
||||
mStatus = status;
|
||||
|
@ -312,7 +307,7 @@ nsFileIO::GetInputStream(nsIInputStream * *aInputStream)
|
|||
rv = nsDirectoryIndexStream::Create(mFile, aInputStream);
|
||||
PR_LOG(gFileIOLog, PR_LOG_DEBUG,
|
||||
("nsFileIO: opening local dir %s for input (%x)",
|
||||
mSpec, rv));
|
||||
mSpec.get(), rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -335,7 +330,7 @@ nsFileIO::GetInputStream(nsIInputStream * *aInputStream)
|
|||
|
||||
PR_LOG(gFileIOLog, PR_LOG_DEBUG,
|
||||
("nsFileIO: opening local file %s for input (%x)",
|
||||
mSpec, rv));
|
||||
mSpec.get(), rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -380,7 +375,7 @@ nsFileIO::GetOutputStream(nsIOutputStream * *aOutputStream)
|
|||
|
||||
PR_LOG(gFileIOLog, PR_LOG_DEBUG,
|
||||
("nsFileIO: opening local file %s for output (%x)",
|
||||
mSpec, rv));
|
||||
mSpec.get(), rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -391,12 +386,7 @@ nsFileIO::GetName(nsACString &aName)
|
|||
if (mFile == nsnull)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsXPIDLCString path;
|
||||
nsresult rv = mFile->GetPath(getter_Copies(path));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
aName = path;
|
||||
return NS_OK;
|
||||
return mFile->GetPath(aName);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -72,7 +72,7 @@ protected:
|
|||
nsresult mStatus;
|
||||
nsCString mContentType;
|
||||
#ifdef PR_LOGGING
|
||||
char* mSpec;
|
||||
nsCString mSpec;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
/* Mac-specific local file url parsing */
|
||||
#include "nsIOService.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
static void SwapSlashColon(char *s)
|
||||
|
@ -72,9 +71,10 @@ nsIOService::GetURLSpecFromFile(nsIFile *aFile, nsACString &aURL)
|
|||
nsresult rv;
|
||||
NS_ENSURE_ARG(aFile);
|
||||
|
||||
nsXPIDLCString ePath;
|
||||
nsCAutoString ePath;
|
||||
|
||||
rv = aFile->GetPath(getter_Copies(ePath));
|
||||
// construct URL spec from native file path
|
||||
rv = aFile->GetNativePath(ePath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
SwapSlashColon((char *) ePath.get());
|
||||
|
@ -97,9 +97,8 @@ nsIOService::GetURLSpecFromFile(nsIFile *aFile, nsACString &aURL)
|
|||
rv = aFile->IsDirectory(&dir);
|
||||
if (NS_FAILED(rv))
|
||||
NS_WARNING(PromiseFlatCString(
|
||||
NS_LITERAL_CSTRING("Cannot tell if ") +
|
||||
escPath + NS_LITERAL_CSTRING(" is a directory or file")
|
||||
).get());
|
||||
NS_LITERAL_CSTRING("Cannot tell if ") + escPath +
|
||||
NS_LITERAL_CSTRING(" is a directory or file")).get());
|
||||
else if (dir) {
|
||||
// make sure we have a trailing slash
|
||||
escPath += "/";
|
||||
|
@ -146,11 +145,12 @@ nsIOService::InitFileFromURLSpec(nsIFile *aFile, const nsACString &aURL)
|
|||
NS_EscapeURL(fileExtension, esc_FileExtension|esc_AlwaysCopy, path);
|
||||
}
|
||||
|
||||
NS_UnescapeURL((char *) path.get());
|
||||
NS_UnescapeURL(path);
|
||||
|
||||
// wack off leading :'s
|
||||
if (path.CharAt(0) == ':')
|
||||
path.Cut(0, 1);
|
||||
|
||||
return localFile->InitWithPath(path.get());
|
||||
// assuming path is encoded in the native charset
|
||||
return localFile->InitWithNativePath(path);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#define INCL_DOS
|
||||
#include "nsIOService.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
static int isleadbyte(int c);
|
||||
|
@ -51,9 +50,10 @@ NS_IMETHODIMP
|
|||
nsIOService::GetURLSpecFromFile(nsIFile *aFile, nsACString &result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsXPIDLCString ePath;
|
||||
nsCAutoString ePath;
|
||||
|
||||
rv = aFile->GetPath(getter_Copies(ePath));
|
||||
// construct URL spec from native file path
|
||||
rv = aFile->GetNativePath(ePath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Replace \ with / to convert to an url
|
||||
|
@ -83,9 +83,8 @@ nsIOService::GetURLSpecFromFile(nsIFile *aFile, nsACString &result)
|
|||
rv = aFile->IsDirectory(&dir);
|
||||
if (NS_FAILED(rv))
|
||||
NS_WARNING(PromiseFlatCString(
|
||||
NS_LITERAL_CSTRING("Cannot tell if ") +
|
||||
escPath + NS_LITERAL_CSTRING(" is a directory or file")
|
||||
).get());
|
||||
NS_LITERAL_CSTRING("Cannot tell if ") + escPath +
|
||||
NS_LITERAL_CSTRING(" is a directory or file")).get());
|
||||
else if (dir) {
|
||||
// make sure we have a trailing slash
|
||||
escPath += "/";
|
||||
|
@ -127,13 +126,14 @@ nsIOService::InitFileFromURLSpec(nsIFile *aFile, const nsACString &aURL)
|
|||
NS_EscapeURL(fileExtension, esc_FileExtension|esc_AlwaysCopy, path);
|
||||
}
|
||||
|
||||
NS_UnescapeURL((char *) path.get());
|
||||
NS_UnescapeURL(path);
|
||||
|
||||
// remove leading '\'
|
||||
if (path.CharAt(0) == '\\')
|
||||
path.Cut(0, 1);
|
||||
|
||||
return localFile->InitWithPath(path.get());
|
||||
// assuming path is encoded in the native charset
|
||||
return localFile->InitWithNativePath(path);
|
||||
}
|
||||
|
||||
static int isleadbyte(int c)
|
||||
|
|
|
@ -40,16 +40,16 @@
|
|||
/* Unix-specific local file uri parsing */
|
||||
#include "nsIOService.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsILocalFile.h"
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIOService::GetURLSpecFromFile(nsIFile *aFile, nsACString &result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsXPIDLCString ePath;
|
||||
nsCAutoString ePath;
|
||||
|
||||
rv = aFile->GetPath(getter_Copies(ePath));
|
||||
// construct URL spec from native file path
|
||||
rv = aFile->GetNativePath(ePath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCAutoString escPath;
|
||||
|
@ -67,9 +67,8 @@ nsIOService::GetURLSpecFromFile(nsIFile *aFile, nsACString &result)
|
|||
rv = aFile->IsDirectory(&dir);
|
||||
if (NS_FAILED(rv))
|
||||
NS_WARNING(PromiseFlatCString(
|
||||
NS_LITERAL_CSTRING("Cannot tell if ") +
|
||||
escPath + NS_LITERAL_CSTRING(" is a directory or file")
|
||||
).get());
|
||||
NS_LITERAL_CSTRING("Cannot tell if ") + escPath +
|
||||
NS_LITERAL_CSTRING(" is a directory or file")).get());
|
||||
else if (dir) {
|
||||
// make sure we have a trailing slash
|
||||
escPath += "/";
|
||||
|
@ -105,7 +104,8 @@ nsIOService::InitFileFromURLSpec(nsIFile* aFile, const nsACString &aURL)
|
|||
NS_EscapeURL(fileExtension, esc_FileExtension|esc_AlwaysCopy, path);
|
||||
}
|
||||
|
||||
NS_UnescapeURL((char *) path.get());
|
||||
NS_UnescapeURL(path);
|
||||
|
||||
return localFile->InitWithPath(path.get());
|
||||
// assuming path is encoded in the native charset
|
||||
return localFile->InitWithNativePath(path);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
/* Windows-specific local file uri parsing */
|
||||
#include "nsIOService.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include <windows.h>
|
||||
|
||||
|
@ -48,9 +47,10 @@ NS_IMETHODIMP
|
|||
nsIOService::GetURLSpecFromFile(nsIFile *aFile, nsACString &result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsXPIDLCString ePath;
|
||||
nsCAutoString ePath;
|
||||
|
||||
rv = aFile->GetPath(getter_Copies(ePath));
|
||||
// construct URL spec from native file path
|
||||
rv = aFile->GetNativePath(ePath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Replace \ with / to convert to an url
|
||||
|
@ -80,9 +80,8 @@ nsIOService::GetURLSpecFromFile(nsIFile *aFile, nsACString &result)
|
|||
rv = aFile->IsDirectory(&dir);
|
||||
if (NS_FAILED(rv))
|
||||
NS_WARNING(PromiseFlatCString(
|
||||
NS_LITERAL_CSTRING("Cannot tell if ") +
|
||||
escPath + NS_LITERAL_CSTRING(" is a directory or file")
|
||||
).get());
|
||||
NS_LITERAL_CSTRING("Cannot tell if ") + escPath +
|
||||
NS_LITERAL_CSTRING(" is a directory or file")).get());
|
||||
else if (dir) {
|
||||
// make sure we have a trailing slash
|
||||
escPath += "/";
|
||||
|
@ -124,11 +123,12 @@ nsIOService::InitFileFromURLSpec(nsIFile *aFile, const nsACString &aURL)
|
|||
NS_EscapeURL(fileExtension, esc_FileExtension|esc_AlwaysCopy, path);
|
||||
}
|
||||
|
||||
NS_UnescapeURL((char *) path.get());
|
||||
NS_UnescapeURL(path);
|
||||
|
||||
// remove leading '\'
|
||||
if (path.CharAt(0) == '\\')
|
||||
path.Cut(0, 1);
|
||||
|
||||
return localFile->InitWithPath(path.get());
|
||||
// assuming path is encoded in the native charset
|
||||
return localFile->InitWithNativePath(path);
|
||||
}
|
||||
|
|
|
@ -2157,8 +2157,8 @@ nsStandardURL::GetFile(nsIFile **result)
|
|||
|
||||
#if defined(PR_LOGGING)
|
||||
if (LOG_ENABLED()) {
|
||||
nsXPIDLCString path;
|
||||
localFile->GetPath(getter_Copies(path));
|
||||
nsCAutoString path;
|
||||
localFile->GetNativePath(path);
|
||||
LOG(("nsStandardURL::GetFile [this=%p spec=%s resulting_path=%s]\n",
|
||||
this, mSpec.get(), path.get()));
|
||||
}
|
||||
|
|
|
@ -178,9 +178,9 @@ NS_IMETHODIMP nsDiskCacheDeviceInfo::GetUsageReport(char ** usageReport)
|
|||
|
||||
buffer.Append("<tr><td><b>Cache Directory:</b></td><td><tt> ");
|
||||
nsCOMPtr<nsILocalFile> cacheDir;
|
||||
char * path;
|
||||
nsCAutoString path;
|
||||
mDevice->getCacheDirectory(getter_AddRefs(cacheDir));
|
||||
nsresult rv = cacheDir->GetPath(&path);
|
||||
nsresult rv = cacheDir->GetPath(path);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
buffer.Append(path);
|
||||
} else {
|
||||
|
@ -758,7 +758,7 @@ nsDiskCacheDevice::InitializeCacheDirectory()
|
|||
}
|
||||
|
||||
// create a directory with unique name to contain existing cache directory
|
||||
rv = cacheTrashDir->Append("Cache");
|
||||
rv = cacheTrashDir->Append(NS_LITERAL_CSTRING("Cache"));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = cacheTrashDir->CreateUnique(nsIFile::DIRECTORY_TYPE, 0777);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -767,7 +767,7 @@ nsDiskCacheDevice::InitializeCacheDirectory()
|
|||
nsCOMPtr<nsIFile> existingCacheDir;
|
||||
rv = mCacheDirectory->Clone(getter_AddRefs(existingCacheDir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = existingCacheDir->MoveTo(cacheTrashDir, nsnull);
|
||||
rv = existingCacheDir->MoveTo(cacheTrashDir, nsCString());
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
@ -786,7 +786,7 @@ nsDiskCacheDevice::GetCacheTrashDirectory(nsIFile ** result)
|
|||
nsCOMPtr<nsIFile> cacheTrashDir;
|
||||
nsresult rv = mCacheDirectory->Clone(getter_AddRefs(cacheTrashDir));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = cacheTrashDir->SetLeafName("Cache.Trash");
|
||||
rv = cacheTrashDir->SetLeafName(NS_LITERAL_CSTRING("Cache.Trash"));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = cacheTrashDir.get();
|
||||
|
@ -844,7 +844,7 @@ nsDiskCacheDevice::SetCacheParentDirectory(nsILocalFile * parentDir)
|
|||
|
||||
rv = parentDir->Clone(getter_AddRefs(directory));
|
||||
if (NS_FAILED(rv)) return;
|
||||
rv = directory->Append("Cache");
|
||||
rv = directory->Append(NS_LITERAL_CSTRING("Cache"));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
rv = directory->Exists(&exists);
|
||||
|
@ -857,7 +857,7 @@ nsDiskCacheDevice::SetCacheParentDirectory(nsILocalFile * parentDir)
|
|||
// clean up Cache.Trash directories
|
||||
rv = parentDir->Clone(getter_AddRefs(directory));
|
||||
if (NS_FAILED(rv)) return;
|
||||
rv = directory->Append("Cache.Trash");
|
||||
rv = directory->Append(NS_LITERAL_CSTRING("Cache.Trash"));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
rv = directory->Exists(&exists);
|
||||
|
@ -867,7 +867,7 @@ nsDiskCacheDevice::SetCacheParentDirectory(nsILocalFile * parentDir)
|
|||
// clean up obsolete NewCache directory
|
||||
rv = parentDir->Clone(getter_AddRefs(directory));
|
||||
if (NS_FAILED(rv)) return;
|
||||
rv = directory->Append("NewCache");
|
||||
rv = directory->Append(NS_LITERAL_CSTRING("NewCache"));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
rv = directory->Exists(&exists);
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче