diff --git a/xpinstall/src/nsInstall.cpp b/xpinstall/src/nsInstall.cpp index 36e92e37a7dc..ea1256767678 100644 --- a/xpinstall/src/nsInstall.cpp +++ b/xpinstall/src/nsInstall.cpp @@ -751,10 +751,6 @@ nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aS if(aSubdirectory != "") { nsfsDir += aSubdirectory; - if(!nsfsDir.Exists()) - { - nsfsDir.CreateDirectory(); - } } *aFolder = new nsString(nsfsDir.GetNativePathCString()); } diff --git a/xpinstall/src/nsInstall.h b/xpinstall/src/nsInstall.h index 90e2f0255d16..5a143463e5f3 100644 --- a/xpinstall/src/nsInstall.h +++ b/xpinstall/src/nsInstall.h @@ -122,6 +122,7 @@ class nsInstall UNINSTALL_FAILED = -223, PACKAGE_FOLDER_NOT_SET = -224, EXTRACTION_FAILED = -225, + FILENAME_ALREADY_USED = -226, GESTALT_UNKNOWN_ERR = -5550, GESTALT_INVALID_ARGUMENT = -5551, diff --git a/xpinstall/src/nsInstallFile.cpp b/xpinstall/src/nsInstallFile.cpp index a5e1433567af..aadeab62294e 100644 --- a/xpinstall/src/nsInstallFile.cpp +++ b/xpinstall/src/nsInstallFile.cpp @@ -107,14 +107,36 @@ nsInstallFile::nsInstallFile(nsInstall* inInstall, delete [] qualifiedRegNameString; - - mFinalFile = new nsFileSpec(folderSpec); + mFinalFile = new nsFileSpec(folderSpec); + + if ( mFinalFile->Exists() ) + { + // is there a file with the same name as the proposed folder? + if ( mFinalFile->IsFile() ) + { + *error = nsInstall::FILENAME_ALREADY_USED; + return; + } + // else this directory already exists, so do nothing + } + else + { + /* the nsFileSpecMac.cpp operator += requires "this" (the nsFileSpec) + * to be an existing dir + */ + int dirPermissions = 755; // std default for UNIX, ignored otherwise + mFinalFile->CreateDir(dirPermissions); + } + *mFinalFile += inPartialPath; mReplaceFile = mFinalFile->Exists(); if (mReplaceFile == PR_FALSE) { + /* although it appears that we are creating the dir _again_ it is necessary + * when inPartialPath has arbitrary levels of nested dirs before the leaf + */ nsFileSpec parent; mFinalFile->GetParent(parent); nsFileSpec makeDirs(parent.GetCString(), PR_TRUE); diff --git a/xpinstall/src/nsInstallFolder.cpp b/xpinstall/src/nsInstallFolder.cpp index c456a3ec4d79..76eed682a411 100644 --- a/xpinstall/src/nsInstallFolder.cpp +++ b/xpinstall/src/nsInstallFolder.cpp @@ -106,7 +106,10 @@ nsInstallFolder::nsInstallFolder(const nsString& aFolderID, const nsString& aRel tempString += aRelativePath; mFileSpec = new nsFileSpec(tempString); - // make sure that the directory is created. + // This paranoia makes no sense since dirCheck.IsDirectory() && dirCheck.Exists() ! + // vvvv + // make sure that the directory is created. + // ^^^^ nsFileSpec(mFileSpec->GetCString(), PR_TRUE); } else @@ -273,7 +276,7 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe mFileSpec = nsnull; return; } -#ifndef XP_MAC + if (aRelativePath.Length() > 0) { nsString tempPath(aRelativePath); @@ -283,9 +286,6 @@ nsInstallFolder::SetDirectoryPath(const nsString& aFolderID, const nsString& aRe *mFileSpec += tempPath; } -#endif - // make sure that the directory is created. - nsFileSpec(mFileSpec->GetCString(), PR_TRUE); } } diff --git a/xpinstall/src/nsJSInstall.cpp b/xpinstall/src/nsJSInstall.cpp index df4d431f36db..b04dd18cc990 100644 --- a/xpinstall/src/nsJSInstall.cpp +++ b/xpinstall/src/nsJSInstall.cpp @@ -2344,6 +2344,9 @@ static JSConstDoubleSpec install_constants[] = { nsInstall::PATCH_BAD_CHECKSUM_TARGET, "PATCH_BAD_CHECKSUM_TARGET" }, { nsInstall::PATCH_BAD_CHECKSUM_RESULT, "PATCH_BAD_CHECKSUM_RESULT" }, { nsInstall::UNINSTALL_FAILED, "UNINSTALL_FAILED" }, + { nsInstall::PACKAGE_FOLDER_NOT_SET, "PACKAGE_FOLDER_NOT_SET" }, + { nsInstall::EXTRACTION_FAILED, "EXTRACTION_FAILED" }, + { nsInstall::FILENAME_ALREADY_USED, "FILENAME_ALREADY_USED" }, { nsInstall::GESTALT_UNKNOWN_ERR, "GESTALT_UNKNOWN_ERR" }, { nsInstall::GESTALT_INVALID_ARGUMENT, "GESTALT_INVALID_ARGUMENT" }, { nsInstall::SUCCESS, "SUCCESS" },