Safe location to write a file from a Firefox extension?

326 views Asked by At

I am working on a Firefox extension that makes uses of a local .xml file, it reads and write it.

I have no problems with the code and it works fine on my pc using the desktop directory for testing, but I don't know which folder to use on the final extension because it could encounter a permissions problem when trying to write the file on some pcs.

On mozilla.org I see these directories I could use:

String  Meaning
ProfD   profile directory
DefProfRt   user (for example /root/.mozilla)
UChrm   %profile%/chrome
DefRt   %installation%/defaults
PrfDef  %installation%/defaults/pref
ProfDefNoLoc    %installation%/defaults/profile
APlugns     %installation%/plugins
AChrom  %installation%/chrome
ComsD   %installation%/components
CurProcD    installation (usually)
Home    OS root (for example /root)
TmpD    OS tmp (for example /tmp)
ProfLD  Local Settings on windows; where the network cache and fastload files are stored
resource:app    application directory in a XULRunner app
Desk    Desktop directory (for example ~/Desktop on Linux, C:\Documents and Settings\username\Desktop on Windows)
Progs   User start menu programs directory (for example C:\Documents and Settings\username\Start Menu\Programs)

Does someone knows which would be the best option to use for a release for distribution? I mean which one of all the available folders will have always write permissions on any pc?

1

There are 1 answers

0
Wladimir Palant On

Extensions should normally only write to user's profile directory (ProfD). If you have multiple files you probably better create a directory for your extension there. If it is a single file - make sure to name it in a way that makes it obvious which extension it belongs to.