PRBool *mFlagPtr; };
m_reg->Close();
nsProfile::StartupWithArgs(nsICmdLineService *cmdLineArgs, PRBool canInteract){    nsresult rv;    struct ScopeFlag    {        ScopeFlag(PRBool *flagPtr) : mFlagPtr(flagPtr)        { *mFlagPtr = PR_TRUE; }        ~ScopeFlag()        { *mFlagPtr = PR_FALSE; }        PRBool *mFlagPtr;    };    // initializations for profile manager    PRBool profileDirSet = PR_FALSE;    nsCString profileURLStr("");#ifdef DEBUG_profile_verbose    printf("Profile Manager : Profile Wizard and Manager activites : Begin\n");#endif    ScopeFlag startupFlag(&mStartingUp);    if (cmdLineArgs)        rv = ProcessArgs(cmdLineArgs, canInteract, &profileDirSet, profileURLStr);    // This boolean is set only when an automigrated user runs out of disk space    // and chooses to cancel further operations from the dialogs presented...    if (mDiskSpaceErrorQuitCalled)        return NS_ERROR_FAILURE;    if (!profileDirSet) {        rv = LoadDefaultProfileDir(profileURLStr, canInteract);        if (NS_FAILED(rv)) return rv;    }    // Ensure that by this point we have a current profile.    // If -CreateProfile was used, we won't, and we're supposed to exit.    nsXPIDLString currentProfileStr;    rv = GetCurrentProfile(getter_Copies(currentProfileStr));    if (NS_FAILED(rv) || (*(const PRUnichar*)currentProfileStr == 0)) {        return NS_ERROR_ABORT;    }    // check UILocale is specified on profileManager, otherwise,    // when -UILocale option is specified, install the UILocale    // -UILocale or -contentLocale is not specified    if (mIsUILocaleSpecified == PR_FALSE && mIsContentLocaleSpecified == PR_FALSE) {        return NS_OK;    }    nsCOMPtr<nsIFile> profileDir;    rv = GetCurrentProfileDir(getter_AddRefs(profileDir));    if (NS_FAILED(rv)) return rv;    nsCAutoString pathBuf;    rv = profileDir->GetNativePath(pathBuf);    if (NS_FAILED(rv)) return rv;    // -UILocale or -contentLocale has been specified, but    // user has selected UILocale and contentLocale for this profile    // on profileManager    // We should not set here    nsCStringKey key(pathBuf);    if (NS_PTR_TO_INT32(gLocaleProfiles->Get(&key)) == PR_TRUE) {#ifdef DEBUG_profile_verbose        printf(" already set UILocale and contentLocale: %s\n", pathBuf.get());        printf(" will not install locale\n");#endif        return NS_OK;    }    gLocaleProfiles->Remove(&key);    nsCOMPtr<nsIChromeRegistrySea> chromeRegistry =        do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);    if (NS_FAILED(rv)) return rv;    // Install to the profile    nsCAutoString fileStr;    rv = NS_GetURLSpecFromFile(profileDir, fileStr);    if (NS_FAILED(rv)) return rv;    // NEED TO FIX: when current UILocale and contentLocale are same with specified locales,    // we shouldn't install them again here. But packageRegistry->GetSelectedLocale() doesn't    // work here properly. It always returns global and global-region of default not current    // profile    if (!mUILocaleName.IsEmpty()) {#ifdef DEBUG_profile_verbose        printf(" install new UILocaleName: %s\n", mUILocaleName.get());#endif        rv = chromeRegistry->SelectLocaleForProfile(mUILocaleName,                                          NS_ConvertUTF8toUCS2(fileStr).get());        if (NS_FAILED(rv)) return rv;    }    if (!mContentLocaleName.IsEmpty()) {#ifdef DEBUG_profile_verbose        printf(" install new mContentLocaleName: %s\n", mContentLocaleName.get());#endif        rv = chromeRegistry->SelectLocaleForProfile(mContentLocaleName,                                          NS_ConvertUTF8toUCS2(fileStr).get());        if (NS_FAILED(rv)) return rv;    }#ifdef DEBUG_profile_verbose    printf("Profile Manager : Profile Wizard and Manager activites : End\n");#endif    return NS_OK;}