From b2d97a1c4dd7ce667714dfa3548917d03e5bb962 Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Mon, 24 Apr 2000 06:08:48 +0000 Subject: [PATCH] Adding critical check for null. removing unneded assignment to temp var. --- xpinstall/src/nsInstallFolder.cpp | 44 +++++++++++++------------------ 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/xpinstall/src/nsInstallFolder.cpp b/xpinstall/src/nsInstallFolder.cpp index c7b3627cc7c..1edd168f4e8 100644 --- a/xpinstall/src/nsInstallFolder.cpp +++ b/xpinstall/src/nsInstallFolder.cpp @@ -116,31 +116,33 @@ nsInstallFolder::nsInstallFolder(const nsString& aFolderID, const nsString& aRel // if it already exists... nsCOMPtr dirCheck; NS_NewLocalFile(aFolderID.ToNewCString(), getter_AddRefs(dirCheck)); - dirCheck->IsDirectory(&flagIsDir); - dirCheck->Exists(&flagExists); - if ( flagIsDir || !flagExists ) + if (dirCheck) { - mFileSpec = dirCheck; - - if (mFileSpec && aRelativePath.Length() > 0 ) + dirCheck->IsDirectory(&flagIsDir); + dirCheck->Exists(&flagExists); + if ( flagIsDir || !flagExists ) { - // we've got a subdirectory to tack on - nsString morePath(aRelativePath); + mFileSpec = dirCheck; - //if ( morePath.Last() != '/' || morePath.Last() != '\\' ) - // morePath.AppendWithConversion('/'); + if (mFileSpec && aRelativePath.Length() > 0 ) + { + // we've got a subdirectory to tack on + nsString morePath(aRelativePath); - mFileSpec->Append(morePath.ToNewCString()); + //if ( morePath.Last() != '/' || morePath.Last() != '\\' ) + // morePath.AppendWithConversion('/'); + + mFileSpec->Append(morePath.ToNewCString()); + } + + // make sure that the directory is created. + // XXX: **why** are we creating these? they might not be used! + // nsFileSpec(mFileSpec->GetCString(), PR_TRUE); } - - // make sure that the directory is created. - // XXX: **why** are we creating these? they might not be used! - // nsFileSpec(mFileSpec->GetCString(), PR_TRUE); } } } - nsInstallFolder::nsInstallFolder(nsInstallFolder& inFolder, const nsString& subString) { MOZ_COUNT_CTOR(nsInstallFolder); @@ -291,17 +293,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe case 109: /////////////////////////////////////////////////////////// File URL { - if (aRelativePath.IsEmpty()) - { - mFileSpec = nsnull; - return; - } - nsCOMPtr temp; - - nsString tempFileURLString = aFolderID; - tempFileURLString += aRelativePath; - NS_NewLocalFile(aRelativePath.ToNewCString(), getter_AddRefs(temp)); mFileSpec = temp;