Hi,
I am writing a Firefox extension and have a need to read the contents of 'moz-icon' (e.g. moz-icon://.img?size=16) URI.
I have following code :
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
var iOService = Cc["@
mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var mozUri = iOService.newURI('moz-icon://.img?size=16', null, null);
var channel = iOService.newChannelFromURI(mozUri);
var inputStream = channel.open(),
binaryInputStream = Cc["@
mozilla.org/binaryinputstream;1"].createInstance(Ci["nsIBinaryInputStream"]);
binaryInputStream.setInputStream(inputStream);
let data = [];
try {
while ((avail = binaryInputStream.available()) > 0)
data = data.concat(binaryInputStream.readByteArray(avail));
binaryInputStream.close(); inputStream.close();
} catch(e) {
}
It works on Windows and Mac, however doesn't work on Linux (Ubuntu 12.0 32bit). If fails when trying to create a newChannelFromURI (says it's not implemented).
Is there any other way of reading the contents of the moz-icon URI besides creating a channel out of it?
Thanks, Sunil
(I have posted the same question on Mozillazine and if I get an answer there, I'll update this thread and vice versa).