Fixing bugs 31688, 17457. Modifying createprofile option to create profile and exit alow the profile creation to use the existing dir. r=gayatrib

This commit is contained in:
racham%netscape.com 2000-05-02 22:32:21 +00:00
Родитель 1555af6dd5
Коммит 9436ac43db
1 изменённых файлов: 22 добавлений и 7 удалений

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

@ -516,7 +516,7 @@ nsProfile::ProcessArgs(nsICmdLineService *cmdLineArgs,
#endif /* DEBUG_profile */ #endif /* DEBUG_profile */
nsAutoString currProfileDir; currProfileDir.AssignWithConversion(currProfileDirSpec.GetNativePathCString()); nsAutoString currProfileDir; currProfileDir.AssignWithConversion(currProfileDirSpec.GetNativePathCString());
rv = CreateNewProfile(currProfileName.GetUnicode(), currProfileDir.GetUnicode()); rv = CreateNewProfile(currProfileName.GetUnicode(), currProfileDir.GetUnicode(), PR_TRUE);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
*profileDirSet = PR_TRUE; *profileDirSet = PR_TRUE;
mCurrentProfileAvailable = PR_TRUE; mCurrentProfileAvailable = PR_TRUE;
@ -526,6 +526,8 @@ nsProfile::ProcessArgs(nsICmdLineService *cmdLineArgs,
gProfileDataAccess->mProfileDataChanged = PR_TRUE; gProfileDataAccess->mProfileDataChanged = PR_TRUE;
gProfileDataAccess->UpdateRegistry(); gProfileDataAccess->UpdateRegistry();
} }
rv = ForgetCurrentProfile();
if (NS_FAILED(rv)) return rv;
} }
} }
@ -830,7 +832,9 @@ NS_IMETHODIMP nsProfile::SetProfileDir(const PRUnichar *profileName, nsFileSpec&
// Creates a new profile // Creates a new profile
NS_IMETHODIMP NS_IMETHODIMP
nsProfile::CreateNewProfile(const PRUnichar* profileName, const PRUnichar* nativeProfileDir) nsProfile::CreateNewProfile(const PRUnichar* profileName,
const PRUnichar* nativeProfileDir,
PRBool useExistingDir)
{ {
NS_ENSURE_ARG_POINTER(profileName); NS_ENSURE_ARG_POINTER(profileName);
@ -874,7 +878,11 @@ nsProfile::CreateNewProfile(const PRUnichar* profileName, const PRUnichar* nativ
// append profile name // append profile name
dirSpec += profileName; dirSpec += profileName;
dirSpec.MakeUnique();
// Make profile directory unique only when the user
// decides to not use an already existing profile directory
if (!useExistingDir)
dirSpec.MakeUnique();
} }
else { else {
dirSpec = nativeProfileDir; dirSpec = nativeProfileDir;
@ -882,8 +890,12 @@ nsProfile::CreateNewProfile(const PRUnichar* profileName, const PRUnichar* nativ
// this prevents people from choosing there profile directory // this prevents people from choosing there profile directory
// or another directory, and remove it when they delete the profile. // or another directory, and remove it when they delete the profile.
// append profile name // append profile name
dirSpec += profileName; dirSpec += profileName;
dirSpec.MakeUnique();
// Make profile directory unique only when the user
// decides to not use an already existing profile directory
if (!useExistingDir)
dirSpec.MakeUnique();
} }
#if defined(DEBUG_profile) #if defined(DEBUG_profile)
@ -891,7 +903,10 @@ nsProfile::CreateNewProfile(const PRUnichar* profileName, const PRUnichar* nativ
#endif #endif
if (!dirSpec.Exists()) if (!dirSpec.Exists())
{
dirSpec.CreateDirectory(); dirSpec.CreateDirectory();
useExistingDir = PR_FALSE;
}
// Set the directory value and add the entry to the registry tree. // Set the directory value and add the entry to the registry tree.
// Creates required user directories. // Creates required user directories.
@ -917,7 +932,7 @@ nsProfile::CreateNewProfile(const PRUnichar* profileName, const PRUnichar* nativ
profDefaultsDir->GetFileSpec(&defaultsDirSpec); profDefaultsDir->GetFileSpec(&defaultsDirSpec);
// Copy contents from defaults folder. // Copy contents from defaults folder.
if (defaultsDirSpec.Exists()) if (defaultsDirSpec.Exists() && (!useExistingDir))
{ {
defaultsDirSpec.RecursiveCopy(dirSpec); defaultsDirSpec.RecursiveCopy(dirSpec);
} }
@ -1510,7 +1525,7 @@ nsProfile::CreateDefaultProfile(void)
nsAutoString dirSpecStr; dirSpecStr.AssignWithConversion(profileDirSpec.GetNativePathCString()); nsAutoString dirSpecStr; dirSpecStr.AssignWithConversion(profileDirSpec.GetNativePathCString());
nsAutoString defaultProfileName; defaultProfileName.AssignWithConversion(DEFAULT_PROFILE_NAME); nsAutoString defaultProfileName; defaultProfileName.AssignWithConversion(DEFAULT_PROFILE_NAME);
rv = CreateNewProfile(defaultProfileName.GetUnicode(), dirSpecStr.GetUnicode()); rv = CreateNewProfile(defaultProfileName.GetUnicode(), dirSpecStr.GetUnicode(), PR_TRUE);
return rv; return rv;
} }