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

Fred Eisele fred at netarx.com
Fri Dec 17 10:08:09 EST 2004


During development I was using the following code to open a file in the 
chrome.

  var theFilePath = theFileUtils.chromeToPath( theChromeName );
  var theFile = new File ( theFilePath );

theChromeName is similar to...
  chrome://mypackage/content/transform/some.xsl
...and it is located in...
  /usr/lib/mozilla-firefox/chrome/mypackage/content/transform/some.xsl
...which is what theFilePath becomes; so far so good.


When it came time to make a package theFileUtils.chromeToPath no
longer gives a 'good' path (e.g. 
chrome://mypackage/content/transform/some.xsl  becomes 
-2152857601!/content/transform/catalogue-import.xsl).
This is because the file is now encapsulated in a jar file (did I 
mention this is firefox).

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?
- expect the File class to know how to open uri's?
- use RemoteFile? It currently only supports 'http' not 'chrome'.
- use Zip?  It does not recognize chrome paths.
- use some creative combination of the File and Zip classes?  That still does not locate the zip file to begin with.
- introduce new class Chrome? 

I expect there are some chrome related components that are part of mozilla/firefox.
Do you know of such a mechanism?

----------------
p.s. thanks for the File( nsIFile ) constructor.





More information about the Jslib mailing list