making string conversions explicit

This commit is contained in:
scc%netscape.com 2000-04-18 05:38:58 +00:00
parent 76a839c993
commit 6f10e8a3a9
20 changed files with 128 additions and 127 deletions

View File

@ -148,15 +148,15 @@ nsInstall::nsInstall(nsIZipReader * theJARFile)
mScriptObject = nsnull; // this is the jsobject for our context
mVersionInfo = nsnull; // this is the version information passed to us in StartInstall()
mInstalledFiles = nsnull; // the list of installed objects
mRegistryPackageName = ""; // this is the name that we will add into the registry for the component we are installing
mUIName = ""; // this is the name that will be displayed in UI.
// mRegistryPackageName = ""; // this is the name that we will add into the registry for the component we are installing
// mUIName = ""; // this is the name that will be displayed in UI.
mPatchList = nsnull;
mUninstallPackage = PR_FALSE;
mRegisterPackage = PR_FALSE;
mStatusSent = PR_FALSE;
mStartInstallCompleted = PR_FALSE;
mJarFileLocation = "";
mInstallArguments = "";
// mInstallArguments = "";
mPackageFolder = nsnull;
// mJarFileData is an opaque handle to the jarfile.
@ -292,7 +292,7 @@ nsInstall::AddDirectory(const nsString& aRegName,
nsInstallFile* ie = nsnull;
PRInt32 result;
if ( aJarSource.Equals("") || aFolder == nsnull )
if ( aJarSource.IsEmpty() || aFolder == nsnull )
{
*aReturn = SaveError(nsInstall::INVALID_ARGUMENTS);
return NS_OK;
@ -308,7 +308,7 @@ nsInstall::AddDirectory(const nsString& aRegName,
nsString qualifiedRegName;
if ( aRegName.Equals(""))
if ( aRegName.IsEmpty())
{
// Default subName = location in jar file
*aReturn = GetQualifiedRegName( aJarSource, qualifiedRegName);
@ -340,7 +340,7 @@ nsInstall::AddDirectory(const nsString& aRegName,
if (!subdirectory.IsEmpty())
{
subdirectory.Append("/");
subdirectory.AppendWithConversion("/");
}
@ -372,11 +372,11 @@ nsInstall::AddDirectory(const nsString& aRegName,
nsString *thisPath = (nsString *)paths->ElementAt(i);
nsString newJarSource = aJarSource;
newJarSource += "/";
newJarSource.AppendWithConversion("/");
newJarSource += *thisPath;
nsString fullRegName = qualifiedRegName;
fullRegName += "/";
fullRegName.AppendWithConversion("/");
fullRegName += *thisPath;
@ -446,7 +446,7 @@ nsInstall::AddDirectory(const nsString& aRegName,
PRInt32* aReturn)
{
return AddDirectory(aRegName,
"",
nsAutoString(),
aJarSource,
aFolder,
aSubdir,
@ -464,11 +464,11 @@ nsInstall::AddDirectory(const nsString& aJarSource,
return NS_OK;
}
return AddDirectory("",
"",
return AddDirectory(nsAutoString(),
nsAutoString(),
aJarSource,
mPackageFolder,
"",
nsAutoString(),
INSTALL_NO_COMPARE,
aReturn);
}
@ -490,7 +490,7 @@ nsInstall::AddSubcomponent(const nsString& aRegName,
PRInt32 errcode = nsInstall::SUCCESS;
if(aJarSource.Equals("") || aFolder == nsnull )
if(aJarSource.IsEmpty() || aFolder == nsnull )
{
*aReturn = SaveError( nsInstall::INVALID_ARGUMENTS );
return NS_OK;
@ -510,14 +510,14 @@ nsInstall::AddSubcomponent(const nsString& aRegName,
return NS_OK;
}
if( aTargetName.Equals("") )
if( aTargetName.IsEmpty() )
tempTargetName = aJarSource;
if (qualifiedVersion.IsEmpty())
qualifiedVersion.Assign("0.0.0.0");
qualifiedVersion.AssignWithConversion("0.0.0.0");
if ( aRegName.Equals("") )
if ( aRegName.IsEmpty() )
{
// Default subName = location in jar file
*aReturn = GetQualifiedRegName( aJarSource, qualifiedRegName);
@ -637,11 +637,11 @@ nsInstall::AddSubcomponent(const nsString& aJarSource,
return NS_OK;
}
return AddSubcomponent("",
return AddSubcomponent(nsAutoString(),
version,
aJarSource,
mPackageFolder,
"",
nsAutoString(),
INSTALL_NO_COMPARE,
aReturn);
}
@ -767,7 +767,7 @@ nsInstall::Execute(const nsString& aJarSource, const nsString& aArgs, PRInt32* a
PRInt32
nsInstall::Execute(const nsString& aJarSource, PRInt32* aReturn)
{
return Execute(aJarSource, "", aReturn);
return Execute(aJarSource, nsAutoString(), aReturn);
}
PRInt32
@ -845,7 +845,7 @@ nsInstall::FinalizeInstall(PRInt32* aReturn)
char *objString = ie->toString();
if (objString)
{
mNotifier->FinalizeProgress(nsAutoString(objString).GetUnicode(),
mNotifier->FinalizeProgress(NS_ConvertASCIItoUCS2(objString).GetUnicode(),
(i+1), mInstalledFiles->Count());
delete [] objString;
}
@ -973,7 +973,7 @@ nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aS
{
int i;
nsString dirStr(dir);
nsString dirStr; dirStr.AssignWithConversion(dir);
if ( (i = dirStr.RFindChar(FILESEP)) > 0 )
{
// i is the index in the string, not the total number of
@ -996,7 +996,7 @@ nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aS
if(*dir != '\0')
{
*aNewFolder = new nsInstallFolder(dir, aSubdirectory);
*aNewFolder = new nsInstallFolder(NS_ConvertASCIItoUCS2(dir), aSubdirectory);
}
if (componentCString)
@ -1008,7 +1008,7 @@ nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aS
PRInt32
nsInstall::GetComponentFolder(const nsString& aComponentName, nsInstallFolder** aNewFolder)
{
return GetComponentFolder(aComponentName, "", aNewFolder);
return GetComponentFolder(aComponentName, nsAutoString(), aNewFolder);
}
PRInt32
@ -1031,7 +1031,7 @@ PRInt32
nsInstall::GetFolder(const nsString& targetFolder, nsInstallFolder** aNewFolder)
{
/* This version of GetFolder takes an nsString object as the only param */
return GetFolder(targetFolder, "", aNewFolder);
return GetFolder(targetFolder, nsAutoString(), aNewFolder);
}
PRInt32
@ -1328,7 +1328,7 @@ nsInstall::Patch(const nsString& aRegName, const nsString& aVersion, const nsStr
PRInt32
nsInstall::Patch(const nsString& aRegName, const nsString& aJarSource, nsInstallFolder* aFolder, const nsString& aTargetName, PRInt32* aReturn)
{
return Patch(aRegName, "", aJarSource, aFolder, aTargetName, aReturn);
return Patch(aRegName, nsAutoString(), aJarSource, aFolder, aTargetName, aReturn);
}
PRInt32
@ -1344,7 +1344,7 @@ nsInstall::SetPackageFolder(nsInstallFolder& aFolder)
if (mPackageFolder)
delete mPackageFolder;
mPackageFolder = new nsInstallFolder(aFolder, "");
mPackageFolder = new nsInstallFolder(aFolder, nsAutoString());
return NS_OK;
}
@ -1387,7 +1387,7 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aRegis
if(REGERR_OK == VR_GetDefaultDirectory(szRegPackageName, MAXREGPATHLEN, szRegPackagePath))
{
mPackageFolder = new nsInstallFolder(szRegPackagePath, "");
mPackageFolder = new nsInstallFolder(NS_ConvertASCIItoUCS2(szRegPackagePath), nsAutoString());
}
else
{
@ -2002,7 +2002,7 @@ nsInstall::ScheduleForInstall(nsInstallObject* ob)
// flash current item
if (mNotifier)
mNotifier->ItemScheduled(nsAutoString(objString).GetUnicode());
mNotifier->ItemScheduled(NS_ConvertASCIItoUCS2(objString).GetUnicode());
// do any unpacking or other set-up
@ -2025,12 +2025,12 @@ nsInstall::ScheduleForInstall(nsInstallObject* ob)
else if ( mNotifier )
{
// error in preparation step -- log it
char* errRsrc = GetResourcedString("ERROR");
char* errRsrc = GetResourcedString(NS_ConvertASCIItoUCS2("ERROR"));
if (errRsrc)
{
char* errprefix = PR_smprintf("%s (%d): ", errRsrc, error);
nsString errstr = errprefix;
errstr += objString;
nsString errstr; errstr.AssignWithConversion(errprefix);
errstr.AppendWithConversion(objString);
mNotifier->LogComment( errstr.GetUnicode() );
@ -2082,7 +2082,7 @@ nsInstall::GetQualifiedPackageName( const nsString& name, nsString& qualifiedNam
nsString startOfName;
name.Left(startOfName, 7);
if ( startOfName.Equals( "=USER=/") )
if ( startOfName.EqualsWithConversion( "=USER=/") )
{
CurrentUserNode(qualifiedName);
qualifiedName += name;
@ -2124,7 +2124,7 @@ nsInstall::GetQualifiedRegName(const nsString& name, nsString& qualifiedRegName
nsString usr ();
if ( startOfName.Equals("=COMM=/") || startOfName.Equals("=USER=/"))
if ( startOfName.EqualsWithConversion("=COMM=/") || startOfName.EqualsWithConversion("=USER=/"))
{
qualifiedRegName = name;
qualifiedRegName.Cut( 0, 7 );
@ -2134,7 +2134,7 @@ nsInstall::GetQualifiedRegName(const nsString& name, nsString& qualifiedRegName
if (!mRegistryPackageName.IsEmpty())
{
qualifiedRegName = mRegistryPackageName;
qualifiedRegName += "/";
qualifiedRegName.AppendWithConversion("/");
qualifiedRegName += name;
}
else
@ -2187,11 +2187,11 @@ nsInstall::CurrentUserNode(nsString& userRegNode)
profname = NULL;
}
userRegNode = "/Netscape/Users/";
userRegNode.AssignWithConversion("/Netscape/Users/");
if (profname != nsnull)
{
userRegNode += nsString(profname);
userRegNode += "/";
userRegNode.AppendWithConversion(profname);
userRegNode.AppendWithConversion("/");
PR_FREEIF(profname);
}
}
@ -2266,7 +2266,7 @@ nsInstall::CleanUp(void)
mPackageFolder = nsnull;
}
mRegistryPackageName = ""; // used to see if StartInstall() has been called
mRegistryPackageName.SetLength(0); // used to see if StartInstall() has been called
mStartInstallCompleted = PR_FALSE;
}
@ -2274,7 +2274,7 @@ nsInstall::CleanUp(void)
void
nsInstall::GetJarFileLocation(nsString& aFile)
{
aFile = mJarFileLocation.GetCString();
aFile.AssignWithConversion(mJarFileLocation.GetCString());
}
void
@ -2339,7 +2339,7 @@ nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedNa
if (aSuggestedName == nsnull)
{
nsSpecialSystemDirectory tempFile(nsSpecialSystemDirectory::OS_TemporaryDirectory);
nsString tempFileName = "xpinstall";
nsString tempFileName; tempFileName.AssignWithConversion("xpinstall");
// Get the extension of the file in the JAR
extpos = aJarfile.RFindChar('.');
@ -2436,7 +2436,7 @@ nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedNa
char*
nsInstall::GetResourcedString(const nsString& aResName)
{
nsString rscdStr = "";
nsString rscdStr;
PRBool bStrBdlSuccess = PR_FALSE;
if (mStringBundle)
@ -2459,7 +2459,7 @@ nsInstall::GetResourcedString(const nsString& aResName)
if (!bStrBdlSuccess)
{
char *cResName = aResName.ToNewCString();
rscdStr = nsInstallResources::GetDefaultVal(cResName);
rscdStr.AssignWithConversion(nsInstallResources::GetDefaultVal(cResName));
if (cResName)
Recycle(cResName);
}
@ -2478,7 +2478,7 @@ nsInstall::ExtractDirEntries(const nsString& directory, nsVoidArray *paths)
if ( paths )
{
nsString pattern(directory);
pattern += "/*";
pattern.AppendWithConversion("/*");
PRInt32 prefix_length = directory.Length()+1; // account for slash
nsresult rv = mJarFileData->FindEntries( nsAutoCString(pattern), &jarEnum );
@ -2504,7 +2504,8 @@ nsInstall::ExtractDirEntries(const nsString& directory, nsVoidArray *paths)
if ( buf[namelen-1] != '/' )
{
// XXX manipulation should be in caller
paths->AppendElement( new nsString(buf+prefix_length) );
nsString* tempString = new nsString; tempString->AssignWithConversion(buf+prefix_length);
paths->AppendElement(tempString);
}
PR_FREEIF( buf );

View File

@ -55,7 +55,6 @@ nsInstallDelete::nsInstallDelete( nsInstall* inInstall,
mDeleteStatus = DELETE_FILE;
mFinalFile = nsnull;
mRegistryName = "";
nsFileSpec* tmp = folderSpec->GetFileSpec();
if (!tmp)
@ -158,7 +157,7 @@ char* nsInstallDelete::toString()
if (mDeleteStatus == DELETE_COMPONENT)
{
char* temp = mRegistryName.ToNewCString();
rsrcVal = mInstall->GetResourcedString("DeleteComponent");
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("DeleteComponent"));
if (rsrcVal)
{
@ -172,7 +171,7 @@ char* nsInstallDelete::toString()
{
if (mFinalFile)
{
rsrcVal = mInstall->GetResourcedString("DeleteComponent");
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("DeleteComponent"));
if (rsrcVal)
{

View File

@ -48,7 +48,7 @@ nsInstallExecute:: nsInstallExecute( nsInstall* inInstall,
{
MOZ_COUNT_CTOR(nsInstallExecute);
if ((inInstall == nsnull) || (inJarLocation.Equals("")) )
if ((inInstall == nsnull) || (inJarLocation.IsEmpty()) )
{
*error = nsInstall::INVALID_ARGUMENTS;
return;
@ -73,7 +73,7 @@ nsInstallExecute::~nsInstallExecute()
PRInt32 nsInstallExecute::Prepare()
{
if (mInstall == NULL || mJarLocation.Equals(""))
if (mInstall == NULL || mJarLocation.IsEmpty())
return nsInstall::INVALID_ARGUMENTS;
return mInstall->ExtractFileFromJar(mJarLocation, nsnull, &mExecutableFile);
@ -120,7 +120,7 @@ char* nsInstallExecute::toString()
if (mExecutableFile == nsnull)
{
char *tempString = mJarLocation.ToNewCString();
rsrcVal = mInstall->GetResourcedString("Execute");
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("Execute"));
if (rsrcVal)
{
@ -133,7 +133,7 @@ char* nsInstallExecute::toString()
}
else
{
rsrcVal = mInstall->GetResourcedString("Execute");
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("Execute"));
if (rsrcVal)
{

View File

@ -207,7 +207,7 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall,
}
else
{
mChildFile = mVersionRegistryName->Equals( regPackageName,
mChildFile = mVersionRegistryName->EqualsWithConversion( regPackageName,
PR_FALSE,
regPackageName.Length() );
}
@ -299,15 +299,15 @@ char* nsInstallFile::toString()
if (mReplaceFile)
{
rsrcVal = mInstall->GetResourcedString("ReplaceFile");
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("ReplaceFile"));
}
else if (mSkipInstall)
{
rsrcVal = mInstall->GetResourcedString("SkipFile");
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("SkipFile"));
}
else
{
rsrcVal = mInstall->GetResourcedString("InstallFile");
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("InstallFile"));
}
if (rsrcVal)

View File

@ -301,70 +301,72 @@ char* nsInstallFileOpItem::toString()
// XXX these hardcoded strings should be replaced by nsInstall::GetResourcedString(id)
// STRING USE WARNING: perhaps |result| should be an |nsCAutoString| to avoid all this double converting
switch(mCommand)
{
case NS_FOP_FILE_COPY:
result = "Copy File: ";
result.Append(mSrc->GetNativePathCString());
result.Append(" to ");
result.Append(mTarget->GetNativePathCString());
result.AssignWithConversion("Copy File: ");
result.AppendWithConversion(mSrc->GetNativePathCString());
result.AppendWithConversion(" to ");
result.AppendWithConversion(mTarget->GetNativePathCString());
resultCString = result.ToNewCString();
break;
case NS_FOP_FILE_DELETE:
result = "Delete File: ";
result.Append(mTarget->GetNativePathCString());
result.AssignWithConversion("Delete File: ");
result.AppendWithConversion(mTarget->GetNativePathCString());
resultCString = result.ToNewCString();
break;
case NS_FOP_FILE_EXECUTE:
result = "Execute File: ";
result.Append(mTarget->GetNativePathCString());
result.Append(" ");
result.AssignWithConversion("Execute File: ");
result.AppendWithConversion(mTarget->GetNativePathCString());
result.AppendWithConversion(" ");
result.Append(*mParams);
resultCString = result.ToNewCString();
break;
case NS_FOP_FILE_MOVE:
result = "Move File: ";
result.Append(mSrc->GetNativePathCString());
result.Append(" to ");
result.Append(mTarget->GetNativePathCString());
result.AssignWithConversion("Move File: ");
result.AppendWithConversion(mSrc->GetNativePathCString());
result.AppendWithConversion(" to ");
result.AppendWithConversion(mTarget->GetNativePathCString());
resultCString = result.ToNewCString();
break;
case NS_FOP_FILE_RENAME:
result = "Rename File: ";
result.AssignWithConversion("Rename File: ");
result.Append(*mStrTarget);
resultCString = result.ToNewCString();
break;
case NS_FOP_DIR_CREATE:
result = "Create Folder: ";
result.Append(mTarget->GetNativePathCString());
result.AssignWithConversion("Create Folder: ");
result.AppendWithConversion(mTarget->GetNativePathCString());
resultCString = result.ToNewCString();
break;
case NS_FOP_DIR_REMOVE:
result = "Remove Folder: ";
result.Append(mTarget->GetNativePathCString());
result.AssignWithConversion("Remove Folder: ");
result.AppendWithConversion(mTarget->GetNativePathCString());
resultCString = result.ToNewCString();
break;
case NS_FOP_DIR_RENAME:
result = "Rename Dir: ";
result.AssignWithConversion("Rename Dir: ");
result.Append(*mStrTarget);
resultCString = result.ToNewCString();
break;
case NS_FOP_WIN_SHORTCUT:
result = "Windows Shortcut: ";
result.Append(*mShortcutPath);
result.Append("\\");
result.AssignWithConversion("Windows Shortcut: ");
result.AppendWithConversion(*mShortcutPath);
result.AppendWithConversion("\\");
result.Append(*mDescription);
resultCString = result.ToNewCString();
break;
case NS_FOP_MAC_ALIAS:
result = "Mac Alias: ";
result.Append(mSrc->GetCString());
result.AssignWithConversion("Mac Alias: ");
result.AppendWithConversion(mSrc->GetCString());
resultCString = result.ToNewCString();
break;
case NS_FOP_UNIX_LINK:
break;
default:
result = "Unkown file operation command!";
result.AssignWithConversion("Unkown file operation command!");
resultCString = result.ToNewCString();
break;
}

View File

@ -86,7 +86,7 @@ MOZ_DECL_CTOR_COUNTER(nsInstallFolder);
nsInstallFolder::nsInstallFolder(const nsString& aFolderID)
{
nsInstallFolder( aFolderID, "" );
nsInstallFolder( aFolderID, nsAutoString() );
}
nsInstallFolder::nsInstallFolder(const nsString& aFolderID, const nsString& aRelativePath)
@ -121,7 +121,7 @@ nsInstallFolder::nsInstallFolder(const nsString& aFolderID, const nsString& aRel
nsString morePath(aRelativePath);
if ( morePath.Last() != '/' || morePath.Last() != '\\' )
morePath += '/';
morePath.AppendWithConversion('/');
*mFileSpec += morePath;
}
@ -160,17 +160,17 @@ nsInstallFolder::~nsInstallFolder()
void
nsInstallFolder::GetDirectoryPath(nsString& aDirectoryPath)
{
aDirectoryPath = "";
aDirectoryPath.SetLength(0);
if (mFileSpec != nsnull)
{
// We want the a NATIVE path.
aDirectoryPath.Assign(mFileSpec->GetCString());
aDirectoryPath.AssignWithConversion(mFileSpec->GetCString());
if (mFileSpec->IsDirectory())
{
if (aDirectoryPath.Last() != FILESEP)
aDirectoryPath.Append(FILESEP);
aDirectoryPath.AppendWithConversion(FILESEP);
}
}
}
@ -404,7 +404,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe
nsString tempPath(aRelativePath);
if (aRelativePath.Last() != '/' || aRelativePath.Last() != '\\')
tempPath += '/';
tempPath.AppendWithConversion('/');
*mFileSpec += tempPath;
}
@ -424,7 +424,7 @@ nsInstallFolder::MapNameToEnum(const nsString& name)
{
int i = 0;
if ( name.Equals(""))
if ( name.IsEmpty())
return -1;
while ( DirectoryTable[i].directoryName[0] != 0 )
@ -462,6 +462,6 @@ nsInstallFolder::ToString(nsAutoString* outString)
//XXX: May need to fix. Native charset paths will be converted into Unicode when the get to JS
// This will appear to work on Latin-1 charsets but won't work on Mac or other charsets.
*outString = mFileSpec->GetCString();
outString->AssignWithConversion( mFileSpec->GetCString() );
return NS_OK;
}

View File

@ -89,7 +89,7 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
*error = nsInstall::NO_SUCH_COMPONENT;
return;
}
nsString folderSpec(tempTargetFile);
nsString folderSpec; folderSpec.AssignWithConversion(tempTargetFile);
mPatchFile = nsnull;
mTargetFile = nsnull;
@ -124,7 +124,7 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
{
MOZ_COUNT_CTOR(nsInstallPatch);
if ((inInstall == nsnull) || (inVRName.Equals("")) || (inJarLocation.Equals("")))
if ((inInstall == nsnull) || (inVRName.IsEmpty()) || (inJarLocation.IsEmpty()))
{
*error = nsInstall::INVALID_ARGUMENTS;
return;
@ -157,7 +157,7 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall,
mVersionInfo->Init(inVInfo);
if(! inPartialPath.Equals(""))
if(! inPartialPath.IsEmpty())
*mTargetFile += inPartialPath;
}
@ -343,7 +343,7 @@ char* nsInstallPatch::toString()
if (mTargetFile != nsnull)
{
rsrcVal = mInstall->GetResourcedString("Patch");
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("Patch"));
if (rsrcVal)
{
@ -417,8 +417,8 @@ nsInstallPatch::NativePatch(const nsFileSpec &sourceFile, const nsFileSpec &patc
{
// make an unique tmp file (FILENAME-src.EXT)
*tempSrcFile = sourceFile;
nsString tmpName = "-src";
nsString tmpFileName = sourceFile.GetLeafName();
nsString tmpName; tmpName.AssignWithConversion("-src");
nsString tmpFileName; tmpFileName.AssignWithConversion(sourceFile.GetLeafName());
PRInt32 i;
if ((i = tmpFileName.RFindChar('.')) > 0)
@ -471,8 +471,8 @@ nsInstallPatch::NativePatch(const nsFileSpec &sourceFile, const nsFileSpec &patc
goto cleanup;
// make a unique file at the same location of our source file (FILENAME-ptch.EXT)
nsString patchFileName = "-ptch";
nsString newFileName = sourceFile.GetLeafName();
nsString patchFileName; patchFileName.AssignWithConversion("-ptch");
nsString newFileName; newFileName.AssignWithConversion(sourceFile.GetLeafName());
PRInt32 index;
if ((index = newFileName.RFindChar('.')) > 0)

View File

@ -217,7 +217,7 @@ nsInstallProgressDialog::SetActionText(const PRUnichar * aActionText)
PRInt32 offset = (len/2) - ((len - maxChars)/2);
PRInt32 count = (len - maxChars);
theMessage.Cut(offset, count);
theMessage.Insert(nsString("..."), offset);
theMessage.Insert(NS_ConvertASCIItoUCS2("..."), offset);
}
return setDlgAttribute( "dialog.currentAction", "value", theMessage );
@ -238,7 +238,7 @@ nsInstallProgressDialog::SetProgress(PRInt32 aValue, PRInt32 aMax, char mode)
previousMax = aMax;
PR_snprintf( buf, sizeof buf, "%lu", aMax );
rv = setDlgAttribute( "dialog.progress", "max", buf );
rv = setDlgAttribute( "dialog.progress", "max", NS_ConvertASCIItoUCS2(buf) );
}
//I use this modeFlag business so I don't have to send
@ -247,9 +247,9 @@ nsInstallProgressDialog::SetProgress(PRInt32 aValue, PRInt32 aMax, char mode)
{
modeFlag = mode;
if ( modeFlag == 'n' )
rv = setDlgAttribute( "dialog.progress", "mode", "normal");
rv = setDlgAttribute( "dialog.progress", "mode", NS_ConvertASCIItoUCS2("normal"));
else
rv = setDlgAttribute( "dialog.progress", "mode", "undetermined");
rv = setDlgAttribute( "dialog.progress", "mode", NS_ConvertASCIItoUCS2("undetermined"));
}
if ( NS_SUCCEEDED(rv))
@ -259,7 +259,7 @@ nsInstallProgressDialog::SetProgress(PRInt32 aValue, PRInt32 aMax, char mode)
else
PR_snprintf( buf, sizeof buf, "%lu", 0 );
rv = setDlgAttribute( "dialog.progress", "value", buf );
rv = setDlgAttribute( "dialog.progress", "value", NS_ConvertASCIItoUCS2(buf) );
}
return rv;
}
@ -270,7 +270,7 @@ nsInstallProgressDialog::StartInstallPhase()
nsresult rv = NS_OK;
// don't care if this fails
setDlgAttribute("dialog.cancel", "disabled", nsString("true"));
setDlgAttribute("dialog.cancel", "disabled", NS_ConvertASCIItoUCS2("true"));
return rv;
}
@ -303,10 +303,10 @@ nsresult nsInstallProgressDialog::setDlgAttribute( const char *id,
if ( mDocument ) {
// Find specified element.
nsCOMPtr<nsIDOMElement> elem;
rv = mDocument->GetElementById( id, getter_AddRefs( elem ) );
rv = mDocument->GetElementById( NS_ConvertASCIItoUCS2(id), getter_AddRefs( elem ) );
if ( elem ) {
// Set the text attribute.
rv = elem->SetAttribute( name, value );
rv = elem->SetAttribute( NS_ConvertASCIItoUCS2(name), value );
if ( NS_SUCCEEDED( rv ) ) {
} else {
DEBUG_PRINTF( PR_STDOUT, "%s %d: SetAttribute failed, rv=0x%X\n",
@ -343,10 +343,10 @@ nsresult nsInstallProgressDialog::getDlgAttribute( const char *id,
if ( mDocument ) {
// Find specified element.
nsCOMPtr<nsIDOMElement> elem;
rv = mDocument->GetElementById( id, getter_AddRefs( elem ) );
rv = mDocument->GetElementById( NS_ConvertASCIItoUCS2(id), getter_AddRefs( elem ) );
if ( elem ) {
// Set the text attribute.
rv = elem->GetAttribute( name, value );
rv = elem->GetAttribute( NS_ConvertASCIItoUCS2(name), value );
if ( NS_SUCCEEDED( rv ) ) {
} else {
DEBUG_PRINTF( PR_STDOUT, "%s %d: GetAttribute failed, rv=0x%X\n",

View File

@ -451,7 +451,7 @@ nsInstallTrigger::CreateTempFileFromURL(const nsString& aURL, nsString& tempFile
if ( aURL.EqualsIgnoreCase("file:/", 6) )
{
tempFileString.Assign( nsNSPRPath(nsFileURL(aURL)) );
tempFileString.AssignWithConversion( NS_STATIC_CAST(const char*, nsNSPRPath(nsFileURL(aURL))) );
}
else
{
@ -482,7 +482,7 @@ nsInstallTrigger::CreateTempFileFromURL(const nsString& aURL, nsString& tempFile
tempFile.MakeUnique();
tempFileString.Assign( nsNSPRPath( nsFilePath(tempFile) ) );
tempFileString.AssignWithConversion( NS_STATIC_CAST(const char*, nsNSPRPath( nsFilePath(tempFile) )) );
}
}

View File

@ -44,7 +44,7 @@ nsInstallUninstall::nsInstallUninstall( nsInstall* inInstall,
{
MOZ_COUNT_CTOR(nsInstallUninstall);
if (regName.Equals(""))
if (regName.IsEmpty())
{
*error = nsInstall::INVALID_ARGUMENTS;
return;
@ -57,7 +57,7 @@ nsInstallUninstall::nsInstallUninstall( nsInstall* inInstall,
userName,
MAXREGPATHLEN );
mUIName.Assign(userName);
mUIName.AssignWithConversion(userName);
if (err != REGERR_OK)
{
@ -108,7 +108,7 @@ char* nsInstallUninstall::toString()
if (temp)
{
rsrcVal = mInstall->GetResourcedString("Uninstall");
rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("Uninstall"));
if (rsrcVal)
{

View File

@ -272,7 +272,7 @@ nsInstallVersion::ToString(nsString& aReturn)
char *result=NULL;
result = PR_sprintf_append(result, "%d.%d.%d.%d", major, minor, release, build);
aReturn.Assign(result);
aReturn.AssignWithConversion(result);
PR_FREEIF(result);

View File

@ -157,7 +157,7 @@ InstallFileOpDirGetParent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
return JS_TRUE;
}
nativeRetNSStr = nativeRet.GetNativePathCString();
nativeRetNSStr.AssignWithConversion(nativeRet.GetNativePathCString());
*rval = STRING_TO_JSVAL(JS_NewUCStringCopyN(cx, nativeRetNSStr.GetUnicode(), nativeRetNSStr.Length()));
return JS_TRUE;
@ -474,7 +474,7 @@ InstallFileOpFileExecute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
ConvertJSValToStr(b1, cx, argv[1]);
}
else
b1 = "";
b1.SetLength(0);
if (argv[0] == JSVAL_NULL || !JSVAL_IS_OBJECT(argv[0])) //argv[0] MUST be a jsval
{
@ -1152,7 +1152,7 @@ InstallFileOpFileMacAlias(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
b0 += b1;
b2 += b1;
b2 += " alias"; // XXX use GetResourcedString(id)
b2.AppendWithConversion(" alias"); // XXX use GetResourcedString(id)
if(NS_OK != nativeThis->FileOpFileMacAlias(b0, b2, &nativeRet))
{

View File

@ -297,7 +297,7 @@ PRBool ConvertJSValToObj(nsISupports** aSupports,
void ConvertJSvalToVersionString(nsString& versionString, JSContext* cx, jsval argument)
{
versionString = "";
versionString.SetLength(0);
if( JSVAL_IS_OBJECT(argument) )
{

View File

@ -541,7 +541,7 @@ InstallTriggerGlobalGetVersion(JSContext *cx, JSObject *obj, uintN argc, jsval *
return JS_FALSE;
}
if(version.Equals(""))
if(version.IsEmpty())
*rval = JSVAL_NULL;
else
ConvertStrToJSVal(version, cx, rval);

View File

@ -287,7 +287,7 @@ InstallVersionInit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
}
else
{
b0 = "0.0.0.0";
b0.AssignWithConversion("0.0.0.0");
}
if (NS_OK != nativeThis->Init(b0))
@ -403,7 +403,7 @@ InstallVersionCompareTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
if(JS_FALSE == ConvertJSValToObj(getter_AddRefs(versionObj),
kIInstallVersionIID,
"InstallVersion",
NS_ConvertASCIItoUCS2("InstallVersion"),
cx,
argv[0]))
{

View File

@ -111,7 +111,7 @@ nsLoggingProgressNotifier::InstallStarted(const PRUnichar *URL, const PRUnichar*
// char* time;
// GetTime(&time);
nsCString name(UIPackageName);
nsCString name; name.AssignWithConversion(UIPackageName);
nsCString uline;
uline.SetCapacity(name.Length());
for ( unsigned int i=0; i < name.Length(); ++i)

View File

@ -553,13 +553,13 @@ nsSoftwareUpdateNameSet::AddNameSet(nsIScriptContext* aScriptContext)
result = aScriptContext->GetNameSpaceManager(&manager);
if (NS_SUCCEEDED(result))
{
result = manager->RegisterGlobalName("InstallVersion",
result = manager->RegisterGlobalName(NS_ConvertASCIItoUCS2("InstallVersion"),
kInstallVersion_CID,
PR_TRUE);
if (NS_FAILED(result)) return result;
result = manager->RegisterGlobalName("InstallTrigger",
result = manager->RegisterGlobalName(NS_ConvertASCIItoUCS2("InstallTrigger"),
kInstallTrigger_CID,
PR_FALSE);

View File

@ -49,7 +49,6 @@ nsXPITriggerItem::nsXPITriggerItem( const PRUnichar* aName,
if ( pos == -1 ) {
// no arguments
mURL = URL;
mArguments = "";
}
else
{

View File

@ -61,7 +61,7 @@ class nsXPITriggerItem
nsCOMPtr<nsIFileSpec> mFile;
PRBool IsFileURL() { return mURL.Equals("file:/",PR_FALSE,6); }
PRBool IsFileURL() { return mURL.EqualsWithConversion("file:/",PR_FALSE,6); }
PRBool IsRelativeURL();
private:

View File

@ -686,7 +686,7 @@ nsXPInstallManager::FinalizeProgress(const PRUnichar *message, PRInt32 itemNum,
mFinalizing = PR_TRUE;
if (mStringBundle)
{
nsString rsrcName = "FinishingInstallMsg";
nsString rsrcName; rsrcName.AssignWithConversion("FinishingInstallMsg");
const PRUnichar* ucRsrcName = rsrcName.GetUnicode();
PRUnichar* ucRsrcVal = nsnull;
nsresult rv = mStringBundle->GetStringFromName(ucRsrcName, &ucRsrcVal);