firefox addon - Mozilla Add-on SDK - OS.File.read (The system cannot find the file specified.) -



firefox addon - Mozilla Add-on SDK - OS.File.read (The system cannot find the file specified.) -

i created add-on next mozilla's tutorials. cfx test , cfx run worked perfectly. set folder on desktop , installed add-on firefox using cfx xpi , ctrl+o (the xpi file).

now add-on gives error in console log:

win error 2 during operation open on file purls.txt (the scheme cannot find file specified.)

here relevant code in main.js:

const {textencoder, textdecoder, os} = cu.import("resource://gre/modules/osfile.jsm", {}); allow decoder = new textdecoder(); allow promise = os.file.read("purls.txt").then( function onsuccess(array) { // stuff }, function onreject(reason) { console.error("couldn't read purls.txt:\n"+reason); } );

please help me figure out going on. when utilize cfx run add-on finds purls.txt file , opens it/reads without problem.

you didn't give path purls.txt, looking purls.txt on drive. on desktop? create path desktop. see pathtopurls;

const {textencoder, textdecoder, os} = cu.import("resource://gre/modules/osfile.jsm", {}); allow decoder = new textdecoder(); allow pathtopurls = os.path.join(os.constants.path.desktopdir, "purls.txt"); console.log('pathtopurls:', pathtopurls); allow promise = os.file.read(pathtopurls).then( function onsuccess(array) { // stuff }, function onreject(reason) { console.error("couldn't read purls.txt:\n"+reason); } );

sdk firefox-addon mozilla

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -