fixes bug 142870 "nsIFile should use UCS-2 instead of UTF-8"

r=dougt sr=alecf
This commit is contained in:
darin%netscape.com 2002-05-07 23:07:19 +00:00
Родитель 9d06768fa4
Коммит 6fd5862e6e
95 изменённых файлов: 627 добавлений и 864 удалений

Просмотреть файл

@ -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(NS_LITERAL_CSTRING("Essential Files"));
systemCertFile->AppendNative(NS_LITERAL_CSTRING("Essential Files"));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
#endif
systemCertFile->Append(NS_LITERAL_CSTRING("systemSignature.jar"));
systemCertFile->AppendNative(NS_LITERAL_CSTRING("systemSignature.jar"));
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
nsCOMPtr<nsIZipReader> systemCertZip;
rv = nsComponentManager::CreateInstance(kZipReaderCID, nsnull,

Просмотреть файл

@ -2603,15 +2603,15 @@ nsChromeRegistry::GetProfileRoot(nsCString& aFileURL)
getter_AddRefs(defaultUserChromeFile));
if (NS_FAILED(rv))
return(rv);
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"));
defaultUserContentFile->AppendNative(NS_LITERAL_CSTRING("chrome"));
defaultUserContentFile->AppendNative(NS_LITERAL_CSTRING("userContent.css"));
defaultUserChromeFile->AppendNative(NS_LITERAL_CSTRING("chrome"));
defaultUserChromeFile->AppendNative(NS_LITERAL_CSTRING("userChrome.css"));
// copy along
// It aint an error if these files dont exist
(void) defaultUserContentFile->CopyTo(userChromeDir, nsCString());
(void) defaultUserChromeFile->CopyTo(userChromeDir, nsCString());
(void) defaultUserContentFile->CopyToNative(userChromeDir, nsCString());
(void) defaultUserChromeFile->CopyToNative(userChromeDir, nsCString());
}
}
if (NS_FAILED(rv))
@ -3043,12 +3043,12 @@ nsChromeRegistry::CheckForNewChrome()
nsCOMPtr<nsIFile> chromeFile;
rv = listFile->Clone(getter_AddRefs(chromeFile));
if (NS_FAILED(rv)) return rv;
rv = chromeFile->Append(kChromeFileName);
rv = chromeFile->AppendNative(kChromeFileName);
if (NS_FAILED(rv)) return rv;
nsInt64 chromeDate;
(void)chromeFile->GetLastModifiedTime(&chromeDate.mValue);
rv = listFile->AppendRelativePath(kInstalledChromeFileName);
rv = listFile->AppendRelativeNativePath(kInstalledChromeFileName);
if (NS_FAILED(rv)) return rv;
nsInt64 listFileDate;
(void)listFile->GetLastModifiedTime(&listFileDate.mValue);

Просмотреть файл

@ -2182,19 +2182,17 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission,
&rv));
NS_ENSURE_SUCCESS(rv, rv);
rv = file->InitWithPath(NS_ConvertUCS2toUTF8(value));
rv = file->InitWithPath(value);
if (NS_SUCCEEDED(rv)) {
//
// Get the leaf path name (to be submitted as the value)
//
nsCAutoString leafNameChars;
rv = file->GetLeafName(leafNameChars);
nsAutoString filename;
rv = file->GetLeafName(filename);
NS_ENSURE_SUCCESS(rv, rv);
if (!leafNameChars.IsEmpty()) {
NS_ConvertUTF8toUCS2 filename(leafNameChars);
if (!filename.IsEmpty()) {
PRBool acceptsFiles = PR_FALSE;
aFormSubmission->AcceptsFiles(&acceptsFiles);

Просмотреть файл

@ -567,7 +567,7 @@ nsXULPrototypeCache::AbortFastLoads()
// Now rename or remove the file.
if (file) {
#ifdef DEBUG
file->MoveTo(nsnull, NS_LITERAL_CSTRING("Aborted.mfasl"));
file->MoveToNative(nsnull, NS_LITERAL_CSTRING("Aborted.mfasl"));
#else
file->Remove(PR_FALSE);
#endif
@ -877,7 +877,7 @@ nsXULPrototypeCache::StartFastLoad(nsIURI* aURI)
if (NS_FAILED(rv))
return rv;
nsCAutoString chromePath;
rv = chromeDir->GetPath(chromePath);
rv = chromeDir->GetNativePath(chromePath);
if (NS_FAILED(rv))
return rv;
@ -965,7 +965,7 @@ nsXULPrototypeCache::StartFastLoad(nsIURI* aURI)
xio->mInputStream = nsnull;
#ifdef DEBUG
file->MoveTo(nsnull, NS_LITERAL_CSTRING("Invalid.mfasl"));
file->MoveToNative(nsnull, NS_LITERAL_CSTRING("Invalid.mfasl"));
#else
file->Remove(PR_FALSE);
#endif

Просмотреть файл

@ -383,7 +383,7 @@ nsresult nsDefaultURIFixup::ConvertFileToStringURI(nsString& aIn,
}
else {
// input is unicode
rv = NS_NewLocalFile(NS_ConvertUCS2toUTF8(aIn), PR_FALSE, getter_AddRefs(filePath));
rv = NS_NewLocalFile(aIn, PR_FALSE, getter_AddRefs(filePath));
}
if (NS_SUCCEEDED(rv))

Просмотреть файл

@ -96,9 +96,9 @@ CAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(GetResCString(str_DefaultsDirName, strBuf));
rv = localFile->AppendRelativeNativePath(GetResCString(str_DefaultsDirName, strBuf));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(GetResCString(str_PrefDefaultsDirName, strBuf));
rv = localFile->AppendRelativeNativePath(GetResCString(str_PrefDefaultsDirName, strBuf));
}
}
else if (nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR) == 0 ||
@ -106,9 +106,9 @@ CAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(GetResCString(str_DefaultsDirName, strBuf));
rv = localFile->AppendRelativeNativePath(GetResCString(str_DefaultsDirName, strBuf));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(GetResCString(str_ProfileDefaultsDirName, strBuf));
rv = localFile->AppendRelativeNativePath(GetResCString(str_ProfileDefaultsDirName, strBuf));
}
}
else if (nsCRT::strcmp(prop, NS_APP_USER_PROFILES_ROOT_DIR) == 0)
@ -119,25 +119,25 @@ CAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(GetResCString(str_ResDirName, strBuf));
rv = localFile->AppendRelativeNativePath(GetResCString(str_ResDirName, strBuf));
}
else if (nsCRT::strcmp(prop, NS_APP_CHROME_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(GetResCString(str_ChromeDirName, strBuf));
rv = localFile->AppendRelativeNativePath(GetResCString(str_ChromeDirName, strBuf));
}
else if (nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(GetResCString(str_PlugInsDirName, strBuf));
rv = localFile->AppendRelativeNativePath(GetResCString(str_PlugInsDirName, strBuf));
}
else if (nsCRT::strcmp(prop, NS_APP_SEARCH_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(GetResCString(str_SearchPlugInsDirName, strBuf));
rv = localFile->AppendRelativeNativePath(GetResCString(str_SearchPlugInsDirName, strBuf));
}
if (localFile && NS_SUCCEEDED(rv))
@ -242,7 +242,7 @@ NS_METHOD CAppFileLocationProvider::GetDefaultUserProfileRoot(nsILocalFile **aLo
rv = GetProductDirectory(getter_AddRefs(localDir));
if (NS_FAILED(rv)) return rv;
rv = localDir->AppendRelativePath(GetResCString(str_ProfilesRootDirName, strBuf));
rv = localDir->AppendRelativeNativePath(GetResCString(str_ProfilesRootDirName, strBuf));
if (NS_FAILED(rv)) return rv;
rv = localDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)

Просмотреть файл

@ -91,8 +91,8 @@ static CFPlugInRef LoadPDEPlugIn()
rv = dirService->Get(NS_XPCOM_CURRENT_PROCESS_DIR, NS_GET_IID(nsILocalFileMac), getter_AddRefs(pluginDir));
if (NS_FAILED(rv))
return nsnull;
pluginDir->Append(NS_LITERAL_CSTRING("Essential Files"));
pluginDir->Append(NS_LITERAL_CSTRING("PrintDialogPDE.plugin"));
pluginDir->AppendNative(NS_LITERAL_CSTRING("Essential Files"));
pluginDir->AppendNative(NS_LITERAL_CSTRING("PrintDialogPDE.plugin"));
FSSpec pluginSpec;
rv = pluginDir->GetFSSpec(&pluginSpec);
if (NS_FAILED(rv))

Просмотреть файл

@ -839,9 +839,7 @@ nsresult nsWebBrowserPersist::SendErrorStatusChange(
nsAutoString path;
if (file)
{
nsCAutoString filePath;
file->GetPath(filePath);
path = NS_ConvertUTF8toUCS2(filePath);
file->GetPath(path);
}
else
{

Просмотреть файл

@ -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(NS_LITERAL_CSTRING("urls.txt"));
local_file->AppendNative(NS_LITERAL_CSTRING("urls.txt"));
local_file->OpenANSIFileDesc(aMode, &fd);
}

Просмотреть файл

@ -92,21 +92,21 @@ winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile *
{
rv = GetProductDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(APP_REGISTRY_NAME);
rv = localFile->AppendNative(APP_REGISTRY_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_DEFAULTS_50_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_PREF_DEFAULTS_50_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(DEFAULTS_PREF_DIR_NAME);
rv = localFile->AppendRelativeNativePath(DEFAULTS_PREF_DIR_NAME);
}
}
else if (nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR) == 0 ||
@ -114,9 +114,9 @@ winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile *
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(DEFAULTS_PROFILE_DIR_NAME);
rv = localFile->AppendRelativeNativePath(DEFAULTS_PROFILE_DIR_NAME);
}
}
else if (nsCRT::strcmp(prop, NS_APP_USER_PROFILES_ROOT_DIR) == 0)
@ -127,25 +127,25 @@ winEmbedFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile *
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(RES_DIR_NAME);
rv = localFile->AppendRelativeNativePath(RES_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_CHROME_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(CHROME_DIR_NAME);
rv = localFile->AppendRelativeNativePath(CHROME_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(PLUGINS_DIR_NAME);
rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_SEARCH_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(SEARCH_DIR_NAME);
rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME);
}
if (localFile && NS_SUCCEEDED(rv))
@ -252,7 +252,7 @@ NS_METHOD winEmbedFileLocProvider::GetDefaultUserProfileRoot(nsILocalFile **aLoc
if (NS_FAILED(rv)) return rv;
// These 3 platforms share this part of the path - do them as one
rv = localDir->AppendRelativePath(PROFILE_ROOT_DIR_NAME);
rv = localDir->AppendRelativeNativePath(PROFILE_ROOT_DIR_NAME);
if (NS_FAILED(rv)) return rv;
rv = localDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)

Просмотреть файл

@ -171,9 +171,7 @@ inFileSearch::GetStringResultAt(PRInt32 aIndex, nsAString& _retval)
}
if (file) {
nsCAutoString temp;
mLastResult->GetPath(temp);
_retval = NS_ConvertUTF8toUCS2(temp);
mLastResult->GetPath(_retval);
if (mReturnRelativePaths)
MakePathRelative(_retval);
} else {
@ -543,12 +541,10 @@ inFileSearch::GetNextDirectory(nsISimpleEnumerator* aEnum)
PRBool
inFileSearch::MatchFile(nsIFile* aFile)
{
nsCAutoString fileName;
nsAutoString fileName;
aFile->GetLeafName(fileName);
NS_ConvertUTF8toUCS2 temp(fileName);
PRUnichar* fileNameUnicode = ToNewUnicode(temp);
PRUnichar* fileNameUnicode = ToNewUnicode(fileName);
PRBool match;
@ -610,9 +606,8 @@ inFileSearch::MakePathRelative(nsAString& aPath)
{
// get an nsAutoString version of the search path
nsCAutoString temp;
mSearchPath->GetPath(temp);
NS_ConvertUTF8toUCS2 searchPath(temp);
nsAutoString searchPath;
mSearchPath->GetPath(searchPath);
nsAutoString result;
PRUint32 len = searchPath.Length();

Просмотреть файл

@ -445,7 +445,7 @@ nsresult nsAutoConfig::readOfflineFile()
if (NS_FAILED(rv))
return rv;
failoverFile->Append(NS_LITERAL_CSTRING("failover.jsc"));
failoverFile->AppendNative(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(NS_LITERAL_CSTRING("failover.jsc"));
failoverFile->AppendNative(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(NS_LITERAL_CSTRING("Essential Files"));
jsFile->AppendNative(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(NS_LITERAL_CSTRING("autoconfig"));
rv = jsFile->AppendNative(NS_LITERAL_CSTRING("autoconfig"));
if (NS_FAILED(rv))
return rv;
}
rv = jsFile->Append(nsDependentCString(aFileName));
rv = jsFile->AppendNative(nsDependentCString(aFileName));
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -1307,7 +1307,7 @@ PUBLIC nsresult Wallet_DefaultsDirectory(nsFileSpec& dirSpec) {
res = NS_GetSpecialDirectory(NS_APP_DEFAULTS_50_DIR, getter_AddRefs(aFile));
if (NS_FAILED(res)) return res;
res = aFile->Append(NS_LITERAL_CSTRING("wallet"));
res = aFile->AppendNative(NS_LITERAL_CSTRING("wallet"));
if (NS_FAILED(res)) return res;
res = NS_NewFileSpecFromIFile(aFile, getter_AddRefs(tempSpec));

Просмотреть файл

@ -1208,7 +1208,7 @@ NS_IMETHODIMP mozXMLTermSession::ExportHTML(const PRUnichar* aFilename,
XMLT_LOG(mozXMLTermSession::ExportHTML,0,
("Exporting %d\n", mCountExportHTML));
result = localFile->InitWithPath(NS_ConvertUCS2toUTF8(filename));
result = localFile->InitWithPath(filename);
if (NS_FAILED(result))
return NS_ERROR_FAILURE;

Просмотреть файл

@ -852,9 +852,7 @@ mozJSComponentLoader::AttemptRegistration(nsIFile *component,
// get the file name
if (component)
{
nsCAutoString leafName;
component->GetLeafName(leafName);
fileName.Assign(NS_ConvertUTF8toUCS2(leafName));
component->GetLeafName(fileName);
}
// this string can't come from a string bundle, because we

Просмотреть файл

@ -304,12 +304,12 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsILocalFile> currentFile = do_CreateInstance("@mozilla.org/file/local;1");
if (currentFile && !defaultName.IsEmpty()) {
result = currentFile->InitWithPath(NS_ConvertUCS2toUTF8(defaultName));
result = currentFile->InitWithPath(defaultName);
if (NS_SUCCEEDED(result)) {
nsCAutoString leafName;
nsAutoString leafName;
currentFile->GetLeafName(leafName);
if (!leafName.IsEmpty()) {
filePicker->SetDefaultString(NS_ConvertUTF8toUCS2(leafName).get());
filePicker->SetDefaultString(leafName.get());
}
// set directory
@ -335,11 +335,10 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsILocalFile> localFile;
result = filePicker->GetFile(getter_AddRefs(localFile));
if (localFile) {
nsCAutoString unicodePath;
nsAutoString unicodePath;
result = localFile->GetPath(unicodePath);
if (!unicodePath.IsEmpty()) {
NS_ConvertUTF8toUCS2 pathName(unicodePath);
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, pathName);
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, unicodePath);
return NS_OK;
}
}

Просмотреть файл

@ -304,12 +304,12 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsILocalFile> currentFile = do_CreateInstance("@mozilla.org/file/local;1");
if (currentFile && !defaultName.IsEmpty()) {
result = currentFile->InitWithPath(NS_ConvertUCS2toUTF8(defaultName));
result = currentFile->InitWithPath(defaultName);
if (NS_SUCCEEDED(result)) {
nsCAutoString leafName;
nsAutoString leafName;
currentFile->GetLeafName(leafName);
if (!leafName.IsEmpty()) {
filePicker->SetDefaultString(NS_ConvertUTF8toUCS2(leafName).get());
filePicker->SetDefaultString(leafName.get());
}
// set directory
@ -335,11 +335,10 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsILocalFile> localFile;
result = filePicker->GetFile(getter_AddRefs(localFile));
if (localFile) {
nsCAutoString unicodePath;
nsAutoString unicodePath;
result = localFile->GetPath(unicodePath);
if (!unicodePath.IsEmpty()) {
NS_ConvertUTF8toUCS2 pathName(unicodePath);
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, pathName);
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, unicodePath);
return NS_OK;
}
}

Просмотреть файл

@ -63,7 +63,7 @@ FileToURI(const char *aFilename)
{
nsCOMPtr<nsILocalFile> lf(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID));
// XXX Handle relative paths somehow.
lf->InitWithPath(nsDependentCString(aFilename));
lf->InitWithNativePath(nsDependentCString(aFilename));
nsIFileURL *url;
CallCreateInstance(kStandardURLCID, &url);

Просмотреть файл

@ -1175,7 +1175,7 @@ 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(NS_LITERAL_CSTRING("absync.dat"));
rv = historyFile->AppendNative(NS_LITERAL_CSTRING("absync.dat"));
NS_ENSURE_SUCCESS(rv, rv);
// TODO: Convert the rest of the code to use
@ -1223,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(NS_LITERAL_CSTRING("absync.lck"));
rv = lockFile->AppendNative(NS_LITERAL_CSTRING("absync.lck"));
if (NS_SUCCEEDED(rv))
{

Просмотреть файл

@ -545,7 +545,7 @@ nsresult nsAbLDAPProcessReplicationData::OpenABForReplicatedDir(PRBool aCreate)
Done(PR_FALSE);
return rv;
}
nsCAutoString backupFileLeafName;
nsAutoString backupFileLeafName;
rv = mBackupReplicationFile->GetLeafName(backupFileLeafName);
if(NS_FAILED(rv)) {
delete dbPath;
@ -570,7 +570,7 @@ nsresult nsAbLDAPProcessReplicationData::OpenABForReplicatedDir(PRBool aCreate)
}
else {
// set backup file to existing replication file for copy
mBackupReplicationFile->SetLeafName(nsDependentCString(mDirServerInfo->replInfo->fileName));
mBackupReplicationFile->SetNativeLeafName(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.

Просмотреть файл

@ -1324,7 +1324,7 @@ NS_IMETHODIMP nsAddressBook::ExportAddressBook(nsIAbDirectory *aDirectory)
}
nsCAutoString leafName;
rv = localFile->GetLeafName(leafName);
rv = localFile->GetNativeLeafName(leafName);
NS_ENSURE_SUCCESS(rv,rv);
// we're looking for .tab, .txt, .csv, .ldi or .ldif

Просмотреть файл

@ -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(NS_LITERAL_CSTRING("rulesbackup.dat"));
backupFile->AppendNative(NS_LITERAL_CSTRING("rulesbackup.dat"));
PRBool exists;
backupFile->Exists(&exists);
if (exists)
backupFile->Remove(PR_FALSE);
return localFilterFile->CopyTo(localParentDir, NS_LITERAL_CSTRING("rulesbackup.dat"));
return localFilterFile->CopyToNative(localParentDir, NS_LITERAL_CSTRING("rulesbackup.dat"));
}
nsresult nsMsgFilterService::AlertBackingUpFilterFile(nsIMsgWindow *aMsgWindow)

Просмотреть файл

@ -213,6 +213,7 @@ nsresult ConvertAndSanitizeFileName(const char * displayName, PRUnichar ** unico
The display name is in UTF-8 because it has been escaped from JS
*/
NS_UnescapeURL(unescapedName);
NS_ConvertUTF8toUCS2 ucs2Str(unescapedName);
nsresult rv = NS_OK;
#if defined(XP_MAC)
@ -220,14 +221,12 @@ nsresult ConvertAndSanitizeFileName(const char * displayName, PRUnichar ** unico
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->SetLeafName(unescapedName)))
if (NS_SUCCEEDED(aLocalFile->SetLeafName(ucs2Str)))
{
aLocalFile->GetLeafName(unescapedName);
aLocalFile->GetLeafName(ucs2Str);
}
#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, '-');
@ -974,7 +973,7 @@ nsMessenger::SaveAs(const char* url, PRBool asFile, nsIMsgIdentity* identity, ns
if (NS_FAILED(rv))
goto done;
nsCAutoString fileName;
nsAutoString fileName;
rv = localFile->GetLeafName(fileName);
if (NS_FAILED(rv)) goto done;

Просмотреть файл

@ -1935,7 +1935,7 @@ 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(NS_LITERAL_CSTRING("addr-migrate"));
rv = tmpLDIFFile->AppendNative(NS_LITERAL_CSTRING("addr-migrate"));
if (NS_FAILED(rv) || !tmpLDIFFile) return;
rv = tmpLDIFFile->CreateUnique(nsIFile::DIRECTORY_TYPE, 0700);

Просмотреть файл

@ -565,7 +565,7 @@ nsMsgMailSession::GetSelectedLocaleDataDir(nsIFile *defaultsDir)
rv = defaultsDir->Clone(getter_AddRefs(localeDataDir));
NS_ENSURE_SUCCESS(rv,rv);
rv = localeDataDir->Append(NS_ConvertUCS2toUTF8(localeName));
rv = localeDataDir->Append(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->Append(NS_ConvertUCS2toUTF8(localeName));
rv = defaultsDir->Append(localeName);
NS_ENSURE_SUCCESS(rv,rv);
}
}

Просмотреть файл

@ -531,7 +531,7 @@ NS_IMETHODIMP nsMsgDBFolder::GetOfflineFileTransport(nsMsgKey msgKey, PRUint32 *
mPath->GetNativePath(getter_Copies(nativePath));
nsCOMPtr <nsILocalFile> localStore;
rv = NS_NewLocalFile(nativePath, PR_TRUE, getter_AddRefs(localStore));
rv = NS_NewNativeLocalFile(nativePath, PR_TRUE, getter_AddRefs(localStore));
if (NS_SUCCEEDED(rv) && localStore)
{
NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);

Просмотреть файл

@ -165,7 +165,7 @@ nsresult RecursiveCopy(nsIFile* srcDir, nsIFile* destDir)
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsILocalFile> newChild(do_QueryInterface(destClone));
nsCAutoString leafName;
nsAutoString leafName;
dirEntry->GetLeafName(leafName);
newChild->AppendRelativePath(leafName);
rv = newChild->Exists(&exists);
@ -175,7 +175,7 @@ nsresult RecursiveCopy(nsIFile* srcDir, nsIFile* destDir)
}
}
else
rv = dirEntry->CopyTo(destDir, nsCString());
rv = dirEntry->CopyTo(destDir, nsString());
}
}

Просмотреть файл

@ -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(NS_LITERAL_CSTRING(PREF_FILE_NAME_IN_4x));
rv = profileLocation->AppendNative(NS_LITERAL_CSTRING(PREF_FILE_NAME_IN_4x));
if (NS_FAILED(rv)) return rv;
PRBool exists = PR_FALSE;
rv = profileLocation->Exists(&exists);
@ -115,7 +115,7 @@ 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(NS_LITERAL_CSTRING("Mail"));
rv = mailLocation->AppendNative(NS_LITERAL_CSTRING("Mail"));
if (NS_FAILED(rv)) return rv;
nsCAutoString nativePath;
rv = mailLocation->GetNativePath(nativePath);

Просмотреть файл

@ -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, nsCString());
rv = defaultMessagesFile->CopyTo(localParentDir, nsString());
if (NS_FAILED(rv)) return rv;
}
return NS_OK;

Просмотреть файл

@ -1555,7 +1555,7 @@ nsOutputFileStream * nsParseNewMailState::GetLogFile ()
nsCOMPtr<nsIFile> logDir;
NS_GetSpecialDirectory(NS_APP_MAIL_50_DIR, getter_AddRefs(logDir));
logDir->Append(NS_LITERAL_CSTRING("filter.log"));
logDir->AppendNative(NS_LITERAL_CSTRING("filter.log"));
nsCAutoString pathBuf;
nsresult rv = logDir->GetNativePath(pathBuf);

Просмотреть файл

@ -518,7 +518,7 @@ nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32
{
// check if attachment exists
if (aIsUnicode)
pFile->InitWithPath (NS_ConvertUCS2toUTF8(aFiles[i].lpszPathName)) ;
pFile->InitWithPath (nsDependentString(aFiles[i].lpszPathName)) ;
else
pFile->InitWithNativePath (nsDependentCString((const char*)aFiles[i].lpszPathName)) ;
PRBool bExist ;
@ -540,34 +540,31 @@ nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32
rv = NS_FileSpecToIFile(&tmpDir, getter_AddRefs(pTempPath)) ;
if(NS_FAILED(rv) || !pTempPath) return rv ;
// temp dir path
nsCAutoString tempPath ;
nsAutoString tempPath ;
rv = pTempPath->GetPath (tempPath) ;
if(NS_FAILED(rv) || tempPath.IsEmpty()) return rv ;
// filename of the file attachment
nsCAutoString leafName ;
nsAutoString leafName ;
pFile->GetLeafName (leafName) ;
if(NS_FAILED(rv) || leafName.IsEmpty()) return rv ;
// full path of the file attachment
nsCAutoString path ;
nsAutoString path ;
pFile->GetPath (path) ;
if(NS_FAILED(rv) || path.IsEmpty()) return rv ;
// dir path of the file attachment
nsCAutoString dirPath (path.get()) ;
nsAutoString 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
// XXX need nsCaseInsensitiveUTF8StringComparator()
if (!Compare(NS_ConvertUTF8toUCS2(tempPath),
NS_ConvertUTF8toUCS2(dirPath),
nsCaseInsensitiveStringComparator()))
if (!Compare(tempPath, dirPath, nsCaseInsensitiveStringComparator()))
{
// if not already existing, create another temp dir for mapi within Win temp dir
nsCAutoString strTempDir ;
nsAutoString strTempDir ;
// this is windows only so we can do "\\"
strTempDir = tempPath + NS_LITERAL_CSTRING("\\moz_mapi");
strTempDir = tempPath + NS_LITERAL_STRING("\\moz_mapi");
pTempDir->InitWithPath (strTempDir) ;
pTempDir->Exists (&bExist) ;
if (!bExist)
@ -584,25 +581,22 @@ 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);
nsDependentString fileNameUCS2(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.
// XXX need nsCaseInsensitiveUTF8StringComparator()
if (!Compare(nsDependentString(aFiles[i].lpszFileName),
NS_ConvertUTF8toUCS2(leafName),
nsCaseInsensitiveStringComparator()))
if (!Compare(fileNameUCS2, leafName, nsCaseInsensitiveStringComparator()))
{
rv = pFile->CopyTo(pTempDir, fileNameUTF8);
rv = pFile->CopyTo(pTempDir, fileNameUCS2);
pFile->InitWithPath(strTempDir) ;
pFile->Append(fileNameUTF8);
pFile->Append(fileNameUCS2);
}
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, fileNameUTF8);
rv = pFile->MoveTo(nsnull, fileNameUCS2);
// 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))
@ -621,10 +615,7 @@ nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32
if (NS_FAILED(rv)) return rv ;
nsDependentCString fileNameNative((char *) aFiles[i].lpszFileName);
// now compare the unicode filename string
// XXX need nsCaseInsensitiveUTF8StringComparator()
if (!Compare(fileName,
NS_ConvertUTF8toUCS2(leafName),
nsCaseInsensitiveStringComparator()))
if (!Compare(fileName, leafName, nsCaseInsensitiveStringComparator()))
{
rv = pFile->CopyToNative(pTempDir, fileNameNative);
pFile->InitWithPath(strTempDir) ;
@ -790,7 +781,7 @@ nsresult nsMapiHook::PopulateCompFieldsForSendDocs(nsIMsgCompFields * aCompField
{
nsCOMPtr <nsILocalFile> pFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ;
if (NS_FAILED(rv) || (!pFile) ) return rv ;
pFile->InitWithPath (NS_ConvertUCS2toUTF8(strFilePaths)) ;
pFile->InitWithPath (strFilePaths) ;
PRBool bExist ;
rv = pFile->Exists(&bExist) ;
@ -826,7 +817,7 @@ nsresult nsMapiHook::PopulateCompFieldsForSendDocs(nsIMsgCompFields * aCompField
newFilePaths += offset + strDelimChars.Length() ;
}
pFile->InitWithPath (NS_ConvertUCS2toUTF8(RemainingPaths)) ;
pFile->InitWithPath (RemainingPaths) ;
#ifdef RAJIV_DEBUG
printf ("File : %S \n", RemainingPaths.get()) ;

Просмотреть файл

@ -377,7 +377,7 @@ nsresult nsMapiRegistryUtils::CopyMozMapiToWinSysDir()
getter_AddRefs(pMozMapiFile));
if (NS_FAILED(rv)) return rv;
pMozMapiFile->Append(NS_LITERAL_CSTRING("mozMapi32.dll"));
pMozMapiFile->AppendNative(NS_LITERAL_CSTRING("mozMapi32.dll"));
PRBool bExist;
rv = pMozMapiFile->Exists(&bExist);
@ -395,7 +395,7 @@ nsresult nsMapiRegistryUtils::CopyMozMapiToWinSysDir()
rv = pCurrentMapiFile->Exists(&bExist);
if (NS_SUCCEEDED(rv) && bExist)
{
rv = pCurrentMapiFile->MoveTo(nsnull, NS_LITERAL_CSTRING("Mapi32_moz_bak.dll"));
rv = pCurrentMapiFile->MoveToNative(nsnull, NS_LITERAL_CSTRING("Mapi32_moz_bak.dll"));
if (NS_FAILED(rv)) return rv;
nsCAutoString fullFilePath(buffer);
fullFilePath.Append(NS_LITERAL_CSTRING("\\Mapi32_moz_bak.dll"));
@ -412,7 +412,7 @@ nsresult nsMapiRegistryUtils::CopyMozMapiToWinSysDir()
NS_NAMED_LITERAL_CSTRING(fileName, "Mapi32.dll");
filePath.Assign(buffer);
pCurrentMapiFile->InitWithNativePath(filePath);
rv = pMozMapiFile->CopyTo(pCurrentMapiFile, fileName);
rv = pMozMapiFile->CopyToNative(pCurrentMapiFile, fileName);
if (NS_FAILED(rv))
RestoreBackedUpMapiDll();
return rv;
@ -450,7 +450,7 @@ nsresult nsMapiRegistryUtils::RestoreBackedUpMapiDll()
rv = pPreviousMapiFile->Exists(&bExist);
if (NS_SUCCEEDED(rv) && bExist)
rv = pPreviousMapiFile->MoveTo(nsnull, NS_LITERAL_CSTRING("Mapi32.dll"));
rv = pPreviousMapiFile->MoveToNative(nsnull, NS_LITERAL_CSTRING("Mapi32.dll"));
if (NS_SUCCEEDED(rv))
DeleteRegistryValue(HKEY_LOCAL_MACHINE,
"Software\\Mozilla\\Desktop",

Просмотреть файл

@ -357,7 +357,7 @@ NS_IMETHODIMP nsPrefBranch::GetComplexValue(const char *aPrefName, const nsIID &
return rv;
nsCOMPtr<nsILocalFile> theFile;
rv = NS_NewLocalFile(nsCString(), PR_TRUE, getter_AddRefs(theFile));
rv = NS_NewNativeLocalFile(nsCString(), PR_TRUE, getter_AddRefs(theFile));
if (NS_FAILED(rv))
return rv;
rv = theFile->SetRelativeDescriptor(fromFile, Substring(++keyEnd, strEnd));

Просмотреть файл

@ -314,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(NS_LITERAL_CSTRING("default_prefs.js"));
rv = aFile->AppendNative(NS_LITERAL_CSTRING("default_prefs.js"));
if (NS_FAILED(rv)) return rv;
}
@ -336,7 +336,7 @@ nsresult nsPrefService::UseUserPrefFile()
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(aFile));
if (NS_SUCCEEDED(rv) && aFile) {
rv = aFile->Append(NS_LITERAL_CSTRING("user.js"));
rv = aFile->AppendNative(NS_LITERAL_CSTRING("user.js"));
if (NS_SUCCEEDED(rv)) {
rv = openPrefFile(aFile, PR_FALSE, PR_FALSE, PR_FALSE);
}
@ -585,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(nsDependentCString(specialFiles[k]));
rv = aFile->AppendNative(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");

Просмотреть файл

@ -52,7 +52,7 @@ nsSafeSaveFile::nsSafeSaveFile(nsIFile *aTargetFile, PRInt32 aNumBackupCopies)
nsresult rv;
// determine the actual filename (less the extension)
rv = aTargetFile->GetLeafName(mTargetFileName);
rv = aTargetFile->GetNativeLeafName(mTargetFileName);
if (NS_FAILED(rv)) // yikes! out of memory
return;
@ -66,7 +66,7 @@ nsSafeSaveFile::nsSafeSaveFile(nsIFile *aTargetFile, PRInt32 aNumBackupCopies)
tempFileName = Substring(mTargetFileName, 0, mTargetNameLen) + NS_LITERAL_CSTRING(".tmp");
rv = aTargetFile->Clone(getter_AddRefs(mTempFile));
if (NS_SUCCEEDED(rv))
mTempFile->SetLeafName(tempFileName);
mTempFile->SetNativeLeafName(tempFileName);
}
void nsSafeSaveFile::CleanupFailedSave(void)
@ -106,10 +106,10 @@ nsresult nsSafeSaveFile::PostProcessSave(void)
fileName = Substring(mTargetFileName, 0, mTargetNameLen) + BACKUP_FILE_EXTENSION;
if (mBackupCount > 1)
fileName.AppendInt(mBackupCount - 1);
backupFile->SetLeafName(fileName);
backupFile->SetNativeLeafName(fileName);
} else {
// no backups desired, delete the previous save
backupFile->SetLeafName(mTargetFileName);
backupFile->SetNativeLeafName(mTargetFileName);
}
// remove the file as determined by the logic above
@ -123,27 +123,27 @@ nsresult nsSafeSaveFile::PostProcessSave(void)
// 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);
backupFile->SetNativeLeafName(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);
backupFile->MoveToNative(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);
rv = backupFile->MoveTo(0, fileName);
backupFile->SetNativeLeafName(mTargetFileName);
rv = backupFile->MoveToNative(0, fileName);
// it's only an error if the file exists
if ((NS_FAILED(rv)) && (rv != NS_ERROR_FILE_NOT_FOUND))
return rv;
}
// finally rename the temp file to the original name (i.e. <filename.tmp> to <filename.js>)
rv = mTempFile->MoveTo(0, mTargetFileName);
rv = mTempFile->MoveToNative(0, mTargetFileName);
return rv;
}
@ -168,7 +168,7 @@ nsresult nsSafeSaveFile::PurgeOldestBackup(void)
while (--backupCount >= 0) {
if (backupCount)
fileName.AppendInt(backupCount);
backupFile->SetLeafName(fileName);
backupFile->SetNativeLeafName(fileName);
rv = backupFile->Remove(PR_FALSE);
if (NS_SUCCEEDED(rv)) {
return NS_OK;

Просмотреть файл

@ -54,7 +54,7 @@ class nsSafeSaveFile {
private:
nsCOMPtr<nsIFile> mTempFile;
nsCString mTargetFileName; // UTF-8
nsCString mTargetFileName; // native charset
PRInt32 mTargetNameLen;
PRInt32 mBackupCount;
};

Просмотреть файл

@ -193,7 +193,7 @@ nsMPFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_re
{
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(PREFS_FILE_50_NAME);
rv = localFile->AppendNative(PREFS_FILE_50_NAME);
}
else if (inAtom == sApp_UserProfileDirectory50)
{
@ -203,19 +203,19 @@ nsMPFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_re
{
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(USER_CHROME_DIR_50_NAME);
rv = localFile->AppendNative(USER_CHROME_DIR_50_NAME);
}
else if (inAtom == sApp_LocalStore50)
{
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(LOCAL_STORE_FILE_50_NAME);
rv = localFile->AppendNative(LOCAL_STORE_FILE_50_NAME);
}
else if (inAtom == sApp_History50)
{
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(HISTORY_FILE_50_NAME);
rv = localFile->AppendNative(HISTORY_FILE_50_NAME);
}
else if (inAtom == sApp_UsersPanels50)
{
@ -226,7 +226,7 @@ nsMPFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_re
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(PANELS_FILE_50_NAME);
rv = localFile->AppendNative(PANELS_FILE_50_NAME);
}
else if (inAtom == sApp_UsersMimeTypes50)
{
@ -237,19 +237,19 @@ nsMPFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_re
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(MIME_TYPES_FILE_50_NAME);
rv = localFile->AppendNative(MIME_TYPES_FILE_50_NAME);
}
else if (inAtom == sApp_BookmarksFile50)
{
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(BOOKMARKS_FILE_50_NAME);
rv = localFile->AppendNative(BOOKMARKS_FILE_50_NAME);
}
else if (inAtom == sApp_DownloadsFile50)
{
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(DOWNLOADS_FILE_50_NAME);
rv = localFile->AppendNative(DOWNLOADS_FILE_50_NAME);
}
else if (inAtom == sApp_SearchFile50)
{
@ -260,31 +260,31 @@ nsMPFileLocProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_re
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(SEARCH_FILE_50_NAME);
rv = localFile->AppendNative(SEARCH_FILE_50_NAME);
}
else if (inAtom == sApp_MailDirectory50)
{
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(MAIL_DIR_50_NAME);
rv = localFile->AppendNative(MAIL_DIR_50_NAME);
}
else if (inAtom == sApp_ImapMailDirectory50)
{
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(IMAP_MAIL_DIR_50_NAME);
rv = localFile->AppendNative(IMAP_MAIL_DIR_50_NAME);
}
else if (inAtom == sApp_NewsDirectory50)
{
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(NEWS_DIR_50_NAME);
rv = localFile->AppendNative(NEWS_DIR_50_NAME);
}
else if (inAtom == sApp_MessengerFolderCache50)
{
rv = mProfileDir->Clone(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(MSG_FOLDER_CACHE_DIR_50_NAME);
rv = localFile->AppendNative(MSG_FOLDER_CACHE_DIR_50_NAME);
}
NS_RELEASE(inAtom);
@ -342,13 +342,13 @@ nsresult RecursiveCopy(nsIFile* srcDir, nsIFile* destDir)
{
nsCOMPtr<nsILocalFile> newChild(do_QueryInterface(destClone));
nsCAutoString leafName;
dirEntry->GetLeafName(leafName);
newChild->AppendRelativePath(leafName);
dirEntry->GetNativeLeafName(leafName);
newChild->AppendRelativeNativePath(leafName);
rv = RecursiveCopy(dirEntry, newChild);
}
}
else
rv = dirEntry->CopyTo(destDir, nsCString());
rv = dirEntry->CopyToNative(destDir, nsCString());
}
}

Просмотреть файл

@ -1897,7 +1897,7 @@ nsPluginStreamListenerPeer::SetupPluginCacheFile(nsIChannel* channel)
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(pluginTmp));
if (NS_FAILED(rv)) return rv;
rv = pluginTmp->Append(kPluginTmpDirName);
rv = pluginTmp->AppendNative(kPluginTmpDirName);
if (NS_FAILED(rv)) return rv;
(void) pluginTmp->Create(nsIFile::DIRECTORY_TYPE,0777);
@ -3325,7 +3325,7 @@ NS_IMETHODIMP nsPluginHostImpl::Destroy(void)
nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(pluginTmp));
if (NS_FAILED(rv)) return rv;
rv = pluginTmp->Append(kPluginTmpDirName);
rv = pluginTmp->AppendNative(kPluginTmpDirName);
if (NS_FAILED(rv)) return rv;
pluginTmp->Remove(PR_TRUE);
@ -5140,7 +5140,7 @@ cidToDllname(nsIComponentManager* aComponentManager, nsIRegistry* aRegistry,
getter_AddRefs(file));
if (NS_SUCCEEDED(rv)) {
file->GetPath(dllName);
file->GetNativePath(dllName);
}
nsCRT::free(NS_REINTERPRET_CAST(char*, library));
@ -6379,7 +6379,7 @@ nsPluginHostImpl::CreateTmpFileToPost(const char *postDataURL, char **pTmpFileNa
if (NS_FAILED(rv))
return rv;
rv = tempFile->Append(kPluginTmpDirName);
rv = tempFile->AppendNative(kPluginTmpDirName);
if (NS_FAILED(rv))
return rv;
@ -6389,8 +6389,10 @@ nsPluginHostImpl::CreateTmpFileToPost(const char *postDataURL, char **pTmpFileNa
(void) tempFile->Create(nsIFile::DIRECTORY_TYPE, 0600);
nsCAutoString inFileName;
inFile->GetLeafName(inFileName);
rv = tempFile->Append(NS_LITERAL_CSTRING("post-") + inFileName);
inFile->GetNativeLeafName(inFileName);
// XXX hack around bug 70083
inFileName.Insert(NS_LITERAL_CSTRING("post-"), 0);
rv = tempFile->AppendNative(inFileName);
if (NS_FAILED(rv))
return rv;
@ -6481,7 +6483,7 @@ nsPluginHostImpl::ScanForRealInComponentsFolder(nsIComponentManager * aCompManag
return rv;
// make sure the file is actually there
RealPlugin->Append(nsDependentCString("nppl3260.dll"));
RealPlugin->AppendNative(nsDependentCString("nppl3260.dll"));
PRBool exists;
nsCAutoString filePath;
RealPlugin->Exists(&exists);

Просмотреть файл

@ -290,7 +290,7 @@ NS_NewPostDataStream(nsIInputStream **result,
nsCOMPtr<nsILocalFile> file;
nsCOMPtr<nsIInputStream> fileStream;
rv = NS_NewLocalFile(data, PR_FALSE, getter_AddRefs(file));
rv = NS_NewNativeLocalFile(data, PR_FALSE, getter_AddRefs(file));
if (NS_FAILED(rv)) return rv;
rv = NS_NewLocalFileInputStream(getter_AddRefs(fileStream), file);

Просмотреть файл

@ -386,7 +386,12 @@ nsFileIO::GetName(nsACString &aName)
if (mFile == nsnull)
return NS_ERROR_NOT_INITIALIZED;
return mFile->GetPath(aName);
nsAutoString path;
nsresult rv = mFile->GetPath(path);
if (NS_FAILED(rv)) return rv;
aName = NS_ConvertUCS2toUTF8(path);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

16
netwerk/cache/src/nsDiskCacheDevice.cpp поставляемый
Просмотреть файл

@ -178,11 +178,11 @@ NS_IMETHODIMP nsDiskCacheDeviceInfo::GetUsageReport(char ** usageReport)
buffer.Append("<tr><td><b>Cache Directory:</b></td><td><tt> ");
nsCOMPtr<nsILocalFile> cacheDir;
nsCAutoString path;
nsAutoString path;
mDevice->getCacheDirectory(getter_AddRefs(cacheDir));
nsresult rv = cacheDir->GetPath(path);
if (NS_SUCCEEDED(rv)) {
buffer.Append(path);
buffer.Append(NS_ConvertUCS2toUTF8(path));
} else {
buffer.Append("directory unavailable");
}
@ -758,7 +758,7 @@ nsDiskCacheDevice::InitializeCacheDirectory()
}
// create a directory with unique name to contain existing cache directory
rv = cacheTrashDir->Append(NS_LITERAL_CSTRING("Cache"));
rv = cacheTrashDir->AppendNative(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, nsCString());
rv = existingCacheDir->MoveToNative(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(NS_LITERAL_CSTRING("Cache.Trash"));
rv = cacheTrashDir->SetNativeLeafName(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(NS_LITERAL_CSTRING("Cache"));
rv = directory->AppendNative(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(NS_LITERAL_CSTRING("Cache.Trash"));
rv = directory->AppendNative(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(NS_LITERAL_CSTRING("NewCache"));
rv = directory->AppendNative(NS_LITERAL_CSTRING("NewCache"));
if (NS_FAILED(rv)) return;
rv = directory->Exists(&exists);

2
netwerk/cache/src/nsDiskCacheMap.cpp поставляемый
Просмотреть файл

@ -149,7 +149,7 @@ nsDiskCacheMap::Open(nsILocalFile * cacheDirectory)
rv = cacheDirectory->Clone(getter_AddRefs(file));
nsCOMPtr<nsILocalFile> localFile(do_QueryInterface(file, &rv));
if (NS_FAILED(rv)) return rv;
rv = localFile->Append(NS_LITERAL_CSTRING("_CACHE_MAP_"));
rv = localFile->AppendNative(NS_LITERAL_CSTRING("_CACHE_MAP_"));
if (NS_FAILED(rv)) return rv;
// open the file

Просмотреть файл

@ -107,7 +107,7 @@ nsAboutBloat::NewChannel(nsIURI *aURI, nsIChannel **result)
getter_AddRefs(file));
if (NS_FAILED(rv)) return rv;
rv = file->Append(NS_LITERAL_CSTRING("bloatlogs"));
rv = file->AppendNative(NS_LITERAL_CSTRING("bloatlogs"));
if (NS_FAILED(rv)) return rv;
PRBool exists;
@ -132,7 +132,7 @@ nsAboutBloat::NewChannel(nsIURI *aURI, nsIChannel **result)
char time[128];
PR_FormatTimeUSEnglish(time, 128, "%Y-%m-%d-%H%M%S.txt", &expTime);
dumpFileName += time;
rv = file->Append(dumpFileName);
rv = file->AppendNative(dumpFileName);
if (NS_FAILED(rv)) return rv;
FILE* out;

Просмотреть файл

@ -356,8 +356,8 @@ Test(CreateFun create, PRUint32 count,
nsCAutoString inDir;
nsCAutoString outDir;
(void)inDirSpec->GetPath(inDir);
(void)outDirSpec->GetPath(outDir);
(void)inDirSpec->GetNativePath(inDir);
(void)outDirSpec->GetNativePath(outDir);
printf("###########\nTest: from %s to %s, bufSize = %d\n",
inDir.get(), outDir.get(), bufSize);
gTimeSampler.Reset();
@ -387,10 +387,10 @@ Test(CreateFun create, PRUint32 count,
if (NS_FAILED(rv)) goto done;
nsCAutoString leafName;
rv = inSpec->GetLeafName(leafName);
rv = inSpec->GetNativeLeafName(leafName);
if (NS_FAILED(rv)) goto done;
rv = outSpec->Append(leafName);
rv = outSpec->AppendNative(leafName);
if (NS_FAILED(rv)) goto done;
PRBool exists;

Просмотреть файл

@ -161,10 +161,10 @@ public:
rv = NS_NewNativeLocalFile(nsDependentCString(origFile), PR_FALSE, getter_AddRefs(file));
if (NS_FAILED(rv)) return rv;
nsCAutoString name;
rv = file->GetLeafName(name);
rv = file->GetNativeLeafName(name);
if (NS_FAILED(rv)) return rv;
name += NS_LITERAL_CSTRING(".bak");
rv = file->SetLeafName(name);
rv = file->SetNativeLeafName(name);
if (NS_FAILED(rv)) return rv;
rv = NS_NewLocalFileOutputStream(getter_AddRefs(mOut),
file,

Просмотреть файл

@ -615,13 +615,13 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(systemTempDir));
if (NS_FAILED(rv)) return rv;
systemTempDir->Append(NS_LITERAL_CSTRING("migrate"));
systemTempDir->AppendNative(NS_LITERAL_CSTRING("migrate"));
//Create a unique directory in the system temp dir based on the name of the 4.x prefs file
rv = systemTempDir->CreateUnique(nsIFile::DIRECTORY_TYPE, 0700);
if (NS_FAILED(rv)) return rv;
rv = PrefsFile4xAsIFile->CopyTo(systemTempDir, NS_LITERAL_CSTRING(PREF_FILE_NAME_IN_4x));
rv = PrefsFile4xAsIFile->CopyToNative(systemTempDir, NS_LITERAL_CSTRING(PREF_FILE_NAME_IN_4x));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIFile> cloneFile;
@ -631,7 +631,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
m_prefsFile = do_QueryInterface(cloneFile, &rv);
if (NS_FAILED(rv)) return rv;
rv = m_prefsFile->Append(NS_LITERAL_CSTRING(PREF_FILE_NAME_IN_4x));
rv = m_prefsFile->AppendNative(NS_LITERAL_CSTRING(PREF_FILE_NAME_IN_4x));
if (NS_FAILED(rv)) return rv;
//Clear the prefs in case a previous set was read in.
@ -1113,7 +1113,7 @@ nsPrefMigration::ProcessPrefsCallback(const char* oldProfilePathStr, const char
newProfilePath->GetNativePath(getter_Copies(path));
NS_NewNativeLocalFile(path, PR_TRUE, getter_AddRefs(newPrefsFile));
rv = newPrefsFile->Append(NS_LITERAL_CSTRING(PREF_FILE_NAME_IN_5x));
rv = newPrefsFile->AppendNative(NS_LITERAL_CSTRING(PREF_FILE_NAME_IN_5x));
if (NS_FAILED(rv)) return rv;
rv=m_prefs->SavePrefFile(newPrefsFile);
@ -2005,7 +2005,7 @@ nsPrefMigration::DetermineOldPath(nsIFileSpec *profilePath, const char *oldPathN
rv = bundle->GetStringFromName(entityName.get(), getter_Copies(localizedDirName));
if (NS_FAILED(rv)) return rv;
rv = oldLocalFile->AppendRelativePath(NS_ConvertUCS2toUTF8(localizedDirName));
rv = oldLocalFile->AppendRelativePath(localizedDirName);
if (NS_FAILED(rv)) return rv;
PRBool exists = PR_FALSE;

Просмотреть файл

@ -234,13 +234,13 @@ nsresult RecursiveCopy(nsIFile* srcDir, nsIFile* destDir)
{
nsCOMPtr<nsILocalFile> newChild(do_QueryInterface(destClone));
nsCAutoString leafName;
dirEntry->GetLeafName(leafName);
newChild->AppendRelativePath(leafName);
dirEntry->GetNativeLeafName(leafName);
newChild->AppendRelativeNativePath(leafName);
rv = RecursiveCopy(dirEntry, newChild);
}
}
else
rv = dirEntry->CopyTo(destDir, nsCString());
rv = dirEntry->CopyToNative(destDir, nsCString());
}
}
@ -855,7 +855,7 @@ nsProfile::ProcessArgs(nsICmdLineService *cmdLineArgs,
nsAutoString currProfileDirString; currProfileDirString.AssignWithConversion(strtok(NULL, " "));
if (!currProfileDirString.IsEmpty()) {
rv = NS_NewLocalFile(NS_ConvertUCS2toUTF8(currProfileDirString), PR_TRUE, getter_AddRefs(currProfileDir));
rv = NS_NewLocalFile(currProfileDirString, PR_TRUE, getter_AddRefs(currProfileDir));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
}
else {
@ -867,9 +867,9 @@ nsProfile::ProcessArgs(nsICmdLineService *cmdLineArgs,
if (NS_FAILED(rv)) return rv;
}
nsCAutoString currProfilePath;
nsAutoString currProfilePath;
currProfileDir->GetPath(currProfilePath);
rv = CreateNewProfile(currProfileName.get(), NS_ConvertUTF8toUCS2(currProfilePath).get(), nsnull, PR_TRUE);
rv = CreateNewProfile(currProfileName.get(), currProfilePath.get(), nsnull, PR_TRUE);
if (NS_SUCCEEDED(rv)) {
*profileDirSet = PR_TRUE;
mCurrentProfileAvailable = PR_TRUE;
@ -1043,11 +1043,11 @@ NS_IMETHODIMP nsProfile::GetProfilePath(const PRUnichar *profileName, PRUnichar
if (NS_SUCCEEDED(rv))
prettyDir = parentDir;
}
nsCAutoString path;
nsAutoString path;
rv = prettyDir->GetPath(path);
if (NS_FAILED(rv)) return rv;
*_retval = ToNewUnicode(NS_ConvertUTF8toUCS2(path));
*_retval = ToNewUnicode(path);
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
@ -1088,7 +1088,7 @@ NS_IMETHODIMP nsProfile::GetProfileLastModTime(const PRUnichar *profileName, PRI
rv = GetProfileDir(profileName, getter_AddRefs(profileDir));
if (NS_FAILED(rv))
return rv;
rv = profileDir->Append(NS_LITERAL_CSTRING("prefs.js"));
rv = profileDir->AppendNative(NS_LITERAL_CSTRING("prefs.js"));
if (NS_FAILED(rv))
return rv;
return profileDir->GetLastModifiedTime(_retval);
@ -1333,7 +1333,7 @@ nsProfile::AddLevelOfIndirection(nsIFile *aDir)
rv = aDir->Clone(getter_AddRefs(prefFile));
NS_ENSURE_SUCCESS(rv,rv);
rv = prefFile->Append(NS_LITERAL_CSTRING("prefs.js"));
rv = prefFile->AppendNative(NS_LITERAL_CSTRING("prefs.js"));
NS_ENSURE_SUCCESS(rv,rv);
rv = prefFile->Exists(&exists);
@ -1545,16 +1545,16 @@ nsProfile::CreateNewProfileWithLocales(const PRUnichar* profileName,
profileDir->Create(nsIFile::DIRECTORY_TYPE, 0775);
// append profile name
profileDir->Append(NS_ConvertUCS2toUTF8(profileName));
profileDir->Append(nsDependentString(profileName));
}
else {
rv = NS_NewLocalFile(NS_ConvertUCS2toUTF8(nativeProfileDir), PR_TRUE, (nsILocalFile **)((nsIFile **)getter_AddRefs(profileDir)));
rv = NS_NewLocalFile(nsDependentString(nativeProfileDir), PR_TRUE, (nsILocalFile **)((nsIFile **)getter_AddRefs(profileDir)));
// this prevents people from choosing there profile directory
// or another directory, and remove it when they delete the profile.
// append profile name
profileDir->Append(NS_ConvertUCS2toUTF8(profileName));
profileDir->Append(nsDependentString(profileName));
}
@ -1662,7 +1662,7 @@ nsProfile::CreateNewProfileWithLocales(const PRUnichar* profileName,
rv = profDefaultsDir->Clone(getter_AddRefs(locProfDefaultsDir));
if (NS_FAILED(rv)) return rv;
locProfDefaultsDir->Append(NS_ConvertUCS2toUTF8(contentLocale));
locProfDefaultsDir->Append(nsDependentString(contentLocale));
rv = locProfDefaultsDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && exists) {
profDefaultsDir = locProfDefaultsDir; // transfers ownership
@ -2102,7 +2102,7 @@ nsProfile::DefineLocaleDefaultsDir()
nsXPIDLString localeName;
rv = packageRegistry->GetSelectedLocale(NS_LITERAL_STRING("global-region").get(), getter_Copies(localeName));
if (NS_SUCCEEDED(rv))
rv = localeDefaults->Append(NS_ConvertUCS2toUTF8(localeName));
rv = localeDefaults->Append(localeName);
}
(void) directoryService->Undefine(NS_APP_PROFILE_DEFAULTS_50_DIR);
rv = directoryService->Define(NS_APP_PROFILE_DEFAULTS_50_DIR, localeDefaults);
@ -2265,7 +2265,7 @@ nsProfile::MigrateProfile(const PRUnichar* profileName)
if (NS_FAILED(rv))
return rv;
rv = newProfDir->Append(NS_ConvertUCS2toUTF8(profileName));
rv = newProfDir->Append(nsDependentString(profileName));
if (NS_FAILED(rv))
return rv;
@ -2308,7 +2308,7 @@ nsProfile::RemigrateProfile(const PRUnichar* profileName)
// leave <xxxxxxxx>.slt alone,
// and remigrate the 4.x profile into <xxxxxxxx>.slt-new
nsCAutoString newDirLeafName(origDirLeafName + NS_LITERAL_CSTRING("-new"));
rv = newProfileDir->SetLeafName(newDirLeafName);
rv = newProfileDir->SetNativeLeafName(newDirLeafName);
NS_ENSURE_SUCCESS(rv,rv);
// Create a new directory for the remigrated profile
@ -2414,7 +2414,7 @@ NS_IMETHODIMP nsProfile::CloneProfile(const PRUnichar* newProfile)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsILocalFile> destDir(do_QueryInterface(aFile, &rv));
if (NS_FAILED(rv)) return rv;
destDir->AppendRelativePath(NS_ConvertUCS2toUTF8(newProfile));
destDir->AppendRelativePath(nsDependentString(newProfile));
// Find a unique name in the dest dir
rv = destDir->CreateUnique(nsIFile::DIRECTORY_TYPE, 0775);
@ -2452,11 +2452,11 @@ nsProfile::CreateDefaultProfile(void)
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILES_ROOT_DIR, getter_AddRefs(profileRootDir));
if (NS_FAILED(rv)) return rv;
nsCAutoString profilePath;
nsAutoString profilePath;
rv = profileRootDir->GetPath(profilePath);
if (NS_FAILED(rv)) return rv;
rv = CreateNewProfile(DEFAULT_PROFILE_NAME, NS_ConvertUTF8toUCS2(profilePath).get(), nsnull, PR_TRUE);
rv = CreateNewProfile(DEFAULT_PROFILE_NAME, profilePath.get(), nsnull, PR_TRUE);
return rv;
}
@ -2554,7 +2554,7 @@ nsProfile::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
{
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(PREFS_FILE_50_NAME); // AppendRelativePath
rv = localFile->AppendNative(PREFS_FILE_50_NAME); // AppendRelativePath
}
else if (inAtom == sApp_UserProfileDirectory50)
{
@ -2564,7 +2564,7 @@ nsProfile::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
{
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(USER_CHROME_DIR_50_NAME);
rv = localFile->AppendNative(USER_CHROME_DIR_50_NAME);
}
else if (inAtom == sApp_LocalStore50)
{
@ -2574,7 +2574,7 @@ nsProfile::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
{
rv = localFile->Append(LOCAL_STORE_FILE_50_NAME);
rv = localFile->AppendNative(LOCAL_STORE_FILE_50_NAME);
if (NS_SUCCEEDED(rv))
rv = EnsureProfileFileExists(localFile);
}
@ -2583,7 +2583,7 @@ nsProfile::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
{
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(HISTORY_FILE_50_NAME);
rv = localFile->AppendNative(HISTORY_FILE_50_NAME);
}
else if (inAtom == sApp_UsersPanels50)
{
@ -2594,7 +2594,7 @@ nsProfile::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
{
rv = localFile->Append(PANELS_FILE_50_NAME);
rv = localFile->AppendNative(PANELS_FILE_50_NAME);
if (NS_SUCCEEDED(rv))
rv = EnsureProfileFileExists(localFile);
}
@ -2607,7 +2607,7 @@ nsProfile::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
{
rv = localFile->Append(MIME_TYPES_FILE_50_NAME);
rv = localFile->AppendNative(MIME_TYPES_FILE_50_NAME);
if (NS_SUCCEEDED(rv))
rv = EnsureProfileFileExists(localFile);
}
@ -2620,7 +2620,7 @@ nsProfile::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
{
rv = localFile->Append(BOOKMARKS_FILE_50_NAME);
rv = localFile->AppendNative(BOOKMARKS_FILE_50_NAME);
if (NS_SUCCEEDED(rv))
rv = EnsureProfileFileExists(localFile);
}
@ -2629,7 +2629,7 @@ nsProfile::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
{
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(DOWNLOADS_FILE_50_NAME);
rv = localFile->AppendNative(DOWNLOADS_FILE_50_NAME);
}
else if (inAtom == sApp_SearchFile50)
{
@ -2640,7 +2640,7 @@ nsProfile::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
{
rv = localFile->Append(SEARCH_FILE_50_NAME);
rv = localFile->AppendNative(SEARCH_FILE_50_NAME);
if (NS_SUCCEEDED(rv))
rv = EnsureProfileFileExists(localFile);
}
@ -2649,25 +2649,25 @@ nsProfile::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
{
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(MAIL_DIR_50_NAME);
rv = localFile->AppendNative(MAIL_DIR_50_NAME);
}
else if (inAtom == sApp_ImapMailDirectory50)
{
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(IMAP_MAIL_DIR_50_NAME);
rv = localFile->AppendNative(IMAP_MAIL_DIR_50_NAME);
}
else if (inAtom == sApp_NewsDirectory50)
{
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(NEWS_DIR_50_NAME);
rv = localFile->AppendNative(NEWS_DIR_50_NAME);
}
else if (inAtom == sApp_MessengerFolderCache50)
{
rv = CloneProfileDirectorySpec(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(MSG_FOLDER_CACHE_DIR_50_NAME);
rv = localFile->AppendNative(MSG_FOLDER_CACHE_DIR_50_NAME);
}
NS_RELEASE(inAtom);

Просмотреть файл

@ -1371,7 +1371,7 @@ nsresult ProfileStruct::InternalizeLocation(nsIRegistry *aRegistry, nsRegistryKe
#endif
// Now we have a unicode path - make it into a file
rv = NS_NewLocalFile(NS_ConvertUCS2toUTF8(convertedProfLoc), PR_TRUE, getter_AddRefs(tempLocal));
rv = NS_NewLocalFile(convertedProfLoc, PR_TRUE, getter_AddRefs(tempLocal));
}
else
{
@ -1388,13 +1388,13 @@ nsresult ProfileStruct::InternalizeLocation(nsIRegistry *aRegistry, nsRegistryKe
PRInt32 firstColon = regLocationData.FindChar(PRUnichar(':'));
if (firstColon == -1)
{
rv = NS_NewLocalFile(nsCString(), PR_TRUE, getter_AddRefs(tempLocal));
rv = NS_NewNativeLocalFile(nsCString(), PR_TRUE, getter_AddRefs(tempLocal));
if (NS_SUCCEEDED(rv)) // XXX this only works on XP_MAC because regLocationData is ASCII
rv = tempLocal->SetPersistentDescriptor(NS_ConvertUCS2toUTF8(regLocationData));
}
else
#endif
rv = NS_NewLocalFile(NS_ConvertUCS2toUTF8(regLocationData), PR_TRUE, getter_AddRefs(tempLocal));
rv = NS_NewLocalFile(regLocationData, PR_TRUE, getter_AddRefs(tempLocal));
}
if (NS_SUCCEEDED(rv) && tempLocal)
@ -1428,10 +1428,8 @@ nsresult ProfileStruct::ExternalizeLocation(nsIRegistry *aRegistry, nsRegistryKe
resolvedLocation->Remove(PR_FALSE);
regData = NS_ConvertUTF8toUCS2(descBuf);
#else
nsCAutoString utf8Path;
rv = resolvedLocation->GetPath(utf8Path);
rv = resolvedLocation->GetPath(regData);
if (NS_FAILED(rv)) return rv;
regData = NS_ConvertUTF8toUCS2(utf8Path);
#endif
rv = aRegistry->SetString(profKey,
@ -1467,7 +1465,7 @@ nsresult ProfileStruct::InternalizeMigratedFromLocation(nsIRegistry *aRegistry,
if (NS_SUCCEEDED(rv))
{
#ifdef XP_MAC
rv = NS_NewLocalFile(nsCString(), PR_TRUE, getter_AddRefs(tempLocal));
rv = NS_NewLocalFile(nsString(), PR_TRUE, getter_AddRefs(tempLocal));
if (NS_SUCCEEDED(rv))
{
// The persistent desc on Mac is base64 encoded so plain ASCII
@ -1476,7 +1474,7 @@ nsresult ProfileStruct::InternalizeMigratedFromLocation(nsIRegistry *aRegistry,
migratedFrom = tempLocal;
}
#else
rv = NS_NewLocalFile(regData, PR_TRUE, getter_AddRefs(tempLocal));
rv = NS_NewLocalFile(NS_ConvertUTF8toUCS2(regData), PR_TRUE, getter_AddRefs(tempLocal));
if (NS_SUCCEEDED(rv))
migratedFrom = tempLocal;
#endif
@ -1494,7 +1492,9 @@ nsresult ProfileStruct::ExternalizeMigratedFromLocation(nsIRegistry *aRegistry,
#if XP_MAC
rv = migratedFrom->GetPersistentDescriptor(regData);
#else
rv = resolvedLocation->GetPath(regData);
nsAutoString path;
rv = resolvedLocation->GetPath(path);
regData = NS_ConvertUCS2toUTF8(path);
#endif
if (NS_SUCCEEDED(rv))

Просмотреть файл

@ -2603,15 +2603,15 @@ nsChromeRegistry::GetProfileRoot(nsCString& aFileURL)
getter_AddRefs(defaultUserChromeFile));
if (NS_FAILED(rv))
return(rv);
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"));
defaultUserContentFile->AppendNative(NS_LITERAL_CSTRING("chrome"));
defaultUserContentFile->AppendNative(NS_LITERAL_CSTRING("userContent.css"));
defaultUserChromeFile->AppendNative(NS_LITERAL_CSTRING("chrome"));
defaultUserChromeFile->AppendNative(NS_LITERAL_CSTRING("userChrome.css"));
// copy along
// It aint an error if these files dont exist
(void) defaultUserContentFile->CopyTo(userChromeDir, nsCString());
(void) defaultUserChromeFile->CopyTo(userChromeDir, nsCString());
(void) defaultUserContentFile->CopyToNative(userChromeDir, nsCString());
(void) defaultUserChromeFile->CopyToNative(userChromeDir, nsCString());
}
}
if (NS_FAILED(rv))
@ -3043,12 +3043,12 @@ nsChromeRegistry::CheckForNewChrome()
nsCOMPtr<nsIFile> chromeFile;
rv = listFile->Clone(getter_AddRefs(chromeFile));
if (NS_FAILED(rv)) return rv;
rv = chromeFile->Append(kChromeFileName);
rv = chromeFile->AppendNative(kChromeFileName);
if (NS_FAILED(rv)) return rv;
nsInt64 chromeDate;
(void)chromeFile->GetLastModifiedTime(&chromeDate.mValue);
rv = listFile->AppendRelativePath(kInstalledChromeFileName);
rv = listFile->AppendRelativeNativePath(kInstalledChromeFileName);
if (NS_FAILED(rv)) return rv;
nsInt64 listFileDate;
(void)listFile->GetLastModifiedTime(&listFileDate.mValue);

Просмотреть файл

@ -1529,7 +1529,7 @@ FileSystemDataSource::GetName(nsIRDFResource *source, nsIRDFLiteral **aResult)
if (aFileLocal)
aFileLocal->SetFollowLinks(PR_FALSE);
nsCAutoString name;
nsAutoString name;
if (NS_FAILED(rv = aFile->GetLeafName(name)))
return(rv);
if (name.IsEmpty())
@ -1559,7 +1559,7 @@ FileSystemDataSource::GetName(nsIRDFResource *source, nsIRDFLiteral **aResult)
PRInt32 nameLen = name.Length();
if ((strncmp(uri, ieFavoritesDir, strlen(ieFavoritesDir)) == 0) && (nameLen > 4))
{
nsCAutoString extension;
nsAutoString extension;
name.Right(extension, 4);
if (extension.EqualsIgnoreCase(".url") ||
extension.EqualsIgnoreCase(".lnk"))
@ -1593,21 +1593,21 @@ FileSystemDataSource::GetName(nsIRDFResource *source, nsIRDFLiteral **aResult)
0, beNameAttr, sizeof(beNameAttr)-1)) > 0)
{
beNameAttr[len] = '\0';
name = beNameAttr;
name = NS_ConvertUTF8toUCS2(beNameAttr);
rv = NS_OK;
}
}
}
if (NS_OK != rv)
{
name = spec.GetLeafName();
name = NS_ConvertUTF8toUCS2(spec.GetLeafName());
rv = NS_OK;
}
}
}
#endif
gRDFService->GetLiteral(NS_ConvertUTF8toUCS2(name).get(), aResult);
gRDFService->GetLiteral(name.get(), aResult);
return NS_OK;
}

Просмотреть файл

@ -31,7 +31,7 @@
* may use your version of this file under either the MPL or the
* GPL.
*
* $Id: nsPKCS12Blob.cpp,v 1.25 2002/04/27 05:32:35 darin%netscape.com Exp $
* $Id: nsPKCS12Blob.cpp,v 1.26 2002/05/07 23:06:45 darin%netscape.com Exp $
*/
#include "prmem.h"
@ -258,7 +258,7 @@ nsPKCS12Blob::ExportToFile(nsILocalFile *file,
SEC_PKCS12ExportContext *ecx = NULL;
SEC_PKCS12SafeInfo *certSafe = NULL, *keySafe = NULL;
SECItem unicodePw;
nsCAutoString filePath;
nsAutoString filePath;
int i;
nsCOMPtr<nsILocalFile> localFileRef;
NS_ASSERTION(mToken, "Need to set the token before exporting");
@ -360,7 +360,7 @@ nsPKCS12Blob::ExportToFile(nsILocalFile *file,
// We're going to add the .p12 extension to the file name just like
// Communicator used to. We create a new nsILocalFile and initialize
// it with the new patch.
filePath.Append(NS_LITERAL_CSTRING(".p12"));
filePath.Append(NS_LITERAL_STRING(".p12"));
localFileRef = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
if (NS_FAILED(rv)) goto finish;
localFileRef->InitWithPath(filePath);
@ -531,7 +531,7 @@ nsPKCS12Blob::digest_open(void *arg, PRBool reading)
NS_GET_IID(nsILocalFile),
getter_AddRefs(tmpFile));
if (tmpFile) {
tmpFile->Append(PIP_PKCS12_TMPFILENAME);
tmpFile->AppendNative(PIP_PKCS12_TMPFILENAME);
nsCAutoString pathBuf;
tmpFile->GetNativePath(pathBuf);
cx->mTmpFilePath = ToNewCString(pathBuf);

Просмотреть файл

@ -144,7 +144,7 @@ nsresult nsOSHelperAppService::GetFileTokenForPath(const PRUnichar * platformApp
if (localFile)
{
if (localFile)
localFile->InitWithPath(NS_ConvertUCS2toUTF8(platformAppPath));
localFile->InitWithPath(nsDependentString(platformAppPath));
*aFile = localFile;
NS_IF_ADDREF(*aFile);
}

Просмотреть файл

@ -892,7 +892,7 @@ void nsExternalAppHandler::ExtractSuggestedFileNameFromChannel(nsIChannel* aChan
if (iter != start) { // not empty
// ONLY if we got here, will we remember the suggested file name...
// The filename must be ASCII, see RFC 2183, section 2.3
mSuggestedFileName = Substring(start, iter);
CopyASCIItoUCS2(Substring(start, iter), mSuggestedFileName);
#ifndef XP_MAC
// Make sure extension is still correct.
@ -949,7 +949,7 @@ nsresult nsExternalAppHandler::RetargetLoadNotifications(nsIRequest *request)
#define SALT_SIZE 8
#define TABLE_SIZE 36
const char table[] =
const PRUnichar table[] =
{ 'a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t',
'u','v','w','x','y','z','0','1','2','3',
@ -971,13 +971,13 @@ void nsExternalAppHandler::EnsureSuggestedFileName()
if (mTempFileExtension.Length() > 1)
{
// Get mSuggestedFileName's current extension.
nsCAutoString fileExt;
nsAutoString fileExt;
PRInt32 pos = mSuggestedFileName.RFindChar('.');
if (pos != kNotFound)
mSuggestedFileName.Right(fileExt, mSuggestedFileName.Length() - pos);
// Now, compare fileExt to mTempFileExtension.
if (!fileExt.Equals(mTempFileExtension, nsCaseInsensitiveCStringComparator()))
if (!fileExt.Equals(mTempFileExtension, nsCaseInsensitiveStringComparator()))
{
// Doesn't match, so force mSuggestedFileName to have the extension we want.
mSuggestedFileName.Append(mTempFileExtension);
@ -1032,7 +1032,7 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel)
if (!leafName.IsEmpty())
{
NS_UnescapeURL(leafName);
mSuggestedFileName = leafName;
mSuggestedFileName = NS_ConvertUTF8toUCS2(leafName); // XXX leafName may not be UTF-8
#ifndef XP_MAC
// Make sure extension is still correct.
@ -1045,7 +1045,7 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel)
}
// step (2), generate a salted file name for the temp file....
nsCAutoString saltedTempLeafName;
nsAutoString saltedTempLeafName;
// this salting code was ripped directly from the profile manager.
// turn PR_Now() into milliseconds since epoch 1058 // and salt rand with that.
double fpTime;
@ -1194,7 +1194,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo
// to the web progress listener.
typedef enum { kReadError, kWriteError, kLaunchError } ErrorType;
static void SendStatusChange(
ErrorType type, nsresult rv, nsIRequest *aRequest, nsIWebProgressListener *aListener, const nsACString &path)
ErrorType type, nsresult rv, nsIRequest *aRequest, nsIWebProgressListener *aListener, const nsAFlatString &path)
{
nsAutoString msgId;
switch(rv)
@ -1239,8 +1239,7 @@ static void SendStatusChange(
if (NS_SUCCEEDED(s->CreateBundle("chrome://global/locale/nsWebBrowserPersist.properties", getter_AddRefs(bundle))))
{
nsXPIDLString msgText;
NS_ConvertUTF8toUCS2 uscPath(path);
const PRUnichar *strings[] = { uscPath.get() };
const PRUnichar *strings[] = { path.get() };
if(NS_SUCCEEDED(bundle->FormatStringFromName(msgId.get(), strings, 1, getter_Copies(msgText))))
{
aListener->OnStatusChange(nsnull, (type == kReadError) ? aRequest : nsnull, rv, msgText);
@ -1321,7 +1320,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnDataAvailable(nsIRequest *request, nsISupp
// An error occurred, notify listener.
if (mWebProgressListener)
{
nsCAutoString tempFilePath;
nsAutoString tempFilePath;
if (mTempFile)
mTempFile->GetPath(tempFilePath);
SendStatusChange(readError ? kReadError : kWriteError, rv, request, mWebProgressListener, tempFilePath);
@ -1405,8 +1404,8 @@ nsresult nsExternalAppHandler::Init(nsIMIMEInfo * aMIMEInfo, const char * aTempF
// make sure the extention includes the '.'
if (aTempFileExtension && *aTempFileExtension != '.')
mTempFileExtension = ".";
mTempFileExtension.Append(aTempFileExtension);
mTempFileExtension = PRUnichar('.');
mTempFileExtension.AppendWithConversion(aTempFileExtension);
return NS_OK;
}
@ -1428,7 +1427,7 @@ NS_IMETHODIMP nsExternalAppHandler::GetSource(nsIURI ** aSourceURI)
NS_IMETHODIMP nsExternalAppHandler::GetSuggestedFileName(PRUnichar ** aSuggestedFileName)
{
*aSuggestedFileName = ToNewUnicode(NS_ConvertUTF8toUCS2(mSuggestedFileName));
*aSuggestedFileName = ToNewUnicode(mSuggestedFileName);
return NS_OK;
}
@ -1467,10 +1466,7 @@ nsresult nsExternalAppHandler::ShowProgressDialog()
nsCOMPtr<nsILocalFile> file = do_QueryInterface(appl);
if (file)
{
nsCAutoString leafName;
file->GetLeafName(leafName);
if (!leafName.IsEmpty())
openWith = NS_ConvertUTF8toUCS2(leafName);
file->GetLeafName(openWith);
}
}
}
@ -1487,7 +1483,7 @@ nsresult nsExternalAppHandler::ShowProgressDialog()
return rv;
}
nsresult nsExternalAppHandler::PromptForSaveToFile(nsILocalFile ** aNewFile, const nsACString &aDefaultFile, const nsACString &aFileExtension)
nsresult nsExternalAppHandler::PromptForSaveToFile(nsILocalFile ** aNewFile, const nsAFlatString &aDefaultFile, const nsAFlatString &aFileExtension)
{
// invoke the dialog!!!!! use mWindowContext as the window context parameter for the dialog request
// XXX Convert to use file picker?
@ -1503,8 +1499,8 @@ nsresult nsExternalAppHandler::PromptForSaveToFile(nsILocalFile ** aNewFile, con
// it because the dialog is implemented by a JS component which doesn't have a window so no unescape routine is defined...
rv = mDialog->PromptForSaveToFile(mWindowContext,
NS_ConvertUTF8toUCS2(aDefaultFile).get(),
NS_ConvertUTF8toUCS2(aFileExtension).get(),
aDefaultFile.get(),
aFileExtension.get(),
aNewFile);
return rv;
}
@ -1532,17 +1528,17 @@ nsresult nsExternalAppHandler::MoveFile(nsIFile * aNewFileLocation)
// extract the new leaf name from the file location
nsCAutoString fileName;
fileToUse->GetLeafName(fileName);
fileToUse->GetNativeLeafName(fileName);
nsCOMPtr<nsIFile> directoryLocation;
fileToUse->GetParent(getter_AddRefs(directoryLocation));
if (directoryLocation)
{
rv = mTempFile->MoveTo(directoryLocation, fileName);
rv = mTempFile->MoveToNative(directoryLocation, fileName);
}
if (NS_FAILED(rv) && mWebProgressListener)
{
// Send error notification.
nsCAutoString path;
nsAutoString path;
fileToUse->GetPath(path);
SendStatusChange(kWriteError, rv, nsnull, mWebProgressListener, path);
}
@ -1569,14 +1565,14 @@ NS_IMETHODIMP nsExternalAppHandler::SaveToDisk(nsIFile * aNewFileLocation, PRBoo
if (!aNewFileLocation)
{
nsCAutoString leafName;
nsAutoString leafName;
nsCOMPtr<nsILocalFile> fileToUse;
mTempFile->GetLeafName(leafName);
if (mSuggestedFileName.IsEmpty())
rv = PromptForSaveToFile(getter_AddRefs(fileToUse), leafName, mTempFileExtension);
else
{
nsCAutoString fileExt;
nsAutoString fileExt;
PRInt32 pos = mSuggestedFileName.RFindChar('.');
if (pos >= 0)
mSuggestedFileName.Right(fileExt, mSuggestedFileName.Length() - pos);
@ -1625,7 +1621,7 @@ nsresult nsExternalAppHandler::OpenWithApplication(nsIFile * aApplication)
if (NS_FAILED(rv) && mWebProgressListener)
{
// Send error notification.
nsCAutoString path;
nsAutoString path;
mFinalFileDestination->GetPath(path);
SendStatusChange(kLaunchError, rv, nsnull, mWebProgressListener, path);
}
@ -1964,7 +1960,7 @@ NS_IMETHODIMP nsExternalHelperAppService::GetTypeFromFile( nsIFile* aFile, char
// Get the Extension
nsCAutoString fileName;
const char* ext = nsnull;
rv = aFile->GetLeafName(fileName);
rv = aFile->GetNativeLeafName(fileName);
if (NS_FAILED(rv)) return rv;
if (!fileName.IsEmpty())

Просмотреть файл

@ -169,13 +169,13 @@ public:
protected:
nsCOMPtr<nsIFile> mTempFile;
nsCOMPtr<nsIURI> mSourceUrl;
nsCString mTempFileExtension; // UTF-8
nsString mTempFileExtension;
nsCOMPtr<nsIMIMEInfo> mMimeInfo;
nsCOMPtr<nsIOutputStream> mOutStream; // output stream to the temp file...
nsCOMPtr<nsISupports> mWindowContext;
// the following field is set if we were processing an http channel that had a content disposition header
// which specified the SUGGESTED file name we should present to the user in the save to disk dialog.
nsCString mSuggestedFileName; // UTF-8
nsString mSuggestedFileName;
// the canceled flag is set if the user canceled the launching of this application before we finished
// saving the data to a temp file...
@ -204,7 +204,7 @@ protected:
// if the user tells us how they want to dispose of the content and we still haven't finished downloading while
// they were deciding, then throw a progress dialog so they know what's going on...
nsresult ShowProgressDialog();
nsresult PromptForSaveToFile(nsILocalFile ** aNewFile, const nsACString &aDefaultFile, const nsACString &aDefaultFileExt);
nsresult PromptForSaveToFile(nsILocalFile ** aNewFile, const nsAFlatString &aDefaultFile, const nsAFlatString &aDefaultFileExt);
// if the passed in channel is an nsIHTTPChannel, we'll attempt to extract a suggested file name
// from the content disposition header...
void ExtractSuggestedFileNameFromChannel(nsIChannel * aChannel);

Просмотреть файл

@ -227,7 +227,7 @@ nsresult nsOSHelperAppService::GetFileTokenForPath(const PRUnichar * platformApp
if (localFile)
{
if (localFile)
localFile->InitWithPath(NS_ConvertUCS2toUTF8(platformAppPath));
localFile->InitWithPath(nsDependentString(platformAppPath));
*aFile = localFile;
NS_IF_ADDREF(*aFile);
}

Просмотреть файл

@ -328,7 +328,7 @@ CreateInputStream(const nsAString& aFilename,
nsCOMPtr<nsILocalFile> file(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
rv = file->InitWithPath(NS_ConvertUCS2toUTF8(aFilename));
rv = file->InitWithPath(aFilename);
if (NS_FAILED(rv))
return rv;
@ -896,7 +896,7 @@ GetHandlerAndDescriptionFromMailcapFile(const nsAString& aFilename,
nsCOMPtr<nsILocalFile> file(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;
rv = file->InitWithPath(NS_ConvertUCS2toUTF8(aFilename));
rv = file->InitWithPath(aFilename);
if (NS_FAILED(rv))
return rv;
@ -1094,7 +1094,7 @@ nsresult nsOSHelperAppService::GetFileTokenForPath(const PRUnichar * platformApp
// first check if this is a full path
PRBool exists = PR_FALSE;
if (*platformAppPath == '/') {
localFile->InitWithPath(NS_ConvertUCS2toUTF8(platformAppPath));
localFile->InitWithPath(nsDependentString(platformAppPath));
localFile->Exists(&exists);
} else {
@ -1111,8 +1111,10 @@ nsresult nsOSHelperAppService::GetFileTokenForPath(const PRUnichar * platformApp
while (colon_iter != end_iter && *colon_iter != ':') {
++colon_iter;
}
// XXX provided the string code has all it's bugs fixed, we should be able to
// remove this PromiseFlatCString call.
localFile->InitWithNativePath(PromiseFlatCString(Substring(start_iter, colon_iter)));
rv = localFile->AppendRelativePath(NS_ConvertUCS2toUTF8(platformAppPath));
rv = localFile->AppendRelativePath(nsDependentString(platformAppPath));
if (NS_SUCCEEDED(rv)) {
localFile->Exists(&exists);
if (!exists) {

Просмотреть файл

@ -236,7 +236,7 @@ nsresult nsOSHelperAppService::GetFileTokenForPath(const PRUnichar * platformApp
if (localFile)
{
if (localFile)
localFile->InitWithPath(NS_ConvertUCS2toUTF8(platformAppPath));
localFile->InitWithPath(nsDependentString(platformAppPath));
*aFile = localFile;
NS_IF_ADDREF(*aFile);
}

Просмотреть файл

@ -5033,11 +5033,8 @@ NS_METHOD nsWindow::SetIcon(const nsAString& anIconSpec)
return NS_ERROR_FAILURE;
}
// Get native file name of that directory.
nsCAutoString rootPath;
chromeDir->GetPath( rootPath );
// Start there.
NS_ConvertUTF8toUCS2 iconPath( rootPath );
nsAutoString iconPath;
chromeDir->GetPath( iconPath );
// Now take input path...
nsAutoString iconSpec( anIconSpec );
@ -5072,7 +5069,7 @@ NS_METHOD nsWindow::SetIcon(const nsAString& anIconSpec)
// See if unicode API not implemented and if not, try ascii version
if ( ::GetLastError() == ERROR_CALL_NOT_IMPLEMENTED ) {
nsCOMPtr<nsILocalFile> pathConverter;
if ( NS_SUCCEEDED( NS_NewLocalFile( NS_ConvertUCS2toUTF8(iconPath),
if ( NS_SUCCEEDED( NS_NewLocalFile( iconPath,
PR_FALSE,
getter_AddRefs( pathConverter ) ) ) ) {
// Now try the char* path.

Просмотреть файл

@ -370,7 +370,7 @@ nsresult NS_COM NS_InitXPCOM2(nsIServiceManager* *result,
//Since people are still using the nsSpecialSystemDirectory, we should init it.
nsCAutoString path;
binDirectory->GetPath(path);
binDirectory->GetNativePath(path);
nsFileSpec spec(path.get());
nsSpecialSystemDirectory::Set(nsSpecialSystemDirectory::Moz_BinDirectory, &spec);

Просмотреть файл

@ -858,9 +858,7 @@ nsNativeComponentLoader::AutoRegisterComponent(PRInt32 when,
nsCOMPtr<nsIFile> dllSpec;
if (NS_SUCCEEDED(dll->GetDllSpec(getter_AddRefs(dllSpec))) && dllSpec)
{
nsCAutoString dllLeafName;
dllSpec->GetLeafName(dllLeafName); // XXX
fileName.Assign(NS_ConvertUTF8toUCS2(dllLeafName));
dllSpec->GetLeafName(fileName);
}
// this string can't come from a string bundle, because we

Просмотреть файл

@ -138,21 +138,21 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile
{
rv = GetProductDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->Append(APP_REGISTRY_NAME);
rv = localFile->AppendNative(APP_REGISTRY_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_DEFAULTS_50_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_PREF_DEFAULTS_50_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(DEFAULTS_PREF_DIR_NAME);
rv = localFile->AppendRelativeNativePath(DEFAULTS_PREF_DIR_NAME);
}
}
else if (nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_50_DIR) == 0 ||
@ -160,9 +160,9 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv)) {
rv = localFile->AppendRelativePath(DEFAULTS_DIR_NAME);
rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME);
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(DEFAULTS_PROFILE_DIR_NAME);
rv = localFile->AppendRelativeNativePath(DEFAULTS_PROFILE_DIR_NAME);
}
}
else if (nsCRT::strcmp(prop, NS_APP_USER_PROFILES_ROOT_DIR) == 0)
@ -173,19 +173,19 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(RES_DIR_NAME);
rv = localFile->AppendRelativeNativePath(RES_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_CHROME_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(CHROME_DIR_NAME);
rv = localFile->AppendRelativeNativePath(CHROME_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(PLUGINS_DIR_NAME);
rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_ENV_PLUGINS_DIR) == 0)
{
@ -197,13 +197,13 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile
{
rv = GetProductDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(PLUGINS_DIR_NAME);
rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_SEARCH_DIR) == 0)
{
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
if (NS_SUCCEEDED(rv))
rv = localFile->AppendRelativePath(SEARCH_DIR_NAME);
rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME);
}
else if (nsCRT::strcmp(prop, NS_APP_INSTALL_CLEANUP_DIR) == 0)
{
@ -212,7 +212,7 @@ nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistant, nsIFile
rv = CloneMozBinDirectory(getter_AddRefs(localFile));
#ifdef XP_MAC
if (NS_SUCCEEDED(rv))
rv = localFile->Append(ESSENTIAL_FILES);
rv = localFile->AppendNative(ESSENTIAL_FILES);
#endif
}
@ -325,7 +325,7 @@ NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsILocalFile **aLocalFi
#error dont_know_how_to_get_product_dir_on_your_platform
#endif
rv = localDir->AppendRelativePath(DEFAULT_PRODUCT_DIR);
rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR);
if (NS_FAILED(rv)) return rv;
rv = localDir->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)
@ -358,7 +358,7 @@ NS_METHOD nsAppFileLocationProvider::GetDefaultUserProfileRoot(nsILocalFile **aL
#if defined(XP_MAC) || defined(XP_MACOSX) || defined(XP_OS2) || defined(XP_PC)
// These 3 platforms share this part of the path - do them as one
rv = localDir->AppendRelativePath(NS_LITERAL_CSTRING("Profiles"));
rv = localDir->AppendRelativeNativePath(NS_LITERAL_CSTRING("Profiles"));
if (NS_FAILED(rv)) return rv;
PRBool exists;

Просмотреть файл

@ -804,13 +804,13 @@ nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_ret
{
rv = GetCurrentProcessDirectory(getter_AddRefs(localFile));
if (localFile)
localFile->Append(COMPONENT_REGISTRY_NAME);
localFile->AppendNative(COMPONENT_REGISTRY_NAME);
}
else if (inAtom == nsDirectoryService::sComponentDirectory)
{
rv = GetCurrentProcessDirectory(getter_AddRefs(localFile));
if (localFile)
localFile->Append(COMPONENT_DIRECTORY);
localFile->AppendNative(COMPONENT_DIRECTORY);
}
else if (inAtom == nsDirectoryService::sOS_DriveDirectory)
{

Просмотреть файл

@ -755,7 +755,7 @@ nsFastLoadFileReader::ReadFooter(nsFastLoadFooter *aFooter)
return rv;
nsCOMPtr<nsILocalFile> file;
rv = NS_NewLocalFile(filename, PR_TRUE, getter_AddRefs(file));
rv = NS_NewNativeLocalFile(filename, PR_TRUE, getter_AddRefs(file));
if (NS_FAILED(rv))
return rv;
@ -767,7 +767,7 @@ nsFastLoadFileReader::ReadFooter(nsFastLoadFooter *aFooter)
if (LL_NE(fastLoadMtime, currentMtime)) {
#ifdef DEBUG
nsCAutoString path;
file->GetPath(path);
file->GetNativePath(path);
printf("%s mtime changed, invalidating FastLoad file\n",
path.get());
#endif
@ -1524,7 +1524,7 @@ NS_IMETHODIMP
nsFastLoadFileWriter::AddDependency(nsIFile* aFile)
{
nsCAutoString path;
nsresult rv = aFile->GetPath(path);
nsresult rv = aFile->GetNativePath(path);
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -147,7 +147,7 @@ nsFastLoadService::NewFastLoadFile(const char* aBaseName, nsIFile* *aResult)
nsCAutoString name(aBaseName);
MASSAGE_BASENAME(name);
name += PLATFORM_FASL_SUFFIX;
rv = file->Append(name);
rv = file->AppendNative(name);
if (NS_FAILED(rv))
return rv;
@ -357,7 +357,7 @@ nsFastLoadService::ComputeChecksum(nsIFile* aFile,
PRUint32 *aChecksum)
{
nsCAutoString path;
nsresult rv = aFile->GetPath(path);
nsresult rv = aFile->GetNativePath(path);
if (NS_FAILED(rv))
return rv;
@ -390,7 +390,7 @@ nsFastLoadService::CacheChecksum(nsIFile* aFile, nsIObjectOutputStream *aStream)
return rv;
nsCAutoString path;
rv = aFile->GetPath(path);
rv = aFile->GetNativePath(path);
if (NS_FAILED(rv))
return rv;

Просмотреть файл

@ -34,19 +34,13 @@ interface nsISimpleEnumerator;
* may think they are. Welcome to reality.
*
* All methods with string parameters have two forms. The preferred
* form operates on UTF-8 encoded characters strings. An alternate
* form operates on UCS-2 encoded characters strings. An alternate
* form operates on characters strings encoded in the "native" charset.
* On platforms that use UTF-8 as the native charset, there is no
* difference between the two set of methods. See, for example: Append
* and AppendNative.
*
* A string containing characters encoded in the native charset cannot
* be safely passed to javascript via xpconnect. Therefore, the "native
* methods" are not scriptable.
*
* The abstract string types, AUTF8String and ACString are used to signify
* UTF-8 encoded strings and native encoded strings, respectively.
*
* @status UNDER_REVIEW
*/
[scriptable, uuid(c8c0a080-0868-11d3-915f-d9d889d48e3c)]
@ -70,7 +64,7 @@ interface nsIFile : nsISupports
* @param node
* A string which is intended to be a child node of the nsIFile.
*/
void append(in AUTF8String node);
void append(in AString node);
[noscript] void appendNative(in ACString node);
/**
@ -103,7 +97,7 @@ interface nsIFile : nsISupports
/**
* Accessor to the leaf name of the file itself.
*/
attribute AUTF8String leafName;
attribute AString leafName;
[noscript] attribute ACString nativeLeafName;
/**
@ -131,7 +125,7 @@ interface nsIFile : nsISupports
* the file to be copied. This param may be empty, in
* which case the current leaf name will be used.
*/
void copyTo(in nsIFile newParentDir, in AUTF8String newName);
void copyTo(in nsIFile newParentDir, in AString newName);
[noscrpit] void CopyToNative(in nsIFile newParentDir, in ACString newName);
/**
@ -141,7 +135,7 @@ interface nsIFile : nsISupports
* as the name implies, it follows symbolic links. The XP_UNIX
* implementation always follow symbolic links when copying.
*/
void copyToFollowingLinks(in nsIFile newParentDir, in AUTF8String newName);
void copyToFollowingLinks(in nsIFile newParentDir, in AString newName);
[noscript] void copyToFollowingLinksNative(in nsIFile newParentDir, in ACString newName);
/**
@ -168,7 +162,7 @@ interface nsIFile : nsISupports
* the file to be moved. This param may be empty, in
* which case the current leaf name will be used.
*/
void moveTo(in nsIFile newParentDir, in AUTF8String newName);
void moveTo(in nsIFile newParentDir, in AString newName);
[noscript] void moveToNative(in nsIFile newParentDir, in ACString newName);
/**
@ -224,9 +218,9 @@ interface nsIFile : nsISupports
* path
* Find out what the nsIFile points at.
*/
readonly attribute AUTF8String target;
readonly attribute AString target;
[noscript] readonly attribute ACString nativeTarget;
readonly attribute AUTF8String path;
readonly attribute AString path;
[noscript] readonly attribute ACString nativePath;
boolean exists();

Просмотреть файл

@ -63,7 +63,7 @@ interface nsILocalFile : nsIFile
* error (NS_ERROR_FILE_UNRECOGNIZED_PATH). This
* path must in native.
*/
void initWithPath(in AUTF8String filePath);
void initWithPath(in AString filePath);
[noscript] void initWithNativePath(in ACString filePath);
/**
@ -110,15 +110,15 @@ interface nsILocalFile : nsIFile
* this cannot contain .. or cannot start with a directory separator
* XXXbe Why not? Bogus!
*/
void appendRelativePath(in AUTF8String relativeFilePath);
void appendRelativePath(in AString relativeFilePath);
[noscript] void appendRelativeNativePath(in ACString relativeFilePath);
/**
* Accessor to a null terminated string which will specify
* the file in a persistent manner for disk storage.
*
* The character set of this attribute is undefined. Do not try to
* interpret it as human readable text.
* The character set of this attribute is undefined. DO NOT TRY TO
* INTERPRET IT AS HUMAN READABLE TEXT!
*/
attribute ACString persistentDescriptor;
@ -143,13 +143,16 @@ interface nsILocalFile : nsIFile
/**
* getRelativeDescriptor
*
* Returns a UTF-8 encoded relative file path in an XP format.
* It is therefore not a native path.
* Returns a relative file path in an opaque, XP format. It is therefore
* not a native path.
*
* The character set of the string returned from this function is
* undefined. DO NOT TRY TO INTERPRET IT AS HUMAN READABLE TEXT!
*
* @param fromFile
* the file from which the descriptor is relative
*/
AUTF8String getRelativeDescriptor(in nsILocalFile fromFile);
ACString getRelativeDescriptor(in nsILocalFile fromFile);
/**
* setRelativeDescriptor
@ -160,7 +163,7 @@ interface nsILocalFile : nsIFile
* @param fromFile
* the file to which the descriptor is relative
*/
void setRelativeDescriptor(in nsILocalFile fromFile, in AUTF8String relativeDesc);
void setRelativeDescriptor(in nsILocalFile fromFile, in ACString relativeDesc);
};
%{C++
@ -168,7 +171,7 @@ interface nsILocalFile : nsIFile
#define NS_LOCAL_FILE_CLASSNAME "Local File Specification"
extern "C" NS_EXPORT nsresult
NS_NewLocalFile(const nsACString &path, PRBool followLinks, nsILocalFile* *result);
NS_NewLocalFile(const nsAString &path, PRBool followLinks, nsILocalFile* *result);
extern "C" NS_EXPORT nsresult
NS_NewNativeLocalFile(const nsACString &path, PRBool followLinks, nsILocalFile* *result);
%}

Просмотреть файл

@ -62,10 +62,10 @@ nsLocalFile::InitWithFile(nsILocalFile *aFile)
NS_ENSURE_ARG(aFile);
nsCAutoString path;
aFile->GetPath(path);
aFile->GetNativePath(path);
if (path.IsEmpty())
return NS_ERROR_FAILURE;
return InitWithPath(path);
return InitWithNativePath(path);
}
#endif
@ -120,11 +120,11 @@ nsLocalFile::CreateUnique(PRUint32 type, PRUint32 attributes)
}
#if defined(XP_MAC)
static const char kPathSeparatorChar = ':';
static const PRUnichar kPathSeparatorChar = ':';
#elif defined(XP_WIN) || defined(XP_OS2)
static const char kPathSeparatorChar = '\\';
static const PRUnichar kPathSeparatorChar = '\\';
#elif defined(XP_UNIX) || defined(XP_BEOS)
static const char kPathSeparatorChar = '/';
static const PRUnichar kPathSeparatorChar = '/';
#else
#error Need to define file path separator for your platform
#endif
@ -134,17 +134,17 @@ static const char kSlashStr[] = "/";
static const char kESCSlashStr[] = "%2F";
#endif
static PRInt32 SplitPath(char *path, char **nodeArray, PRInt32 arrayLen)
static PRInt32 SplitPath(PRUnichar *path, PRUnichar **nodeArray, PRInt32 arrayLen)
{
if (*path == 0)
return 0;
char **nodePtr = nodeArray;
PRUnichar **nodePtr = nodeArray;
if (*path == kPathSeparatorChar)
path++;
*nodePtr++ = path;
for (char *cp = path; *cp != 0; cp++) {
for (PRUnichar *cp = path; *cp != 0; cp++) {
if (*cp == kPathSeparatorChar) {
*cp++ = 0;
if (*cp != 0) {
@ -162,12 +162,16 @@ NS_IMETHODIMP
nsLocalFile::GetRelativeDescriptor(nsILocalFile *fromFile, nsACString& _retval)
{
const PRInt32 kMaxNodesInPath = 32;
//
// _retval will be UTF-8 encoded
//
nsresult rv;
_retval.Truncate(0);
nsCAutoString thisPath, fromPath;
char *thisNodes[kMaxNodesInPath], *fromNodes[kMaxNodesInPath];
nsAutoString thisPath, fromPath;
PRUnichar *thisNodes[kMaxNodesInPath], *fromNodes[kMaxNodesInPath];
PRInt32 thisNodeCnt, fromNodeCnt, nodeIndex;
rv = GetPath(thisPath);
@ -177,13 +181,13 @@ nsLocalFile::GetRelativeDescriptor(nsILocalFile *fromFile, nsACString& _retval)
if (NS_FAILED(rv))
return rv;
thisNodeCnt = SplitPath((char *)thisPath.get(), thisNodes, kMaxNodesInPath);
fromNodeCnt = SplitPath((char *)fromPath.get(), fromNodes, kMaxNodesInPath);
thisNodeCnt = SplitPath((PRUnichar *)thisPath.get(), thisNodes, kMaxNodesInPath);
fromNodeCnt = SplitPath((PRUnichar *)fromPath.get(), fromNodes, kMaxNodesInPath);
if (thisNodeCnt < 0 || fromNodeCnt < 0)
return NS_ERROR_FAILURE;
for (nodeIndex = 0; nodeIndex < thisNodeCnt && nodeIndex < fromNodeCnt; nodeIndex++) {
if (!strcmp(thisNodes[nodeIndex], fromNodes[nodeIndex]))
if (!nsCRT::strcmp(thisNodes[nodeIndex], fromNodes[nodeIndex]))
break;
}
@ -191,11 +195,9 @@ nsLocalFile::GetRelativeDescriptor(nsILocalFile *fromFile, nsACString& _retval)
for (nodeIndex = branchIndex; nodeIndex < fromNodeCnt; nodeIndex++)
_retval.Append(NS_LITERAL_CSTRING("../"));
for (nodeIndex = branchIndex; nodeIndex < thisNodeCnt; nodeIndex++) {
NS_ConvertUCS2toUTF8 nodeStr(thisNodes[nodeIndex]);
#ifdef XP_MAC
nsCAutoString nodeStr(thisNodes[nodeIndex]);
nodeStr.ReplaceSubstring(kSlashStr, kESCSlashStr);
#else
nsDependentCString nodeStr(thisNodes[nodeIndex]);
#endif
_retval.Append(nodeStr);
if (nodeIndex + 1 < thisNodeCnt)
@ -215,6 +217,10 @@ nsLocalFile::SetRelativeDescriptor(nsILocalFile *fromFile, const nsACString& rel
if (NS_FAILED(rv))
return rv;
//
// relativeDesc is UTF-8 encoded
//
nsCString::const_iterator strBegin, strEnd;
relativeDesc.BeginReading(strBegin);
relativeDesc.EndReading(strEnd);
@ -240,9 +246,9 @@ nsLocalFile::SetRelativeDescriptor(nsILocalFile *fromFile, const nsACString& rel
#ifdef XP_MAC
nsCAutoString nodeString(Substring(nodeBegin, nodeEnd));
nodeString.ReplaceSubstring(kESCSlashStr, kSlashStr);
targetFile->Append(nodeString);
targetFile->Append(NS_ConvertUTF8toUCS2(nodeString));
#else
targetFile->Append(Substring(nodeBegin, nodeEnd));
targetFile->Append(NS_ConvertUTF8toUCS2(Substring(nodeBegin, nodeEnd)));
#endif
if (nodeEnd != strEnd) // If there's more left in the string, inc over the '/' nodeEnd is on.
++nodeEnd;
@ -252,116 +258,3 @@ nsLocalFile::SetRelativeDescriptor(nsILocalFile *fromFile, const nsACString& rel
nsCOMPtr<nsILocalFile> targetLocalFile(do_QueryInterface(targetFile));
return InitWithFile(targetLocalFile);
}
#define GET_UTF8(func, result) \
PR_BEGIN_MACRO \
PRUnichar *buf = nsnull; \
nsresult rv = (func)(&buf); \
if (NS_FAILED(rv)) return rv; \
result = NS_ConvertUCS2toUTF8(buf); \
nsMemory::Free(buf); \
PR_END_MACRO
NS_IMETHODIMP
nsLocalFile::Append(const nsACString &aNode)
{
if (aNode.IsEmpty() || FSCharsetIsUTF8() || IsASCII(aNode))
return AppendNative(aNode);
return AppendUnicode(NS_ConvertUTF8toUCS2(aNode).get());
}
NS_IMETHODIMP
nsLocalFile::GetLeafName(nsACString &aLeafName)
{
if (FSCharsetIsUTF8() || LeafIsASCII())
return GetNativeLeafName(aLeafName);
GET_UTF8(GetUnicodeLeafName, aLeafName);
return NS_OK;
}
NS_IMETHODIMP
nsLocalFile::SetLeafName(const nsACString &aLeafName)
{
if (aLeafName.IsEmpty() || FSCharsetIsUTF8() || IsASCII(aLeafName))
return SetNativeLeafName(aLeafName);
return SetUnicodeLeafName(NS_ConvertUTF8toUCS2(aLeafName).get());
}
NS_IMETHODIMP
nsLocalFile::CopyTo(nsIFile *aNewParentDir, const nsACString &aNewName)
{
if (aNewName.IsEmpty() || FSCharsetIsUTF8() || IsASCII(aNewName))
return CopyToNative(aNewParentDir, aNewName);
return CopyToUnicode(aNewParentDir, NS_ConvertUTF8toUCS2(aNewName).get());
}
NS_IMETHODIMP
nsLocalFile::CopyToFollowingLinks(nsIFile *aNewParentDir, const nsACString &aNewName)
{
if (aNewName.IsEmpty() || FSCharsetIsUTF8() || IsASCII(aNewName))
return CopyToFollowingLinksNative(aNewParentDir, aNewName);
return CopyToFollowingLinksUnicode(aNewParentDir, NS_ConvertUTF8toUCS2(aNewName).get());
}
NS_IMETHODIMP
nsLocalFile::MoveTo(nsIFile *aNewParentDir, const nsACString &aNewName)
{
if (aNewName.IsEmpty() || FSCharsetIsUTF8() || IsASCII(aNewName))
return MoveToNative(aNewParentDir, aNewName);
return MoveToUnicode(aNewParentDir, NS_ConvertUTF8toUCS2(aNewName).get());
}
NS_IMETHODIMP
nsLocalFile::GetTarget(nsACString &aTarget)
{
if (FSCharsetIsUTF8())
return GetNativeTarget(aTarget);
// XXX unfortunately, there is no way to know if the target will contain
// non-ASCII characters until after we resolve it.
GET_UTF8(GetUnicodeTarget, aTarget);
return NS_OK;
}
NS_IMETHODIMP
nsLocalFile::GetPath(nsACString &aPath)
{
if (FSCharsetIsUTF8() || PathIsASCII())
return GetNativePath(aPath);
GET_UTF8(GetUnicodePath, aPath);
return NS_OK;
}
NS_IMETHODIMP
nsLocalFile::InitWithPath(const nsACString &aPath)
{
if (aPath.IsEmpty() || FSCharsetIsUTF8() || IsASCII(aPath))
return InitWithNativePath(aPath);
return InitWithUnicodePath(NS_ConvertUTF8toUCS2(aPath).get());
}
NS_IMETHODIMP
nsLocalFile::AppendRelativePath(const nsACString &aRelativePath)
{
if (aRelativePath.IsEmpty() || FSCharsetIsUTF8() || IsASCII(aRelativePath))
return AppendRelativeNativePath(aRelativePath);
return AppendRelativeUnicodePath(NS_ConvertUTF8toUCS2(aRelativePath).get());
}
nsresult
NS_NewLocalFile(const nsACString &aPath, PRBool aFollowLinks, nsILocalFile **aResult)
{
if (aPath.IsEmpty() || nsLocalFile::FSCharsetIsUTF8() || IsASCII(aPath))
return NS_NewNativeLocalFile(aPath, aFollowLinks, aResult);
return NS_NewUnicodeLocalFile(NS_ConvertUTF8toUCS2(aPath).get(), aFollowLinks, aResult);
}

Просмотреть файл

@ -29,7 +29,6 @@
#include "nsXPIDLString.h"
#include "nsLocalFileMac.h"
#include "nsLocalFileUnicode.h"
#include "nsISimpleEnumerator.h"
#include "nsIComponentManager.h"
#include "nsIInternetConfigService.h"
@ -1318,12 +1317,12 @@ nsLocalFile::InitWithNativePath(const nsACString &filePath)
}
NS_IMETHODIMP
nsLocalFile::InitWithUnicodePath(const PRUnichar *filePath)
nsLocalFile::InitWithPath(const nsAString &filePath)
{
nsresult rv;
nsCAutoString fsStr;
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(nsDependentString(filePath), fsStr)))
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(filePath, fsStr)))
rv = InitWithNativePath(fsStr);
return rv;
@ -1546,12 +1545,12 @@ nsLocalFile::AppendNative(const nsACString &aNode)
}
NS_IMETHODIMP
nsLocalFile::AppendUnicode(const PRUnichar *node)
nsLocalFile::Append(const nsAString &node)
{
nsresult rv;
nsCAutoString fsStr;
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(nsDependentString(node), fsStr)))
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(node, fsStr)))
rv = AppendNative(fsStr);
return rv;
@ -1578,12 +1577,12 @@ nsLocalFile::AppendRelativeNativePath(const nsACString &relPath)
}
NS_IMETHODIMP
nsLocalFile::AppendRelativeUnicodePath(const PRUnichar *relPath)
nsLocalFile::AppendRelativePath(const nsAString &relPath)
{
nsresult rv;
nsCAutoString fsStr;
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(nsDependentString(relPath), fsStr)))
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(relPath, fsStr)))
rv = AppendRelativeNativePath(fsStr);
return rv;
@ -1628,18 +1627,13 @@ nsLocalFile::GetNativeLeafName(nsACString &aLeafName)
}
NS_IMETHODIMP
nsLocalFile::GetUnicodeLeafName(PRUnichar **aLeafName)
nsLocalFile::GetLeafName(nsAString &aLeafName)
{
nsresult rv;
nsCAutoString fsStr;
if (NS_SUCCEEDED(rv = GetNativeLeafName(fsStr))) {
nsAutoString ucStr;
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::FSToUCS(fsStr, ucStr))) {
if ((*aLeafName = ToNewUnicode(ucStr)) == nsnull)
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
if (NS_SUCCEEDED(rv = GetNativeLeafName(fsStr)))
rv = nsFSStringConversionMac::FSToUCS(fsStr, aLeafName);
return rv;
}
@ -1673,12 +1667,12 @@ nsLocalFile::SetNativeLeafName(const nsACString &aLeafName)
}
NS_IMETHODIMP
nsLocalFile::SetUnicodeLeafName(const PRUnichar * aLeafName)
nsLocalFile::SetLeafName(const nsAString &aLeafName)
{
nsresult rv;
nsCAutoString fsStr;
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(nsDependentString(aLeafName), fsStr)))
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(aLeafName, fsStr)))
rv = SetNativeLeafName(fsStr);
return rv;
@ -1738,10 +1732,9 @@ nsLocalFile::GetNativePath(nsACString &_retval)
}
NS_IMETHODIMP
nsLocalFile::GetUnicodePath(PRUnichar **_retval)
nsLocalFile::GetPath(nsAString &_retval)
{
nsresult rv = NS_OK;
NS_ENSURE_ARG_POINTER(_retval);
#if TARGET_CARBON
if (sHasHFSPlusAPIs) // should always be true under Carbon, but in case...
@ -1770,9 +1763,7 @@ nsLocalFile::GetUnicodePath(PRUnichar **_retval)
ucPathString.Append(ucAppendage);
}
*_retval = ToNewUnicode(ucPathString);
if (!*_retval)
return NS_ERROR_OUT_OF_MEMORY;
_retval = ucPathString;
}
else
#endif
@ -1780,11 +1771,7 @@ nsLocalFile::GetUnicodePath(PRUnichar **_retval)
nsCAutoString fsStr;
if (NS_SUCCEEDED(rv = GetNativePath(fsStr))) {
nsAutoString ucStr;
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::FSToUCS(fsStr, ucStr))) {
if ((*_retval = ToNewUnicode(ucStr)) == nsnull)
rv = NS_ERROR_OUT_OF_MEMORY;
}
rv = nsFSStringConversionMac::FSToUCS(fsStr, _retval);
}
}
return rv;
@ -1877,14 +1864,14 @@ nsLocalFile::CopyToNative(nsIFile *newParentDir, const nsACString &newName)
}
NS_IMETHODIMP
nsLocalFile::CopyToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
nsLocalFile::CopyTo(nsIFile *newParentDir, const nsAString &newName)
{
if (!newName)
if (newName.IsEmpty())
return CopyToNative(newParentDir, nsCString());
nsresult rv;
nsCAutoString fsStr;
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(nsDependentString(newName), fsStr)))
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(newName, fsStr)))
rv = CopyToNative(newParentDir, fsStr);
return rv;
}
@ -1896,14 +1883,14 @@ nsLocalFile::CopyToFollowingLinksNative(nsIFile *newParentDir, const nsACString
}
NS_IMETHODIMP
nsLocalFile::CopyToFollowingLinksUnicode(nsIFile *newParentDir, const PRUnichar *newName)
nsLocalFile::CopyToFollowingLinks(nsIFile *newParentDir, const nsAString &newName)
{
if (!newName)
if (newName.IsEmpty())
return CopyToFollowingLinksNative(newParentDir, nsCString());
nsresult rv;
nsCAutoString fsStr;
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(nsDependentString(newName), fsStr)))
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(newName, fsStr)))
rv = CopyToFollowingLinksNative(newParentDir, fsStr);
return rv;
}
@ -1915,14 +1902,14 @@ nsLocalFile::MoveToNative(nsIFile *newParentDir, const nsACString &newName)
}
NS_IMETHODIMP
nsLocalFile::MoveToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
nsLocalFile::MoveTo(nsIFile *newParentDir, const nsAString &newName)
{
if (!newName)
if (newName.IsEmpty())
return MoveToNative(newParentDir, nsCString());
nsresult rv;
nsCAutoString fsStr;
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(nsDependentString(newName), fsStr)))
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::UCSToFS(newName, fsStr)))
rv = MoveToNative(newParentDir, fsStr);
return rv;
}
@ -2550,17 +2537,13 @@ nsLocalFile::GetNativeTarget(nsACString &_retval)
}
NS_IMETHODIMP
nsLocalFile::GetUnicodeTarget(PRUnichar **_retval)
nsLocalFile::GetTarget(nsAString &_retval)
{
nsresult rv;
nsCAutoString fsStr;
if (NS_SUCCEEDED(rv = GetNativeTarget(fsStr))) {
nsAutoString ucStr;
if (NS_SUCCEEDED(rv = nsFSStringConversionMac::FSToUCS(fsStr, ucStr))) {
if ((*_retval = ToNewUnicode(ucStr)) == nsnull)
rv = NS_ERROR_OUT_OF_MEMORY;
}
rv = nsFSStringConversionMac::FSToUCS(fsStr, _retval);
}
return rv;
}
@ -3563,10 +3546,10 @@ NS_NewNativeLocalFile(const nsACString &path, PRBool followLinks, nsILocalFile*
}
nsresult
NS_NewUnicodeLocalFile(const PRUnichar* path, PRBool followLinks, nsILocalFile* *result)
NS_NewLocalFile(const nsAString &path, PRBool followLinks, nsILocalFile* *result)
{
nsCAutoString fsCharSetStr;
nsresult rv = nsFSStringConversionMac::UCSToFS(nsDependentString(path), fsCharSetStr);
nsresult rv = nsFSStringConversionMac::UCSToFS(path, fsCharSetStr);
if (NS_FAILED(rv))
return rv;
return NS_NewNativeLocalFile(fsCharSetStr, followLinks, result);

Просмотреть файл

@ -86,15 +86,6 @@ protected:
nsresult ExtensionIsOnExceptionList(const char *extension, PRBool *onList);
// XXX needs impl
static PRBool FSCharsetIsUTF8() { return PR_FALSE; }
// XXX we should compute and store these values
PRBool LeafIsASCII() { return PR_FALSE; }
PRBool PathIsASCII() { return PR_FALSE; }
NS_DECL_NSLOCALFILE_UNICODE_METHODS
private:
nsLocalFile(const nsLocalFile& srcFile);
nsLocalFile(const FSSpec& aSpec, const nsACString& aAppendedPath);

Просмотреть файл

@ -28,7 +28,6 @@
#include "nsMemory.h"
#include "nsLocalFileOS2.h"
#include "nsLocalFileUnicode.h"
#include <uconv.h>
@ -2272,16 +2271,13 @@ FStoUCS2(const char* aBuffer, PRUnichar **aResult)
}
NS_IMETHODIMP
nsLocalFile::InitWithUnicodePath(const PRUnichar *filePath)
nsLocalFile::InitWithPath(const nsAString &filePath)
{
NS_ENSURE_ARG(filePath);
if (nsCRT::strlen(filePath) == 0)
return NS_ERROR_INVALID_ARG;
if (filePath.IsEmpty())
return InitWithNativePath(nsCString());
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(filePath, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(filePath).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return InitWithNativePath(tmp);
@ -2290,15 +2286,13 @@ nsLocalFile::InitWithUnicodePath(const PRUnichar *filePath)
}
NS_IMETHODIMP
nsLocalFile::AppendUnicode(const PRUnichar *node)
nsLocalFile::Append(const nsAString &node)
{
NS_ENSURE_ARG(node);
if (nsCRT::strlen(node) == 0)
if (node.IsEmpty())
return NS_OK;
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(node, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(node).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return AppendNative(tmp);
@ -2307,11 +2301,9 @@ nsLocalFile::AppendUnicode(const PRUnichar *node)
}
NS_IMETHODIMP
nsLocalFile::AppendRelativeUnicodePath(const PRUnichar *node)
nsLocalFile::AppendRelativePath(const nsAString &node)
{
NS_ENSURE_ARG(node);
if (nsCRT::strlen(node) == 0)
if (node.IsEmpty())
return NS_OK;
nsXPIDLCString tmp;
@ -2319,7 +2311,7 @@ nsLocalFile::AppendRelativeUnicodePath(const PRUnichar *node)
if (tmp.IsEmpty())
return NS_OK;
nsresult rv = UCS2toFS(node, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(node).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return AppendRelativeNativePath(tmp);
@ -2328,28 +2320,29 @@ nsLocalFile::AppendRelativeUnicodePath(const PRUnichar *node)
}
NS_IMETHODIMP
nsLocalFile::GetUnicodeLeafName(PRUnichar **aLeafName)
nsLocalFile::GetLeafName(nsAString &aLeafName)
{
NS_ENSURE_ARG_POINTER(aLeafName);
nsCAutoString tmp;
nsresult rv = GetNativeLeafName(tmp);
if (NS_SUCCEEDED(rv))
return FStoUCS2(tmp.get(), aLeafName);
if (NS_SUCCEEDED(rv)) {
nsXPIDLString ucsBuf;
rv = FStoUCS2(tmp.get(), getter_Copies(ucsBuf));
if (NS_SUCCEEDED(rv))
aLeafName = ucsBuf;
}
return rv;
}
NS_IMETHODIMP
nsLocalFile::SetUnicodeLeafName(const PRUnichar *aLeafName)
nsLocalFile::SetLeafName(const nsAString &aLeafName)
{
NS_ENSURE_ARG(aLeafName);
if (nsCRT::strlen(aLeafName) == 0)
return NS_OK;
if (aLeafName.IsEmpty())
return SetNativeLeafName(nsCString());
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(aLeafName, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(aLeafName).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return SetNativeLeafName(tmp);
@ -2358,21 +2351,23 @@ nsLocalFile::SetUnicodeLeafName(const PRUnichar *aLeafName)
}
NS_IMETHODIMP
nsLocalFile::GetUnicodePath(PRUnichar **_retval)
nsLocalFile::GetPath(nsAString &_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
return FStoUCS2(mWorkingPath.get(), _retval);
nsXPIDLString ucsBuf;
nsresult rv = FStoUCS2(mWorkingPath.get(), getter_Copies(ucsBuf));
if (NS_SUCCEEDED(rv))
_retval = ucsBuf;
return rv;
}
NS_IMETHODIMP
nsLocalFile::CopyToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
nsLocalFile::CopyTo(nsIFile *newParentDir, const nsAString &newName)
{
if (!newName || nsCRT::strlen(newName) == 0)
if (newName.IsEmpty())
return CopyToNative(newParentDir, nsCString());
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(newName, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(newName).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return CopyToNative(newParentDir, tmp);
@ -2381,13 +2376,13 @@ nsLocalFile::CopyToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
}
NS_IMETHODIMP
nsLocalFile::CopyToFollowingLinksUnicode(nsIFile *newParentDir, const PRUnichar *newName)
nsLocalFile::CopyToFollowingLinks(nsIFile *newParentDir, const nsAString &newName)
{
if (!newName || nsCRT::strlen(newName) == 0)
if (newName.IsEmpty())
return CopyToFollowingLinksNative(newParentDir, nsCString());
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(newName, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(newName).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return CopyToFollowingLinksNative(newParentDir, tmp);
@ -2396,13 +2391,13 @@ nsLocalFile::CopyToFollowingLinksUnicode(nsIFile *newParentDir, const PRUnichar
}
NS_IMETHODIMP
nsLocalFile::MoveToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
nsLocalFile::MoveTo(nsIFile *newParentDir, const nsAString &newName)
{
if (!newName || nsCRT::strlen(newName) == 0)
if (newName.IsEmpty())
return MoveToNative(newParentDir, nsCString());
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(newName, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(newName).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return MoveToNative(newParentDir, tmp);
@ -2411,26 +2406,29 @@ nsLocalFile::MoveToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
}
NS_IMETHODIMP
nsLocalFile::GetUnicodeTarget(PRUnichar **_retval)
nsLocalFile::GetTarget(nsAString &_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
nsCAutoString tmp;
nsresult rv = GetNativeTarget(tmp);
if (NS_SUCCEEDED(rv))
return FStoUCS2(tmp.get(), _retval);
if (NS_SUCCEEDED(rv)) {
nsXPIDLString ucsBuf;
rv = FStoUCS2(tmp.get(), getter_Copies(ucsBuf));
if (NS_SUCCEEDED(rv))
_retval = ucsBuf;
}
return rv;
}
nsresult
NS_NewUnicodeLocalFile(const PRUnichar* path, PRBool followLinks, nsILocalFile* *result)
NS_NewLocalFile(const nsAString &path, PRBool followLinks, nsILocalFile* *result)
{
if (!path || nsCRT::strlen(path) == 0)
return NS_ERROR_INVALID_ARG;
if (path.IsEmpty())
return NS_NewNativeLocalFile(nsCString(), followLinks, result);
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(path, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(path).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return NS_NewNativeLocalFile(tmp, followLinks, result);
@ -2442,14 +2440,10 @@ NS_NewUnicodeLocalFile(const PRUnichar* path, PRBool followLinks, nsILocalFile*
// global init/shutdown
//----------------------------------------------------------------------------
PRBool nsLocalFile::mFSCharsetIsUTF8 = PR_FALSE;
void
nsLocalFile::GlobalInit()
{
NS_CreateUnicodeConverters();
// XXX set mFSCharsetIsUTF8
}
void

Просмотреть файл

@ -115,12 +115,9 @@ public:
public:
static void GlobalInit();
static void GlobalShutdown();
static PRBool FSCharsetIsUTF8() { return mFSCharsetIsUTF8; }
private:
static PRBool mFSCharsetIsUTF8;
// this is the flag which indicates if I can used cached information about the file
PRPackedBool mDirty;
PRPackedBool mLastResolution;
@ -147,12 +144,6 @@ private:
nsresult CopySingleFile(nsIFile *source, nsIFile* dest, const nsACString &newName, PRBool followSymlinks, PRBool move);
nsresult SetModDate(PRInt64 aLastModifiedTime, PRBool resolveTerminal);
// XXX impl
PRBool PathIsASCII() { return PR_FALSE; }
PRBool LeafIsASCII() { return PR_FALSE; }
NS_DECL_NSLOCALFILE_UNICODE_METHODS
};
#endif

Просмотреть файл

@ -41,6 +41,7 @@
#include <utime.h>
#include <dirent.h>
#include <ctype.h>
#include <locale.h>
#ifdef XP_BEOS
#include <Path.h>
#include <Entry.h>
@ -58,7 +59,6 @@
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsLocalFileUnix.h"
#include "nsLocalFileUnicode.h"
#include "nsIComponentManager.h"
#include "nsXPIDLString.h"
#include "prproces.h"
@ -210,9 +210,7 @@ nsDirEnumeratorUnix::GetNextEntry()
}
nsLocalFile::nsLocalFile() :
mHaveCachedStat(PR_FALSE),
mPathIsASCII(-1),
mLeafIsASCII(-1)
mHaveCachedStat(PR_FALSE)
{
NS_INIT_REFCNT();
}
@ -670,11 +668,11 @@ nsLocalFile::CopyDirectoryTo(nsIFile *newParent)
rv = newParent->Clone(getter_AddRefs(destClone));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsILocalFile> newDir(do_QueryInterface(destClone));
if (NS_FAILED(rv = entry->CopyTo(newDir, nsCString()))) {
if (NS_FAILED(rv = entry->CopyToNative(newDir, nsCString()))) {
#ifdef DEBUG
nsresult rv2;
nsCAutoString pathName;
if (NS_FAILED(rv2 = entry->GetPath(pathName)))
if (NS_FAILED(rv2 = entry->GetNativePath(pathName)))
return rv2;
printf("Operation not supported: %s\n", pathName.get());
#endif
@ -684,11 +682,11 @@ nsLocalFile::CopyDirectoryTo(nsIFile *newParent)
}
}
} else {
if (NS_FAILED(rv = entry->CopyTo(newParent, nsCString()))) {
if (NS_FAILED(rv = entry->CopyToNative(newParent, nsCString()))) {
#ifdef DEBUG
nsresult rv2;
nsCAutoString pathName;
if (NS_FAILED(rv2 = entry->GetPath(pathName)))
if (NS_FAILED(rv2 = entry->GetNativePath(pathName)))
return rv2;
printf("Operation not supported: %s\n", pathName.get());
#endif
@ -1552,61 +1550,73 @@ NS_NewNativeLocalFile(const nsACString &path, PRBool followSymlinks, nsILocalFil
#define TOLERATE_UCONV_FAILURE 1
static int
convert_ucs2_to_native(const PRUnichar *input, char *result, unsigned resultLen)
convert_ucs2_to_native(const nsAString &input, char *result, unsigned resultLen)
{
// this function assumes that |result| is big enough
NS_ASSERTION(resultLen == PATH_MAX, "unexpected resultLen");
#ifdef HAVE_WCRTOMB
mbstate_t ps = {0};
#endif
char buf[16], *cursor = result;
char *cursor = result;
int i = 0;
const PRUnichar *p = input;
NS_ASSERTION(MB_CUR_MAX <= sizeof(buf), "must increase sizeof(buf)");
nsAString::const_iterator start, end;
input.BeginReading(start);
input.EndReading(end);
PRUint32 size;
// perform conversion
p = input;
while (*p) {
for ( ; start != end; start.advance(size)) {
size = start.size_forward();
const PRUnichar *p = start.get();
for (PRUint32 j = 0; j < size; ++j, ++p) {
#ifdef HAVE_WCRTOMB
i = (int) wcrtomb(cursor, (wchar_t) *p, &ps);
i = (int) wcrtomb(cursor, (wchar_t) *p, &ps);
#else
// XXX is this thread-safe?
i = (int) wctomb(cursor, (wchar_t) *p);
// XXX is this thread-safe?
i = (int) wctomb(cursor, (wchar_t) *p);
#endif
if (i < 0) {
NS_WARNING("wctomb failed: possible charset mismatch");
if (i < 0) {
NS_WARNING("wctomb failed: possible charset mismatch");
#ifdef TOLERATE_UCONV_FAILURE
*cursor = (unsigned char) *p; // truncate
i = 1;
*cursor = (unsigned char) *p; // truncate
i = 1;
#else
return -1;
return -1;
#endif
}
// most likely we're dead anyways if this assertion should fire
NS_ASSERTION(cursor + i <= result + resultLen, "wrote beyond end of string");
cursor += i;
if (cursor >= result + resultLen - 1) {
cursor = result + resultLen - 1; // fixup cursor
break;
}
}
// most likely we're dead anyways if this assertion should fire
NS_ASSERTION(cursor + i <= result + resultLen, "wrote beyond end of string");
cursor += i;
if (cursor >= result + resultLen - 1) {
cursor = result + resultLen - 1; // fixup cursor
break;
}
p++;
}
*cursor = '\0';
return cursor - result;
}
static int
convert_native_to_ucs2(const char *input, unsigned inputLen, PRUnichar **result)
convert_native_to_ucs2(const char *input, unsigned inputLen, nsAString &result)
{
#ifdef HAVE_MBRTOWC
mbstate_t ps = {0};
#endif
PRUnichar *p;
int i;
int i, resultLen = 0;
result.Truncate();
// allocate space for largest possible result
p = *result = (PRUnichar *) nsMemory::Alloc((inputLen + 1) * sizeof(PRUnichar));
result.SetCapacity(inputLen + 1);
nsAString::iterator start;
result.BeginWriting(start);
p = start.get();
if (!p) {
NS_ERROR("memory allocation failed");
return -1;
@ -1625,6 +1635,7 @@ convert_native_to_ucs2(const char *input, unsigned inputLen, PRUnichar **result)
if (i < 0) {
NS_WARNING("mbtowc failed: possible charset mismatch");
#ifdef TOLERATE_UCONV_FAILURE
// truncate and hope for the best
tmp = (unsigned char) *input;
i = 1;
#else
@ -1637,9 +1648,10 @@ convert_native_to_ucs2(const char *input, unsigned inputLen, PRUnichar **result)
input += i;
inputLen -= i;
p++;
resultLen++;
}
*p = '\0';
return p - *result;
result.SetLength(resultLen);
return 0;
}
#define SET_UCS(func, ucsArg) \
@ -1673,60 +1685,60 @@ convert_native_to_ucs2(const char *input, unsigned inputLen, PRUnichar **result)
// Unicode interface Wrapper
nsresult
nsLocalFile::InitWithUnicodePath(const PRUnichar *filePath)
nsLocalFile::InitWithPath(const nsAString &filePath)
{
SET_UCS(InitWithNativePath, filePath);
SET_UCS(InitWithNativePath, filePath);
}
nsresult
nsLocalFile::AppendUnicode(const PRUnichar *node)
nsLocalFile::Append(const nsAString &node)
{
SET_UCS( AppendNative , node);
SET_UCS(AppendNative, node);
}
nsresult
nsLocalFile::AppendRelativeUnicodePath(const PRUnichar *node)
nsLocalFile::AppendRelativePath(const nsAString &node)
{
SET_UCS( AppendRelativeNativePath , node);
SET_UCS(AppendRelativeNativePath, node);
}
nsresult
nsLocalFile::GetUnicodeLeafName(PRUnichar **aLeafName)
nsLocalFile::GetLeafName(nsAString &aLeafName)
{
GET_UCS(GetNativeLeafName, aLeafName);
GET_UCS(GetNativeLeafName, aLeafName);
}
nsresult
nsLocalFile::SetUnicodeLeafName(const PRUnichar * aLeafName)
nsLocalFile::SetLeafName(const nsAString &aLeafName)
{
SET_UCS( SetNativeLeafName , aLeafName);
SET_UCS(SetNativeLeafName, aLeafName);
}
nsresult
nsLocalFile::GetUnicodePath(PRUnichar **_retval)
nsLocalFile::GetPath(nsAString &_retval)
{
int i = convert_native_to_ucs2(mPath.get(), mPath.Length(), _retval);
if (i == -1)
return NS_ERROR_FAILURE;
return NS_OK;
int i = convert_native_to_ucs2(mPath.get(), mPath.Length(), _retval);
if (i == -1)
return NS_ERROR_FAILURE;
return NS_OK;
}
nsresult
nsLocalFile::CopyToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
nsLocalFile::CopyTo(nsIFile *newParentDir, const nsAString &newName)
{
SET_UCS_2ARGS_2( CopyToNative , newParentDir, newName);
SET_UCS_2ARGS_2(CopyToNative , newParentDir, newName);
}
nsresult
nsLocalFile::CopyToFollowingLinksUnicode(nsIFile *newParentDir, const PRUnichar *newName)
nsLocalFile::CopyToFollowingLinks(nsIFile *newParentDir, const nsAString &newName)
{
SET_UCS_2ARGS_2( CopyToFollowingLinksNative , newParentDir, newName);
SET_UCS_2ARGS_2(CopyToFollowingLinksNative , newParentDir, newName);
}
nsresult
nsLocalFile::MoveToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
nsLocalFile::MoveTo(nsIFile *newParentDir, const nsAString &newName)
{
SET_UCS_2ARGS_2( MoveToNative , newParentDir, newName);
SET_UCS_2ARGS_2(MoveToNative, newParentDir, newName);
}
nsresult
nsLocalFile::GetUnicodeTarget(PRUnichar **_retval)
nsLocalFile::GetTarget(nsAString &_retval)
{
GET_UCS(GetNativeTarget, _retval);
GET_UCS(GetNativeTarget, _retval);
}
nsresult
NS_NewUnicodeLocalFile(const PRUnichar* path, PRBool followLinks, nsILocalFile* *result)
NS_NewLocalFile(const nsAString &path, PRBool followLinks, nsILocalFile* *result)
{
char buf[PATH_MAX];
int i = convert_ucs2_to_native(path, buf, PATH_MAX);
@ -1739,25 +1751,11 @@ NS_NewUnicodeLocalFile(const PRUnichar* path, PRBool followLinks, nsILocalFile*
// global init/shutdown
//-----------------------------------------------------------------------------
PRBool
nsLocalFile::FSCharsetIsUTF8()
{
#if HAVE_NL_LANGINFO && defined(CODESET)
// this result may vary, so we must query nl_langinfo each time.
// fortunately, this amounts to little more than an array lookup (at
// least that's how it's implemented in glibc).
const char *codeset = nl_langinfo(CODESET);
if (!codeset) {
NS_WARNING("cannot get nl_langinfo(CODESET)");
return PR_FALSE;
}
return (strcmp(codeset, "UTF-8") == 0);
#endif
}
void
nsLocalFile::GlobalInit()
{
// need to initialize the locale or else charset conversion will fail.
setlocale(LC_CTYPE, "");
}
void

Просмотреть файл

@ -118,31 +118,11 @@ public:
public:
static void GlobalInit();
static void GlobalShutdown();
static PRBool FSCharsetIsUTF8();
protected:
struct stat mCachedStat;
nsCString mPath;
PRPackedBool mHaveCachedStat;
PRInt8 mPathIsASCII; // -1 if unknown
PRInt8 mLeafIsASCII; // -1 if unknown
NS_DECL_NSLOCALFILE_UNICODE_METHODS
// XXX these results should probably be cached
PRBool PathIsASCII() {
if (mPathIsASCII == -1)
mPathIsASCII = IsASCII(mPath);
return mPathIsASCII;
}
PRBool LeafIsASCII() {
if (mLeafIsASCII == -1) {
nsACString::const_iterator begin, end;
LocateNativeLeafName(begin, end);
mLeafIsASCII = IsASCII(Substring(begin, end));
}
return mLeafIsASCII;
}
void LocateNativeLeafName(nsACString::const_iterator &,
nsACString::const_iterator &);
@ -155,9 +135,6 @@ protected:
void InvalidateCache() {
mHaveCachedStat = PR_FALSE;
// not the most optimal place to clear these, but it works...
mPathIsASCII = -1;
mLeafIsASCII = -1;
}
nsresult FillStatCache();

Просмотреть файл

@ -27,7 +27,6 @@
#include "nsMemory.h"
#include "nsLocalFileWin.h"
#include "nsLocalFileUnicode.h"
#include "nsISimpleEnumerator.h"
#include "nsIComponentManager.h"
@ -1935,7 +1934,7 @@ nsLocalFile::Reveal()
nsresult rv = NS_OK;
PRBool isDirectory = PR_FALSE;
nsCAutoString path;
nsCAutoString utf8Path;
nsAutoString unicodePath;
IsDirectory(&isDirectory);
if (isDirectory)
@ -1949,12 +1948,10 @@ nsLocalFile::Reveal()
if (parent)
{
parent->GetNativePath(path);
parent->GetPath(utf8Path);
parent->GetPath(unicodePath);
}
}
NS_ConvertUTF8toUCS2 unicodePath(utf8Path);
// Remember the current fg window.
HWND origWin, fgWin;
origWin = fgWin = ::GetForegroundWindow();
@ -2030,8 +2027,8 @@ nsLocalFile::Reveal()
break;
// Now get file name pidl from that folder.
nsXPIDLString unicodeLeaf;
if (NS_FAILED(GetUnicodeLeafName(getter_Copies(unicodeLeaf))))
nsAutoString unicodeLeaf;
if (NS_FAILED(GetLeafName(unicodeLeaf)))
break;
rc = folder->ParseDisplayName( 0,
0,
@ -2210,10 +2207,10 @@ static nsresult FStoUCS2(const char* aBuffer, PRUnichar **aResult)
}
nsresult
nsLocalFile::InitWithUnicodePath(const PRUnichar *filePath)
nsLocalFile::InitWithPath(const nsAString &filePath)
{
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(filePath, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(filePath).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return InitWithNativePath(tmp);
@ -2221,10 +2218,10 @@ nsLocalFile::InitWithUnicodePath(const PRUnichar *filePath)
}
nsresult
nsLocalFile::AppendUnicode(const PRUnichar *node)
nsLocalFile::Append(const nsAString &node)
{
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(node, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(node).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return AppendNative(tmp);
@ -2232,31 +2229,35 @@ nsLocalFile::AppendUnicode(const PRUnichar *node)
}
nsresult
nsLocalFile::AppendRelativeUnicodePath(const PRUnichar *node)
nsLocalFile::AppendRelativePath(const nsAString &node)
{
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(node, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(node).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return AppendRelativeNativePath(tmp);
return rv;
}
nsresult
nsLocalFile::GetUnicodeLeafName(PRUnichar **aLeafName)
nsLocalFile::GetLeafName(nsAString &aLeafName)
{
nsCAutoString tmp;
nsresult rv = GetNativeLeafName(tmp);
if (NS_SUCCEEDED(rv))
return FStoUCS2(tmp.get(), aLeafName);
if (NS_SUCCEEDED(rv)) {
nsXPIDLString ucsBuf;
rv = FStoUCS2(tmp.get(), getter_Copies(ucsBuf));
if (NS_SUCCEEDED(rv))
aLeafName = ucsBuf;
}
return rv;
}
nsresult
nsLocalFile::SetUnicodeLeafName(const PRUnichar * aLeafName)
nsLocalFile::SetLeafName(const nsAString &aLeafName)
{
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(aLeafName, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(aLeafName).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return SetNativeLeafName(tmp);
@ -2264,19 +2265,23 @@ nsLocalFile::SetUnicodeLeafName(const PRUnichar * aLeafName)
}
nsresult
nsLocalFile::GetUnicodePath(PRUnichar **_retval)
nsLocalFile::GetPath(nsAString &_retval)
{
return FStoUCS2(mWorkingPath.get(), _retval);
nsXPIDLString ucsBuf;
nsresult rv = FStoUCS2(mWorkingPath.get(), getter_Copies(ucsBuf));
if (NS_SUCCEEDED(rv))
_retval = ucsBuf;
return rv;
}
nsresult
nsLocalFile::CopyToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
nsLocalFile::CopyTo(nsIFile *newParentDir, const nsAString &newName)
{
if (!newName)
if (newName.IsEmpty())
return CopyToNative(newParentDir, nsCString());
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(newName, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(newName).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return CopyToNative(newParentDir, tmp);
@ -2284,13 +2289,13 @@ nsLocalFile::CopyToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
}
nsresult
nsLocalFile::CopyToFollowingLinksUnicode(nsIFile *newParentDir, const PRUnichar *newName)
nsLocalFile::CopyToFollowingLinks(nsIFile *newParentDir, const nsAString &newName)
{
if (!newName)
if (newName.IsEmpty())
return CopyToFollowingLinksNative(newParentDir, nsCString());
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(newName, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(newName).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return CopyToFollowingLinksNative(newParentDir, tmp);
@ -2298,13 +2303,13 @@ nsLocalFile::CopyToFollowingLinksUnicode(nsIFile *newParentDir, const PRUnichar
}
nsresult
nsLocalFile::MoveToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
nsLocalFile::MoveTo(nsIFile *newParentDir, const nsAString &newName)
{
if (!newName)
if (newName.IsEmpty())
return MoveToNative(newParentDir, nsCString());
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(newName, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(newName).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return MoveToNative(newParentDir, tmp);
@ -2312,21 +2317,25 @@ nsLocalFile::MoveToUnicode(nsIFile *newParentDir, const PRUnichar *newName)
}
nsresult
nsLocalFile::GetUnicodeTarget(PRUnichar **_retval)
nsLocalFile::GetTarget(nsAString &_retval)
{
nsCAutoString tmp;
nsresult rv = GetNativeTarget(tmp);
if (NS_SUCCEEDED(rv))
return FStoUCS2(tmp.get(), _retval);
if (NS_SUCCEEDED(rv)) {
nsXPIDLString ucsBuf;
rv = FStoUCS2(tmp.get(), getter_Copies(ucsBuf));
if (NS_SUCCEEDED(rv))
_retval = ucsBuf;
}
return rv;
}
nsresult
NS_NewUnicodeLocalFile(const PRUnichar* path, PRBool followLinks, nsILocalFile* *result)
NS_NewLocalFile(const nsAString &path, PRBool followLinks, nsILocalFile* *result)
{
nsXPIDLCString tmp;
nsresult rv = UCS2toFS(path, getter_Copies(tmp));
nsresult rv = UCS2toFS(PromiseFlatString(path).get(), getter_Copies(tmp));
if (NS_SUCCEEDED(rv))
return NS_NewNativeLocalFile(tmp, followLinks, result);
@ -2337,15 +2346,11 @@ NS_NewUnicodeLocalFile(const PRUnichar* path, PRBool followLinks, nsILocalFile*
// nsLocalFile <static members>
//-----------------------------------------------------------------------------
PRBool nsLocalFile::mFSCharsetIsUTF8 = PR_FALSE;
void
nsLocalFile::GlobalInit()
{
nsresult rv = NS_CreateShortcutResolver();
NS_ASSERTION(NS_SUCCEEDED(rv), "Shortcut resolver could not be created");
// XXX determine value of mFSCharsetIsUTF8
}
void

Просмотреть файл

@ -68,7 +68,6 @@ public:
public:
static void GlobalInit();
static void GlobalShutdown();
static PRBool FSCharsetIsUTF8() { return mFSCharsetIsUTF8; }
private:
@ -88,12 +87,6 @@ private:
static PRBool mFSCharsetIsUTF8;
NS_DECL_NSLOCALFILE_UNICODE_METHODS
// XXX impl
PRBool PathIsASCII() { return PR_FALSE; }
PRBool LeafIsASCII() { return PR_FALSE; }
void MakeDirty();
nsresult ResolveAndStat(PRBool resolveTerminal);
nsresult ResolvePath(const char* workingPath, PRBool resolveTerminal, char** resolvedPath);

Просмотреть файл

@ -332,7 +332,7 @@ xptiInterfaceInfoManager::BuildFileList(nsISupportsArray* aSearchPath,
}
nsCAutoString name;
if(NS_FAILED(file->GetLeafName(name)))
if(NS_FAILED(file->GetNativeLeafName(name)))
return PR_FALSE;
if(xptiFileType::IsUnknown(name.get()))
@ -431,7 +431,7 @@ xptiInterfaceInfoManager::LoadFile(const xptiTypelib& aTypelibRecord,
getter_AddRefs(file))) || !file)
return PR_FALSE;
if(NS_FAILED(file->Append(nsDependentCString(fileRecord->GetName()))))
if(NS_FAILED(file->AppendNative(nsDependentCString(fileRecord->GetName()))))
return PR_FALSE;
XPTHeader* header;
@ -628,12 +628,12 @@ xptiSortFileList(const void * p1, const void *p2, void * closure)
nsCAutoString name1;
nsCAutoString name2;
if(NS_FAILED(pFile1->GetLeafName(name1)))
if(NS_FAILED(pFile1->GetNativeLeafName(name1)))
{
NS_ERROR("way bad, with no happy out!");
return 0;
}
if(NS_FAILED(pFile2->GetLeafName(name2)))
if(NS_FAILED(pFile2->GetNativeLeafName(name2)))
{
NS_ERROR("way bad, with no happy out!");
return 0;
@ -792,7 +792,7 @@ xptiInterfaceInfoManager::DetermineAutoRegStrategy(nsISupportsArray* aSearchPath
if(NS_FAILED(file->GetFileSize(&size)) ||
NS_FAILED(file->GetLastModifiedTime(&date)) ||
NS_FAILED(file->GetLeafName(name)) ||
NS_FAILED(file->GetNativeLeafName(name)) ||
!aWorkingSet->FindDirectoryOfFile(file, &directory))
{
NS_ERROR("unexpected!");
@ -841,7 +841,7 @@ xptiInterfaceInfoManager::DetermineAutoRegStrategy(nsISupportsArray* aSearchPath
PRInt64 date;
if(NS_FAILED(file->GetFileSize(&size)) ||
NS_FAILED(file->GetLastModifiedTime(&date)) ||
NS_FAILED(file->GetLeafName(name)))
NS_FAILED(file->GetNativeLeafName(name)))
{
NS_ERROR("unexpected!");
return FULL_VALIDATION_REQUIRED;
@ -909,7 +909,7 @@ xptiInterfaceInfoManager::AddOnlyNewFilesFromFileList(nsISupportsArray* aSearchP
PRUint32 dir;
if(NS_FAILED(file->GetFileSize(&size)) ||
NS_FAILED(file->GetLastModifiedTime(&date)) ||
NS_FAILED(file->GetLeafName(name)) ||
NS_FAILED(file->GetNativeLeafName(name)) ||
!aWorkingSet->FindDirectoryOfFile(file, &dir))
{
return PR_FALSE;
@ -1059,7 +1059,7 @@ xptiInterfaceInfoManager::DoFullValidationMergeFromFileList(nsISupportsArray* aS
PRUint32 dir;
if(NS_FAILED(file->GetFileSize(&size)) ||
NS_FAILED(file->GetLastModifiedTime(&date)) ||
NS_FAILED(file->GetLeafName(name)) ||
NS_FAILED(file->GetNativeLeafName(name)) ||
!aWorkingSet->FindDirectoryOfFile(file, &dir))
{
return PR_FALSE;
@ -1545,7 +1545,7 @@ xptiInterfaceInfoManager::DEBUG_DumpFileList(nsISupportsArray* aFileList)
return PR_FALSE;
nsCAutoString name;
if(NS_FAILED(file->GetLeafName(name)))
if(NS_FAILED(file->GetNativeLeafName(name)))
return PR_FALSE;
printf("* found %s\n", name.get());
@ -1575,7 +1575,7 @@ xptiInterfaceInfoManager::DEBUG_DumpFileArray(nsILocalFile** aFileArray,
nsILocalFile* file = aFileArray[i];
nsCAutoString name;
if(NS_FAILED(file->GetLeafName(name)))
if(NS_FAILED(file->GetNativeLeafName(name)))
return PR_FALSE;
printf("found file: %s\n", name.get());

Просмотреть файл

@ -79,7 +79,7 @@ CurrentAppDirMatchesPersistentDescriptor(xptiInterfaceInfoManager* aMgr,
aMgr->GetApplicationDir(getter_AddRefs(appDir));
nsCOMPtr<nsILocalFile> descDir;
nsresult rv = NS_NewLocalFile(nsCString(), PR_FALSE, getter_AddRefs(descDir));
nsresult rv = NS_NewNativeLocalFile(nsCString(), PR_FALSE, getter_AddRefs(descDir));
if(NS_FAILED(rv))
return PR_FALSE;
@ -136,7 +136,7 @@ PRBool xptiManifest::Write(xptiInterfaceInfoManager* aMgr,
if(!aMgr->GetCloneOfManifestDir(getter_AddRefs(tempFile)) || !tempFile)
return PR_FALSE;
if(NS_FAILED(tempFile->Append(g_TempManifestFilename)))
if(NS_FAILED(tempFile->AppendNative(g_TempManifestFilename)))
return PR_FALSE;
// All exits via "goto out;" from here on...
@ -262,7 +262,7 @@ out:
if(!aMgr->GetCloneOfManifestDir(getter_AddRefs(mainFile)) || !mainFile)
return PR_FALSE;
if(NS_FAILED(mainFile->Append(g_MainManifestFilename)))
if(NS_FAILED(mainFile->AppendNative(g_MainManifestFilename)))
return PR_FALSE;
PRBool exists;
@ -273,7 +273,7 @@ out:
return PR_FALSE;
// MoveTo means rename.
if(NS_FAILED(tempFile->MoveTo(nsnull, g_MainManifestFilename)))
if(NS_FAILED(tempFile->MoveToNative(nsnull, g_MainManifestFilename)))
return PR_FALSE;
}
@ -297,7 +297,7 @@ ReadManifestIntoMemory(xptiInterfaceInfoManager* aMgr,
if(!aMgr->GetCloneOfManifestDir(getter_AddRefs(aFile)) || !aFile)
return nsnull;
if(NS_FAILED(aFile->Append(g_MainManifestFilename)))
if(NS_FAILED(aFile->AppendNative(g_MainManifestFilename)))
return nsnull;
#ifdef DEBUG
@ -305,7 +305,7 @@ ReadManifestIntoMemory(xptiInterfaceInfoManager* aMgr,
static PRBool shown = PR_FALSE;
nsCAutoString path;
if(!shown && NS_SUCCEEDED(aFile->GetPath(path)) && !path.IsEmpty())
if(!shown && NS_SUCCEEDED(aFile->GetNativePath(path)) && !path.IsEmpty())
{
printf("Type Manifest File: %s\n", path.get());
shown = PR_TRUE;
@ -776,7 +776,7 @@ PRBool xptiManifest::Delete(xptiInterfaceInfoManager* aMgr)
if(!aMgr->GetCloneOfManifestDir(getter_AddRefs(aFile)) || !aFile)
return PR_FALSE;
if(NS_FAILED(aFile->Append(g_MainManifestFilename)))
if(NS_FAILED(aFile->AppendNative(g_MainManifestFilename)))
return PR_FALSE;
PRBool exists;

Просмотреть файл

@ -417,7 +417,7 @@ PRBool xptiWorkingSet::DirectoryAtMatchesPersistentDescriptor(PRUint32 i,
return PR_FALSE;
nsCOMPtr<nsILocalFile> descDir;
nsresult rv = NS_NewLocalFile(nsCString(), PR_FALSE, getter_AddRefs(descDir));
nsresult rv = NS_NewNativeLocalFile(nsCString(), PR_FALSE, getter_AddRefs(descDir));
if(NS_FAILED(rv))
return PR_FALSE;

Просмотреть файл

@ -257,7 +257,7 @@ CopyTest(const char *testFile, const char *targetDir)
rv = dir->InitWithNativePath(nsDependentCString(targetDir));
VerifyResult(rv);
rv = file->CopyTo(dir, nsCString());
rv = file->CopyTo(dir, nsString());
VerifyResult(rv);
printf("end copy test\n");

Просмотреть файл

@ -1184,7 +1184,7 @@ static nsresult VerifyInstallation(int argc, char **argv)
if (NS_FAILED(rv) || !registryFile)
return NS_ERROR_FAILURE;
registryFile->Append(CLEANUP_REGISTRY);
registryFile->AppendNative(CLEANUP_REGISTRY);
PRBool exists;
registryFile->Exists(&exists);
@ -1197,7 +1197,7 @@ static nsresult VerifyInstallation(int argc, char **argv)
nsCOMPtr<nsIFile> cleanupUtility;
registryFile->Clone(getter_AddRefs(cleanupUtility));
cleanupUtility->SetLeafName(CLEANUP_UTIL);
cleanupUtility->SetNativeLeafName(CLEANUP_UTIL);
//Create the process framework to run the cleanup utility
nsCOMPtr<nsIProcess> cleanupProcess = do_CreateInstance(kIProcessCID);

Просмотреть файл

@ -454,11 +454,9 @@ nsDownloadManager::AddDownload(nsIURI* aSource,
}
// Set and assert the "pretty" (display) name of the download
nsCAutoString prettyName;
nsAutoString displayName; displayName.Assign(aDisplayName);
if (displayName.IsEmpty()) {
aTarget->GetLeafName(prettyName);
displayName.Assign(NS_ConvertUTF8toUCS2(prettyName));
aTarget->GetLeafName(displayName);
}
(*aDownload)->SetDisplayName(displayName.get());

Просмотреть файл

@ -540,9 +540,7 @@ nsFileView::GetCellText(PRInt32 aRow, const PRUnichar* aColID,
}
if (NS_LITERAL_STRING("FilenameColumn").Equals(aColID)) {
nsCAutoString temp;
curFile->GetLeafName(temp);
aCellText = NS_ConvertUTF8toUCS2(temp);
curFile->GetLeafName(aCellText);
} else if (NS_LITERAL_STRING("LastModifiedColumn").Equals(aColID)) {
PRInt64 lastModTime;
curFile->GetLastModifiedTime(&lastModTime);
@ -647,13 +645,11 @@ nsFileView::FilterFiles()
if (!mShowHiddenFiles)
file->IsHidden(&isHidden);
nsCAutoString leafName;
if(NS_FAILED(file->GetLeafName(leafName))) {
nsAutoString ucsLeafName;
if(NS_FAILED(file->GetLeafName(ucsLeafName))) {
// need to check return value for GetLeafName()
continue;
}
NS_ConvertUTF8toUCS2 ucsLeafName(leafName);
if (!isHidden) {
for (PRInt32 j = 0; j < filterCount; ++j) {
@ -692,7 +688,7 @@ SortNameCallback(const void* aElement1, const void* aElement2, void* aContext)
nsIFile* file1 = *NS_STATIC_CAST(nsIFile* const *, aElement1);
nsIFile* file2 = *NS_STATIC_CAST(nsIFile* const *, aElement2);
nsCAutoString leafName1, leafName2;
nsAutoString leafName1, leafName2;
file1->GetLeafName(leafName1);
file2->GetLeafName(leafName2);

Просмотреть файл

@ -2433,7 +2433,7 @@ InternetSearchDataSource::saveContents(nsIChannel* channel, nsIInternetSearchCon
if (NS_FAILED(context->GetBufferLength(&bufferLength))) return(rv);
if (bufferLength < 1) return(NS_OK);
rv = outFile->Append(baseName);
rv = outFile->Append(NS_ConvertUTF8toUCS2(baseName));
if (NS_FAILED(rv)) return rv;
// save data to file
@ -3831,12 +3831,10 @@ InternetSearchDataSource::SaveEngineInfoIntoGraph(nsIFile *file, nsIFile *icon,
if (NS_FAILED(rv)) return(rv);
if (!exists) return(NS_ERROR_UNEXPECTED);
nsCAutoString leafName;
rv = native->GetLeafName(leafName);
nsAutoString basename;
rv = native->GetLeafName(basename);
if (NS_FAILED(rv)) return rv;
NS_ConvertUTF8toUCS2 basename(leafName);
// ensure that the basename points to the search engine file
PRInt32 extensionOffset;
if ((extensionOffset = basename.RFindChar(PRUnichar('.'))) > 0)
@ -4054,12 +4052,11 @@ InternetSearchDataSource::GetSearchEngineList(nsIFile *searchDir,
if (NS_FAILED(rv) || (fileSize == 0))
continue;
nsCAutoString pathBuf;
rv = dirEntry->GetPath(pathBuf);
nsAutoString uri;
rv = dirEntry->GetPath(uri);
if (NS_FAILED(rv))
continue;
NS_ConvertUTF8toUCS2 uri(pathBuf);
PRInt32 len = uri.Length();
if (len < 5)
{

Просмотреть файл

@ -331,10 +331,7 @@ nsString nsStreamTransfer::SuggestNameFor( nsIChannel *aChannel, char const *sug
NS_UnescapeURL(suggestedFileName);
if ( NS_SUCCEEDED( NS_NewNativeLocalFile( suggestedFileName, PR_FALSE, getter_AddRefs( localFile ) ) ) ) {
// We want base part of name only.
nsCAutoString baseName;
if ( NS_SUCCEEDED( localFile->GetLeafName( baseName ) ) ) {
result = NS_ConvertUTF8toUCS2(baseName);
}
localFile->GetLeafName(result);
}
} else if ( aChannel ) {
// Get URI from channel and spec from URI.
@ -349,11 +346,8 @@ nsString nsStreamTransfer::SuggestNameFor( nsIChannel *aChannel, char const *sug
rv = fileurl->GetFile(getter_AddRefs(localeFile));
if ( NS_SUCCEEDED( rv ) && localeFile)
{
nsCAutoString baseName;
if ( NS_SUCCEEDED( localeFile->GetLeafName( baseName ) ) ) {
result = NS_ConvertUTF8toUCS2(baseName);
if ( NS_SUCCEEDED( localeFile->GetLeafName( result ) ) )
return result;
}
}
}

Просмотреть файл

@ -138,7 +138,7 @@ nsresult GetRegFilePath(nsACString &regFilePath)
return nsnull;
#if defined (XP_MAC)
tmp->Append(ESSENTIAL_FILES);
tmp->AppendNative(ESSENTIAL_FILES);
#endif
iFileUtilityPath = do_QueryInterface(tmp);
}
@ -151,7 +151,7 @@ nsresult GetRegFilePath(nsACString &regFilePath)
if (NS_FAILED(rv) || !iFileUtilityPath)
return nsnull;
iFileUtilityPath->Append(CLEANUP_REGISTRY);
iFileUtilityPath->AppendNative(CLEANUP_REGISTRY);
//Yes, we know using GetPath is buggy on the Mac.
//When libreg is fixed to accept nsIFiles we'll change this to match.

Просмотреть файл

@ -708,8 +708,7 @@ nsInstall::DiskSpaceAvailable(const nsString& aFolder, PRInt64* aReturn)
return NS_OK;
}
nsCOMPtr<nsILocalFile> folder;
NS_NewLocalFile(NS_ConvertUCS2toUTF8(aFolder), PR_TRUE,
getter_AddRefs(folder));
NS_NewLocalFile(aFolder, PR_TRUE, getter_AddRefs(folder));
result = folder->GetDiskSpaceAvailable(aReturn);
return NS_OK;
@ -2587,7 +2586,7 @@ nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsIFile* aSuggestedName,
aJarfile.Right(extension, (aJarfile.Length() - extpos) );
tempFileName += extension;
}
tempFile->Append(NS_ConvertUCS2toUTF8(tempFileName));
tempFile->Append(tempFileName);
// Create a temporary file to extract to
MakeUnique(tempFile);
@ -2616,7 +2615,7 @@ nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsIFile* aSuggestedName,
return nsInstall::OUT_OF_MEMORY;
//get the leafname so we can convert its extension to .new
nsCAutoString newLeafName;
nsAutoString newLeafName;
tempFile->GetLeafName(newLeafName);
PRInt32 extpos = newLeafName.RFindChar('.');
@ -2625,7 +2624,7 @@ nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsIFile* aSuggestedName,
// We found the extension;
newLeafName.Truncate(extpos + 1); //strip off the old extension
}
newLeafName.Append("new");
newLeafName.Append(NS_LITERAL_STRING("new"));
//Now reset the leafname
tempFile->SetLeafName(newLeafName);
@ -2808,7 +2807,7 @@ nsresult MakeUnique(nsILocalFile* file)
nsCAutoString leafNameBuf;
rv = file->GetLeafName(leafNameBuf);
rv = file->GetNativeLeafName(leafNameBuf);
if (NS_FAILED(rv)) return rv;
// XXX this code should use iterators
@ -2833,7 +2832,7 @@ nsresult MakeUnique(nsILocalFile* file)
// start with "Picture-1.jpg" after "Picture.jpg" exists
char newName[32];
sprintf(newName, "%s-%d%s", leafName, indx, suffix);
file->SetLeafName(nsDependentCString(newName));
file->SetNativeLeafName(nsDependentCString(newName));
rv = file->Exists(&flagExists);
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -140,7 +140,7 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
else
{
nsresult rv = inPartialPath.Mid(subString, offset, nodeLength);
mFinalFile->Append(NS_ConvertUCS2toUTF8(subString));
mFinalFile->Append(subString);
offset += nodeLength + 1;
if (!finished)
location = inPartialPath.FindChar('/', offset);
@ -200,16 +200,13 @@ void nsInstallFile::CreateAllFolders(nsInstall *inInstall, nsIFile *inFolderPath
inFolderPath->Exists(&flagExists);
if(!flagExists)
{
nsCAutoString szPath;
inFolderPath->GetParent(getter_AddRefs(nsfsFolderPath));
CreateAllFolders(inInstall, nsfsFolderPath, error);
inFolderPath->Create(nsIFile::DIRECTORY_TYPE, 0755); //nsIFileXXX: What kind of permissions are required here?
++mFolderCreateCount;
inFolderPath->GetPath(szPath);
nsStrFolder.Assign(NS_ConvertUTF8toUCS2(szPath));
inFolderPath->GetPath(nsStrFolder);
ilc = new nsInstallLogComment(inInstall, NS_LITERAL_STRING("CreateFolder"), nsStrFolder, error);
if(ilc == nsnull)
*error = nsInstall::OUT_OF_MEMORY;

Просмотреть файл

@ -668,7 +668,7 @@ nsInstallFileOpItem::NativeFileOpFileRenamePrepare()
mSrc->GetParent(&target);
nsresult rv =
target->Append(NS_ConvertUCS2toUTF8(*mStrTarget));
target->Append(*mStrTarget);
//90% of the failures during Append will be because the target wasn't in string form
// which it must be.
if (NS_FAILED(rv)) return nsInstall::INVALID_ARGUMENTS;
@ -708,7 +708,7 @@ nsInstallFileOpItem::NativeFileOpFileRenameComplete()
if (target)
{
target->Append(NS_ConvertUCS2toUTF8(*mStrTarget));
target->Append(*mStrTarget);
}
else
return nsInstall::UNEXPECTED_ERROR;
@ -716,8 +716,7 @@ nsInstallFileOpItem::NativeFileOpFileRenameComplete()
target->Exists(&flagExists);
if(!flagExists)
{
mSrc->MoveTo(parent,
NS_ConvertUCS2toUTF8(*mStrTarget));
mSrc->MoveTo(parent, *mStrTarget);
}
else
return nsInstall::ALREADY_EXISTS;
@ -739,7 +738,7 @@ nsInstallFileOpItem::NativeFileOpFileRenameAbort()
{
PRInt32 ret = nsInstall::SUCCESS;
PRBool flagExists;
nsCAutoString leafName;
nsAutoString leafName;
nsCOMPtr<nsIFile> newFilename;
nsCOMPtr<nsIFile> parent;
@ -752,7 +751,7 @@ nsInstallFileOpItem::NativeFileOpFileRenameAbort()
mSrc->GetParent(getter_AddRefs(parent));
if(parent)
{
newFilename->Append(NS_ConvertUCS2toUTF8(*mStrTarget));
newFilename->Append(*mStrTarget);
mSrc->GetLeafName(leafName);
@ -772,7 +771,7 @@ PRInt32
nsInstallFileOpItem::NativeFileOpFileCopyPrepare()
{
PRBool flagExists, flagIsFile, flagIsWritable;
nsCAutoString leafName;
nsAutoString leafName;
nsresult rv;
nsCOMPtr<nsIFile> tempVar;
nsCOMPtr<nsIFile> targetParent;
@ -839,7 +838,7 @@ nsInstallFileOpItem::NativeFileOpFileCopyComplete()
{
PRInt32 rv = NS_OK;
PRBool flagIsFile, flagExists;
nsCAutoString leafName;
nsAutoString leafName;
nsCOMPtr<nsIFile> parent;
nsCOMPtr<nsIFile> tempTarget;
@ -898,7 +897,7 @@ nsInstallFileOpItem::NativeFileOpFileCopyAbort()
mTarget->Clone(getter_AddRefs(fullTarget));
if(nsInstallFileOpItem::ACTION_SUCCESS == mAction)
{
nsCAutoString leafName;
nsAutoString leafName;
mSrc->GetLeafName(leafName);
fullTarget->Append(leafName);
fullTarget->Remove(PR_FALSE);
@ -1050,7 +1049,7 @@ nsInstallFileOpItem::NativeFileOpFileMovePrepare()
else
{
nsCOMPtr<nsIFile> tempVar;
nsCAutoString leaf;
nsAutoString leaf;
mTarget->Clone(getter_AddRefs(tempVar));
mSrc->GetLeafName(leaf);
@ -1164,7 +1163,7 @@ nsInstallFileOpItem::NativeFileOpDirRenamePrepare()
nsCOMPtr<nsIFile> target;
mSrc->GetParent(getter_AddRefs(target));
target->Append(NS_ConvertUCS2toUTF8(*mStrTarget));
target->Append(*mStrTarget);
target->Exists(&flagExists);
if(flagExists)
@ -1194,15 +1193,14 @@ nsInstallFileOpItem::NativeFileOpDirRenameComplete()
nsCOMPtr<nsIFile> target;
mSrc->GetParent(getter_AddRefs(target));
target->Append(NS_ConvertUCS2toUTF8(*mStrTarget));
target->Append(*mStrTarget);
target->Exists(&flagExists);
if(!flagExists)
{
nsCOMPtr<nsIFile> parent;
mSrc->GetParent(getter_AddRefs(parent));
ret = mSrc->MoveTo(parent,
NS_ConvertUCS2toUTF8(*mStrTarget));
ret = mSrc->MoveTo(parent, *mStrTarget);
}
else
return nsInstall::ALREADY_EXISTS;
@ -1221,7 +1219,7 @@ nsInstallFileOpItem::NativeFileOpDirRenameAbort()
{
PRBool flagExists;
PRInt32 ret = nsInstall::SUCCESS;
nsCAutoString leafName;
nsAutoString leafName;
nsCOMPtr<nsIFile> newDirName;
nsCOMPtr<nsIFile> parent;
@ -1229,7 +1227,7 @@ nsInstallFileOpItem::NativeFileOpDirRenameAbort()
if(!flagExists)
{
mSrc->GetParent(getter_AddRefs(newDirName));
newDirName->Append(NS_ConvertUCS2toUTF8(*mStrTarget));
newDirName->Append(*mStrTarget);
mSrc->GetLeafName(leafName);
mSrc->GetParent(getter_AddRefs(parent));
ret = newDirName->MoveTo(parent, leafName);
@ -1260,7 +1258,7 @@ nsInstallFileOpItem::NativeFileOpWindowsShortcutPrepare()
}
else
{
tempVar->Append(NS_LITERAL_CSTRING("NSTestDir"));
tempVar->AppendNative(NS_LITERAL_CSTRING("NSTestDir"));
tempVar->Create(1, 0755);
tempVar->Exists(&flagExists);
if(!flagExists)
@ -1341,7 +1339,7 @@ nsInstallFileOpItem::NativeFileOpWindowsShortcutAbort()
shortcutDescription = *mDescription;
shortcutDescription.Append(NS_LITERAL_STRING(".lnk"));
mShortcutPath->Clone(getter_AddRefs(shortcutTarget));
shortcutTarget->Append(NS_ConvertUCS2toUTF8(shortcutDescription));
shortcutTarget->Append(shortcutDescription);
NativeFileOpFileDeleteComplete(shortcutTarget);
}

Просмотреть файл

@ -183,7 +183,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
if (NS_SUCCEEDED(rv))
{
mFileSpec->Append(INSTALL_PLUGINS_DIR);
mFileSpec->AppendNative(INSTALL_PLUGINS_DIR);
}
else
mFileSpec = nsnull;
@ -286,7 +286,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
if (NS_SUCCEEDED(rv))
{
mFileSpec->Append(INSTALL_COMPONENTS_DIR);
mFileSpec->AppendNative(INSTALL_COMPONENTS_DIR);
}
else
mFileSpec = nsnull;
@ -309,7 +309,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
if (NS_SUCCEEDED(rv))
{
mFileSpec->Append(INSTALL_CHROME_DIR);
mFileSpec->AppendNative(INSTALL_CHROME_DIR);
}
}
break;
@ -528,7 +528,7 @@ nsInstallFolder::AppendXPPath(const nsString& aRelativePath)
start = curr+1;
}
nsresult rv = mFileSpec->Append(NS_ConvertUCS2toUTF8(segment));
nsresult rv = mFileSpec->Append(segment);
if (NS_FAILED(rv))
{
// Unicode converters not present (likely wizard case)
@ -575,27 +575,16 @@ nsInstallFolder::ToString(nsAutoString* outString)
// This will appear to work on Latin-1 charsets but won't work on Mac or other charsets.
// On the other hand doing it right requires intl charset converters
// which we don't yet have in the initial install case.
//
// However, nsLocalFile now uses the native charset conversion implementation, so this
// code should always work.
if (!mFileSpec || !outString)
return NS_ERROR_NULL_POINTER;
nsCAutoString temp;
nsresult rv = mFileSpec->GetPath(temp);
if (NS_SUCCEEDED(rv))
{
outString->Assign(NS_ConvertUTF8toUCS2(temp));
}
else
{
// converters not present, most likely in wizard case;
// do best we can with stock ASCII conversion
// XXX NOTE we can make sure our filenames are ASCII, but we have no
// control over the directory name which might be localized!!!
nsCAutoString temp;
rv = mFileSpec->GetPath(temp);
outString->Assign(NS_ConvertUTF8toUCS2(temp));
}
nsresult rv = mFileSpec->GetPath(*outString);
if (NS_FAILED(rv))
return rv;
PRBool flagIsFile;
mFileSpec->IsFile(&flagIsFile);

Просмотреть файл

@ -176,7 +176,7 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
mVersionInfo->Init(inVInfo);
if(! inPartialPath.IsEmpty())
mTargetFile->Append(NS_ConvertUCS2toUTF8(inPartialPath));
mTargetFile->Append(inPartialPath);
}
nsInstallPatch::~nsInstallPatch()
@ -416,7 +416,7 @@ nsInstallPatch::NativePatch(nsIFile *sourceFile, nsIFile *patchFile, nsIFile **n
nsCOMPtr<nsILocalFile> patchFileLocal = do_QueryInterface(patchFile, &rv);
nsCAutoString realfile;
sourceFile->GetPath(realfile);
sourceFile->GetNativePath(realfile);
sourceFile->Clone(getter_AddRefs(outFileSpec));
@ -450,11 +450,10 @@ nsInstallPatch::NativePatch(nsIFile *sourceFile, nsIFile *patchFile, nsIFile **n
if (( dd->bWin32BoundImage || dd->bMacAppleSingle) && (status == GDIFF_OK ))
{
// make an unique tmp file (FILENAME-src.EXT)
nsCAutoString leafName;
rv = sourceFile->GetLeafName(leafName);
nsAutoString tmpFileName;
rv = sourceFile->GetLeafName(tmpFileName);
NS_NAMED_LITERAL_STRING(tmpName, "-src");
NS_ConvertUTF8toUCS2 tmpFileName(leafName);
PRInt32 i;
if ((i = tmpFileName.RFindChar('.')) > 0)
@ -471,25 +470,22 @@ nsInstallPatch::NativePatch(nsIFile *sourceFile, nsIFile *patchFile, nsIFile **n
rv = sourceFile->Clone(getter_AddRefs(tempSrcFile)); //Clone the sourceFile
tempSrcFile->SetLeafName(NS_ConvertUCS2toUTF8(tmpFileName)); //Append the new leafname
tempSrcFile->SetLeafName(tmpFileName); //Append the new leafname
uniqueSrcFile = do_QueryInterface(tempSrcFile, &rv); //Create an nsILocalFile version to pass to MakeUnique
MakeUnique(uniqueSrcFile);
nsCAutoString realfile;
sourceFile->GetPath(realfile);
sourceFile->GetNativePath(realfile);
#ifdef WIN32
nsCAutoString nativeFile;
sourceFile->GetNativePath(nativeFile);
// unbind Win32 images
nsCAutoString unboundFile;
uniqueSrcFile->GetNativePath(unboundFile);
if (su_unbind((char*)nativeFile.get(), (char*)unboundFile.get())) //
if (su_unbind((char*)realfile.get(), (char*)unboundFile.get())) //
{
uniqueSrcFile->GetPath(realfile);
realfile = unboundFile;
}
else
{
@ -509,7 +505,7 @@ nsInstallPatch::NativePatch(nsIFile *sourceFile, nsIFile *patchFile, nsIFile **n
if (status == noErr)
{
// set
tempSrcFile->GetPath(realfile);
tempSrcFile->GetNativePath(realfile);
}
#endif
}
@ -518,15 +514,15 @@ nsInstallPatch::NativePatch(nsIFile *sourceFile, nsIFile *patchFile, nsIFile **n
goto cleanup;
// make a unique file at the same location of our source file (FILENAME-ptch.EXT)
NS_NAMED_LITERAL_CSTRING(patchFileName, "-ptch");
nsCAutoString newFileName;
NS_NAMED_LITERAL_STRING(patchFileName, "-ptch");
nsAutoString newFileName;
sourceFile->GetLeafName(newFileName);
PRInt32 index;
if ((index = newFileName.RFindChar('.')) > 0)
{
nsCAutoString extention;
nsCAutoString fileName;
nsAutoString extention;
nsAutoString fileName;
newFileName.Right(extention, (newFileName.Length() - index) );
newFileName.Left(fileName, (newFileName.Length() - (newFileName.Length() - index)));
newFileName = fileName + patchFileName + extention;
@ -547,7 +543,7 @@ nsInstallPatch::NativePatch(nsIFile *sourceFile, nsIFile *patchFile, nsIFile **n
//dd->fSrc = PR_Open ( realfile, PR_RDONLY, 0666);
//dd->fOut = PR_Open ( outFile, PR_RDWR|PR_CREATE_FILE|PR_TRUNCATE, 0666);
nsCOMPtr<nsILocalFile> realFileLocal = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);;
realFileLocal->InitWithPath(realfile);
realFileLocal->InitWithNativePath(realfile);
realFileLocal->OpenNSPRFileDesc(PR_RDONLY, 0666, &dd->fSrc);
outFileLocal->OpenNSPRFileDesc(PR_RDWR|PR_CREATE_FILE|PR_TRUNCATE, 0666, &dd->fOut);
@ -627,7 +623,7 @@ nsInstallPatch::NativePatch(nsIFile *sourceFile, nsIFile *patchFile, nsIFile **n
outFileSpec->Remove(PR_FALSE);
nsCAutoString leaf;
nsAutoString leaf;
anotherName->GetLeafName(leaf);
anotherName->CopyTo(parent, leaf);

Просмотреть файл

@ -1163,15 +1163,15 @@ InstallFileOpFileWindowsShortcut(JSContext *cx, JSObject *obj, uintN argc, jsval
ConvertJSValToStr(b0, cx, argv[0]);
NS_NewLocalFile(NS_ConvertUCS2toUTF8(b0), PR_TRUE, getter_AddRefs(nsfsB0));
NS_NewLocalFile(b0, PR_TRUE, getter_AddRefs(nsfsB0));
ConvertJSValToStr(b1, cx, argv[1]);
NS_NewLocalFile(NS_ConvertUCS2toUTF8(b1), PR_TRUE, getter_AddRefs(nsfsB1));
NS_NewLocalFile(b1, PR_TRUE, getter_AddRefs(nsfsB1));
ConvertJSValToStr(b2, cx, argv[2]);
ConvertJSValToStr(b3, cx, argv[3]);
NS_NewLocalFile(NS_ConvertUCS2toUTF8(b3), PR_TRUE, getter_AddRefs(nsfsB3));
NS_NewLocalFile(b3, PR_TRUE, getter_AddRefs(nsfsB3));
ConvertJSValToStr(b4, cx, argv[4]);
ConvertJSValToStr(b5, cx, argv[5]);
NS_NewLocalFile(NS_ConvertUCS2toUTF8(b5), PR_TRUE, getter_AddRefs(nsfsB5));
NS_NewLocalFile(b5, PR_TRUE, getter_AddRefs(nsfsB5));
if(JSVAL_IS_NULL(argv[6]))
{
@ -1273,7 +1273,7 @@ InstallFileOpFileMacAlias(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
}
ConvertJSValToStr(sourceLeaf, cx, argv[1]);
rv1 = iFileSource->Append(NS_ConvertUCS2toUTF8(sourceLeaf));
rv1 = iFileSource->Append(sourceLeaf);
// public int FileMacAlias( InstallFolder aSourceFolder,
// String aSourceFileName,
@ -1298,7 +1298,7 @@ InstallFileOpFileMacAlias(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
aliasLeaf.Append(NS_LITERAL_STRING(" alias")); // XXX use GetResourcedString(id)
}
rv2 = iFileAlias->Append(NS_ConvertUCS2toUTF8(aliasLeaf));
rv2 = iFileAlias->Append(aliasLeaf);
if (NS_FAILED(rv1) || NS_FAILED(rv2))
{
*rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);

Просмотреть файл

@ -285,7 +285,7 @@ PRInt32 nsRegisterItem::Complete()
if (NS_SUCCEEDED(rv))
{
tmp->Append(INSTALL_CHROME_DIR);
tmp->AppendNative(INSTALL_CHROME_DIR);
}
}
nsCOMPtr<nsILocalFile> startupFile( do_QueryInterface(tmp, &rv) );
@ -297,7 +297,7 @@ PRInt32 nsRegisterItem::Complete()
rv = startupFile->Create(nsIFile::DIRECTORY_TYPE, 0755);
if (NS_SUCCEEDED(rv))
{
rv = startupFile->Append(NS_LITERAL_CSTRING("installed-chrome.txt"));
rv = startupFile->AppendNative(NS_LITERAL_CSTRING("installed-chrome.txt"));
if (NS_SUCCEEDED(rv))
{
rv = startupFile->OpenNSPRFileDesc(

Просмотреть файл

@ -204,7 +204,7 @@ nsSoftwareUpdate::Shutdown()
nsCOMPtr<nsIFile> tmp;
rv = nsSoftwareUpdate::GetProgramDirectory()->Clone(getter_AddRefs(tmp));
#if defined (XP_MAC)
tmp->Append(ESSENTIAL_FILES);
tmp->AppendNative(ESSENTIAL_FILES);
#endif
pathToCleanupUtility = do_QueryInterface(tmp);
@ -219,7 +219,7 @@ nsSoftwareUpdate::Shutdown()
NS_ASSERTION(pathToCleanupUtility,"No path to cleanup utility in nsSoftwareUpdate::Shutdown()");
//Create the Process framework
pathToCleanupUtility->Append(CLEANUP_UTIL);
pathToCleanupUtility->AppendNative(CLEANUP_UTIL);
nsCOMPtr<nsIProcess> cleanupProcess = do_CreateInstance(kIProcessCID);
rv = cleanupProcess->Init(pathToCleanupUtility);
if (NS_SUCCEEDED(rv))

Просмотреть файл

@ -746,7 +746,7 @@ nsXPInstallManager::GetDestinationFile(nsString& url, nsILocalFile* *file)
if (NS_SUCCEEDED(rv))
{
userChrome->Append(NS_ConvertUCS2toUTF8(leaf));
userChrome->Append(leaf);
MakeUnique(userChrome);
*file = userChrome;
NS_IF_ADDREF(*file);