Changing mozilla's profile using GRE

[email protected] (fltcpt) 2 Jul 2004 22:55:56 -0700
Newsgroups gmane.comp.mozilla.devel.prefs
Organization http://groups.google.com
Message-ID <[email protected]>
I am trying to use an external program (talking
to GRE using xpcom) to modify my Mozilla's (the browser)
cache directory... I have this:

rv = profileService->SetCurrentProfile(some_profile); // assume
profile exists
nsCOMPtr<nsIPrefService> preferenceService =
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIPrefBranch> prefBranch;
rv = preferenceService->GetBranch(nsnull, getter_AddRefs(prefBranch));
rv = prefBranch->SetCharPref("browser.cache.disk.parent_directory",
some_dir);
rv = preferenceService->SavePrefFile(nsnull); // return value rv is
not ok

Saving to file failed. (tried GetCharPref, failed too)
nsIPref doesn't work either (it's not frozen so I better
stick with nsIPrefService anyway)...

Any idea what I did wrong? Wrong directory service provider?
One note: it creates an empty prefs-1.js at the correct 
profile directory....

I'd appreciate any response.

Thanks.