2011-12-14 63 views
1

我正在使用本地.xml文件的Firefox擴展,它讀取和寫入它。從Firefox擴展中寫入文件的安全位置?

我沒有問題的代碼,它可以在我的電腦上使用桌面目錄進行測試,但是我不知道在最終擴展上使用哪個文件夾,因爲它在嘗試寫入時可能會遇到權限問題一些電腦上的文件。

在mozilla.org我看到這些目錄我可以使用:

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) 

是否有人知道這將是用於發佈的版本是最好的選擇?我的意思是所有可用文件夾中的哪一個會在任何pc上始終寫入權限?

回答

4

擴展應該通常只寫入用戶的配置文件目錄(ProfD)。如果你有多個文件,你最好爲你的擴展創建一個目錄。如果它是一個文件 - 確保以一種明顯指明它屬於哪個擴展名的方式命名它。