[Jslib] What to use to open files in the chrome jar?

Pete Collins pete at mozdevgroup.com
Fri Dec 17 11:11:07 EST 2004


>
> This is because the file is now encapsulated in a jar file (did I 
> mention this is firefox).

Yes chromeToPath is broken for recent versions of Firefox only. Still 
works fine in Mozilla builds.


See jslib bug 7959:
  http://bugzilla.mozdev.org/show_bug.cgi?id=7959

>
> extension.xpi:
>              install.rdf
>              chrome/extension.jar
>              components/extension.dll
>              components/extension.js
>              defaults/extension.something
>              defaults/preferences/extension.js
>
> The basic question is...
> What is the appropriate way to get an file handle to this file?
>
>
We need to implement a Chrome class or just provide support for opening 
chrome URL's. Once a file is in a jar, it is no longer a "local" file.

It can be done, I just can't think of an *easy* way to do it off the top 
of my head ...

Heres the *long* way to do it:
Example uses [chrome://jslib/content/jslib.xul]

-------------------
js> var ios = 
jslibGetService("@mozilla.org/network/io-service;1","nsIIOService");
js>  var uri = ios.newURI("chrome://jslib/content/jslib.xul",null,null);
jjs> var channel = ios.newChannelFromURI(uri);
jjs> var is = 
jslibCreateInstance("@mozilla.org/scriptableinputstream;1","nsIScriptableInputStream");
js> is.init(channel.open());
js> is.available();
1776
js> is.read(is.available());

I'll file a bug and get this type of functionality in as soon as I can ...

--pete

-- 
Pete Collins - Founder, Mozdev Group Inc.
www.mozdevgroup.com
Mozilla Software Development Solutions 




More information about the Jslib mailing list