From 686c370100dc9822763ce6e259f5e4b42d231499 Mon Sep 17 00:00:00 2001 From: "gayatrib%netscape.com" Date: Wed, 7 Jul 1999 01:08:17 +0000 Subject: [PATCH] Added code that copies content from defaults folder --- profile/src/nsProfile.cpp | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/profile/src/nsProfile.cpp b/profile/src/nsProfile.cpp index 27219db0446..9d89c457d18 100644 --- a/profile/src/nsProfile.cpp +++ b/profile/src/nsProfile.cpp @@ -938,6 +938,13 @@ NS_IMETHODIMP nsProfile::CreateNewProfile(char* charData) printf("ProfileManagerData*** : %s\n", charData); #endif + nsIFileLocator* locator = nsnull; + + rv = nsServiceManager::GetService(kFileLocatorCID, nsIFileLocator::GetIID(), (nsISupports**)&locator); + + if (NS_FAILED(rv) || !locator) + return NS_ERROR_FAILURE; + nsString data(charData); // Set the gathered info into an array @@ -958,24 +965,16 @@ NS_IMETHODIMP nsProfile::CreateNewProfile(char* charData) if (!dirName || !*dirName) { // They didn't type a directory path... - nsIFileLocator* locator = nsnull; - - rv = nsServiceManager::GetService(kFileLocatorCID, nsIFileLocator::GetIID(), (nsISupports**)&locator); - - if (NS_FAILED(rv) || !locator) - return NS_ERROR_FAILURE; - // Get current profile, make the new one a sibling... nsIFileSpec* horribleCOMDirSpecThing; rv = locator->GetFileLocation(nsSpecialFileSpec::App_DefaultUserProfileRoot50, &horribleCOMDirSpecThing); - nsServiceManager::ReleaseService(kFileLocatorCID, locator); - if (NS_FAILED(rv) || !horribleCOMDirSpecThing) return NS_ERROR_FAILURE; //Append profile name to form a directory name horribleCOMDirSpecThing->GetFileSpec(&dirSpec); + NS_RELEASE(horribleCOMDirSpecThing); //dirSpec.SetLeafName(profileName); dirSpec += profileName; } @@ -997,7 +996,24 @@ NS_IMETHODIMP nsProfile::CreateNewProfile(char* charData) if (NS_FAILED(rv)) return rv; - if (dirName) + // Get profile defaults folder.. + nsIFileSpec* profDefaultsDir; + rv = locator->GetFileLocation(nsSpecialFileSpec::App_ProfileDefaultsFolder50, &profDefaultsDir); + + if (NS_FAILED(rv) || !profDefaultsDir) + return NS_ERROR_FAILURE; + + nsFileSpec defaultsDirSpec; + + profDefaultsDir->GetFileSpec(&defaultsDirSpec); + NS_RELEASE(profDefaultsDir); + + // Copy contents from defaults folder. + defaultsDirSpec.RecursiveCopy(dirSpec); + + nsServiceManager::ReleaseService(kFileLocatorCID, locator); + + if (dirName) { PR_DELETE(dirName); }