fx-compat: getURLSpecFromFile()Zotero.File.pathToFileURI()

One remaining instance in the prefs that will need to be fixed
This commit is contained in:
Dan Stillman 2022-06-19 15:20:54 -04:00
parent f8aa14d431
commit 8f7a160ba1
3 changed files with 4 additions and 16 deletions

View file

@ -1952,9 +1952,7 @@ var ItemTree = class ItemTree extends LibraryTree {
let uri;
if (!Zotero.isMac) {
Zotero.debug("Adding text/x-moz-url " + i);
let fph = Cc["@mozilla.org/network/protocol;1?name=file"]
.createInstance(Ci.nsIFileProtocolHandler);
uri = fph.getURLSpecFromFile(file);
uri = Zotero.File.pathToFileURI(file);
event.dataTransfer.mozSetDataAt("text/x-moz-url", uri + '\n' + file.leafName, i);
}

View file

@ -2941,15 +2941,11 @@ Zotero.Item.prototype.getLocalFileURL = function() {
if (!this.isAttachment()) {
throw ("getLocalFileURL() can only be called on attachment items");
}
var file = this.getFile();
var file = this.getFilePath();
if (!file) {
return false;
}
var nsIFPH = Components.classes["@mozilla.org/network/protocol;1?name=file"]
.getService(Components.interfaces.nsIFileProtocolHandler);
return nsIFPH.getURLSpecFromFile(file);
return Zotero.File.pathToFileURI(file);
}

View file

@ -676,18 +676,12 @@ Zotero.Translate.IO.Read.prototype = {
},
"_initRDF":function() {
// get URI
var IOService = Components.classes['@mozilla.org/network/io-service;1']
.getService(Components.interfaces.nsIIOService);
var fileHandler = IOService.getProtocolHandler("file")
.QueryInterface(Components.interfaces.nsIFileProtocolHandler);
var baseURI = fileHandler.getURLSpecFromFile(this.file);
Zotero.debug("Translate: Initializing RDF data store");
this._dataStore = new Zotero.RDF.AJAW.IndexedFormula();
var parser = new Zotero.RDF.AJAW.RDFParser(this._dataStore);
try {
var nodes = Zotero.Translate.IO.parseDOMXML(this._rawStream, this._charset, this.file.fileSize);
let baseURI = Zotero.File.pathToFileURI(this.file);
parser.parse(nodes, baseURI);
this.RDF = new Zotero.Translate.IO._RDFSandbox(this._dataStore);