0
蔭試圖建立在我的擴展目錄中的文件,我有這樣的代碼:創建文件使用擴展的Firefox
AddonManager.getAddonByID(" extension id here ", function(addon)
{
var uri = addon.getResourceURI("hello.txt");
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
var stringUri = uri.asciiSpec;
stringUri = stringUri.replace(new RegExp(/\//g), '\\');
stringUri = stringUri.slice(8);
alert(stringUri);
try{
file.initWithPath(stringUri);
} catch(e) {
alert(e);
}
alert(addon.hasResource("hello.txt"));
});
但由於某些原因最後警報顯示總是假的,文件不存在。我究竟做錯了什麼?
我也把解壓縮到的install.rdf真正解包的標籤,看看紐約的擴展目錄中晚期
感謝。
什麼config.json URI,'file'或'jar'的方案的轉換? – paa
file ................ – Tony