[Project_owners] shared profiles

Brian King brian at mozdev.org
Mon Aug 2 15:22:10 EDT 2004


On 30.7.2004 22:32, Patrick Brunschwig wrote:

>>But how do you write to that file exclusively when calling setPref,
>>instead of the profile 'prefs.js'? The only related API call I see is
>>nsIPref:savePrefFile(in nsIFile aFile), but this appears to write *all*
>>current preferences. I just want to do it on a one by one basis for
>>certain prefs.
> 
> You can't do that directly. But I think it would not be very difficult
> to create your own function which can write a file into that folder.
> It's not much more than this:
>   for (...) {
>     write('pref("'+thePref+'", '+ theValue + ');');
>   }

I was able to achieve what I wanted using a combination of:
nsIPrefService.readUserPrefs(..)
               .savePrefFile(..)

I now have my own appprefs file living in defaults/pref, being read from 
and written to, and it's still inheriting the default prefs. But it 
means that prefs.js in the profile is being ignored. This is fine for my 
app, but may not be for others trying to do something similar.

Thanks Patrick.
-- 
Brian King
www.mozdev.org - free project hosting for the mozilla community


More information about the Project_owners mailing list