Mike Lee wrote:
I used to be able to do:
var fileUrl = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIFileURL);
But that no longer works, reading bug 157135 made me thought something like:
var url = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIURL);
url.spec = "file:///c:/something.txt";
url.QueryInterface(Components.interfaces.nsIFileURL);
would work, but it doesn't. I now use the method from abCardViewOverlay.js but I would like to know why the above doesn't work anymore? Or whats the proper way to get nsIFileURL interface?
Regards
"@mozilla.org/network/standard-url;1" is not a frozen contract ID. there is no guarantee that using it is good for anything at all.
that said, the correct way to instantiate an URL object implementing nsIFileURL is to use the nsIIOService.
e.g.,
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var url = ios.newURI("file:///c:/something.txt", null, null);
--
darin
