My add-on, Color Source, needs to iterate files in a directory within my add-on (e.g., the content
subdirectory) when the add-on is not unpacked (i.e., is kept zipped as an XPI).
We are using code like this to get the Addon object:
Cu.import("resource://gre/modules/AddonManager.jsm", null)
.AddonManager
.getAddonByID(
"color_source@brett.zamir",
function(addon) {
var uri = addon.getResourceURI();
}
);
In order to pass a path to new OS.File.DirectoryIterator
, we have tried:
OS.Path.join(uri.path, 'content');
which apparently works in *nix but not Windows- Getting and then cloning
uri.QueryInterface(Ci.nsIFileURL).file
, and then callingappend('content')
on the clone and this works, but only when the add-on has the<em:unpack>
directive set to true ininstall.rdf
.
How do we get a path that works even when the add-on is zipped up?
(Note: I have added a Firefox add-on tag to this post because the issue should be similar there)