Fx60: Remove instances of nsILocalFile
nsILocalFile was merged into nsIFile, so either replace it with that or switch to Zotero.File.pathToFile().
This commit is contained in:
parent
6f965251ed
commit
433794916a
13 changed files with 36 additions and 57 deletions
|
@ -51,13 +51,11 @@ var Zotero_RTFScan = new function() {
|
||||||
this.introPageShowing = function() {
|
this.introPageShowing = function() {
|
||||||
var path = Zotero.Prefs.get("rtfScan.lastInputFile");
|
var path = Zotero.Prefs.get("rtfScan.lastInputFile");
|
||||||
if(path) {
|
if(path) {
|
||||||
inputFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
|
inputFile = Zotero.File.pathToFile(path);
|
||||||
inputFile.initWithPath(path);
|
|
||||||
}
|
}
|
||||||
var path = Zotero.Prefs.get("rtfScan.lastOutputFile");
|
var path = Zotero.Prefs.get("rtfScan.lastOutputFile");
|
||||||
if(path) {
|
if(path) {
|
||||||
outputFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
|
outputFile = Zotero.File.pathToFile(path);
|
||||||
outputFile.initWithPath(path);
|
|
||||||
}
|
}
|
||||||
_updatePath();
|
_updatePath();
|
||||||
document.getElementById("choose-input-file").focus();
|
document.getElementById("choose-input-file").focus();
|
||||||
|
|
|
@ -2239,7 +2239,7 @@ Zotero.Item.prototype.getFilePath = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
let file = Components.classes["@mozilla.org/file/local;1"]
|
let file = Components.classes["@mozilla.org/file/local;1"]
|
||||||
.createInstance(Components.interfaces.nsILocalFile);
|
.createInstance(Components.interfaces.nsIFile);
|
||||||
try {
|
try {
|
||||||
file.persistentDescriptor = path;
|
file.persistentDescriptor = path;
|
||||||
}
|
}
|
||||||
|
@ -2345,7 +2345,7 @@ Zotero.Item.prototype.getFilePathAsync = Zotero.Promise.coroutine(function* () {
|
||||||
// the file couldn't be found
|
// the file couldn't be found
|
||||||
if (Zotero.isMac && path.startsWith('AAAA')) {
|
if (Zotero.isMac && path.startsWith('AAAA')) {
|
||||||
let file = Components.classes["@mozilla.org/file/local;1"]
|
let file = Components.classes["@mozilla.org/file/local;1"]
|
||||||
.createInstance(Components.interfaces.nsILocalFile);
|
.createInstance(Components.interfaces.nsIFile);
|
||||||
try {
|
try {
|
||||||
file.persistentDescriptor = path;
|
file.persistentDescriptor = path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ Zotero.DataDirectory = {
|
||||||
let nsIFile;
|
let nsIFile;
|
||||||
try {
|
try {
|
||||||
nsIFile = Components.classes["@mozilla.org/file/local;1"]
|
nsIFile = Components.classes["@mozilla.org/file/local;1"]
|
||||||
.createInstance(Components.interfaces.nsILocalFile);
|
.createInstance(Components.interfaces.nsIFile);
|
||||||
nsIFile.persistentDescriptor = prefVal;
|
nsIFile.persistentDescriptor = prefVal;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
@ -265,7 +265,7 @@ Zotero.DataDirectory = {
|
||||||
let nsIFile;
|
let nsIFile;
|
||||||
try {
|
try {
|
||||||
nsIFile = Components.classes["@mozilla.org/file/local;1"]
|
nsIFile = Components.classes["@mozilla.org/file/local;1"]
|
||||||
.createInstance(Components.interfaces.nsILocalFile);
|
.createInstance(Components.interfaces.nsIFile);
|
||||||
nsIFile.persistentDescriptor = prefs['extensions.zotero.dataDir'];
|
nsIFile.persistentDescriptor = prefs['extensions.zotero.dataDir'];
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|
|
@ -1319,7 +1319,6 @@ Zotero.File = new function(){
|
||||||
dialogButtonText: Zotero.getString('file.accessError.showParentDir'),
|
dialogButtonText: Zotero.getString('file.accessError.showParentDir'),
|
||||||
dialogButtonCallback: function () {
|
dialogButtonCallback: function () {
|
||||||
try {
|
try {
|
||||||
file.parent.QueryInterface(Components.interfaces.nsILocalFile);
|
|
||||||
file.parent.reveal();
|
file.parent.reveal();
|
||||||
}
|
}
|
||||||
// Unsupported on some platforms
|
// Unsupported on some platforms
|
||||||
|
@ -1353,13 +1352,12 @@ Zotero.File = new function(){
|
||||||
Zotero.debug("Revealing " + file);
|
Zotero.debug("Revealing " + file);
|
||||||
|
|
||||||
var nsIFile = this.pathToFile(file);
|
var nsIFile = this.pathToFile(file);
|
||||||
nsIFile.QueryInterface(Components.interfaces.nsILocalFile);
|
|
||||||
try {
|
try {
|
||||||
nsIFile.reveal();
|
nsIFile.reveal();
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
Zotero.logError(e);
|
Zotero.logError(e);
|
||||||
// On platforms that don't support nsILocalFile.reveal() (e.g. Linux),
|
// On platforms that don't support nsIFile.reveal() (e.g. Linux),
|
||||||
// launch the directory
|
// launch the directory
|
||||||
let zp = Zotero.getActiveZoteroPane();
|
let zp = Zotero.getActiveZoteroPane();
|
||||||
if (zp) {
|
if (zp) {
|
||||||
|
|
|
@ -2847,7 +2847,7 @@ Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
||||||
var dirPrimitive = {};
|
var dirPrimitive = {};
|
||||||
var dataSize = {};
|
var dataSize = {};
|
||||||
transferable.getTransferData("application/x-moz-file-promise-dir", dirPrimitive, dataSize);
|
transferable.getTransferData("application/x-moz-file-promise-dir", dirPrimitive, dataSize);
|
||||||
var destDir = dirPrimitive.value.QueryInterface(Components.interfaces.nsILocalFile);
|
var destDir = dirPrimitive.value.QueryInterface(Components.interfaces.nsIFile);
|
||||||
|
|
||||||
var draggedItems = Zotero.Items.get(this._itemIDs);
|
var draggedItems = Zotero.Items.get(this._itemIDs);
|
||||||
var items = [];
|
var items = [];
|
||||||
|
@ -2901,7 +2901,7 @@ Zotero.ItemTreeView.fileDragDataProvider.prototype = {
|
||||||
var numFiles = 0;
|
var numFiles = 0;
|
||||||
while (files.hasMoreElements()) {
|
while (files.hasMoreElements()) {
|
||||||
var f = files.getNext();
|
var f = files.getNext();
|
||||||
f.QueryInterface(Components.interfaces.nsILocalFile);
|
f.QueryInterface(Components.interfaces.nsIFile);
|
||||||
if (f.leafName.indexOf('.') != 0) {
|
if (f.leafName.indexOf('.') != 0) {
|
||||||
numFiles++;
|
numFiles++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2588,7 +2588,7 @@ Zotero.Schema = new function(){
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let file = Components.classes["@mozilla.org/file/local;1"]
|
let file = Components.classes["@mozilla.org/file/local;1"]
|
||||||
.createInstance(Components.interfaces.nsILocalFile);
|
.createInstance(Components.interfaces.nsIFile);
|
||||||
try {
|
try {
|
||||||
file.persistentDescriptor = path;
|
file.persistentDescriptor = path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -681,11 +681,11 @@ Zotero.Translate.ItemSaver.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
"_parseAbsolutePath":function(path) {
|
"_parseAbsolutePath":function(path) {
|
||||||
var file = Components.classes["@mozilla.org/file/local;1"].
|
var file;
|
||||||
createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
try {
|
try {
|
||||||
file.initWithPath(path);
|
file = Zotero.File.pathToFile(path);
|
||||||
} catch(e) {
|
}
|
||||||
|
catch (e) {
|
||||||
Zotero.debug("Translate: Invalid absolute path: " + path);
|
Zotero.debug("Translate: Invalid absolute path: " + path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -994,9 +994,7 @@ Zotero.Translate.ItemGetter.prototype = {
|
||||||
|
|
||||||
"exportFiles":function(dir, extension) {
|
"exportFiles":function(dir, extension) {
|
||||||
// generate directory
|
// generate directory
|
||||||
this._exportFileDirectory = Components.classes["@mozilla.org/file/local;1"].
|
this._exportFileDirectory = dir.parent.clone();
|
||||||
createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
this._exportFileDirectory.initWithFile(dir.parent);
|
|
||||||
|
|
||||||
// delete this file if it exists
|
// delete this file if it exists
|
||||||
if(dir.exists()) {
|
if(dir.exists()) {
|
||||||
|
@ -1012,9 +1010,7 @@ Zotero.Translate.ItemGetter.prototype = {
|
||||||
|
|
||||||
// generate a new location for the exported file, with the appropriate
|
// generate a new location for the exported file, with the appropriate
|
||||||
// extension
|
// extension
|
||||||
var location = Components.classes["@mozilla.org/file/local;1"].
|
var location = this._exportFileDirectory.clone();
|
||||||
createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
location.initWithFile(this._exportFileDirectory);
|
|
||||||
location.append(name+"."+extension);
|
location.append(name+"."+extension);
|
||||||
|
|
||||||
return location;
|
return location;
|
||||||
|
@ -1075,9 +1071,7 @@ Zotero.Translate.ItemGetter.prototype = {
|
||||||
|
|
||||||
// Separate the path into a list of subdirectories and the attachment filename,
|
// Separate the path into a list of subdirectories and the attachment filename,
|
||||||
// and initialize the required file objects
|
// and initialize the required file objects
|
||||||
var targetFile = Components.classes["@mozilla.org/file/local;1"].
|
var targetFile = exportDir.clone();
|
||||||
createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
targetFile.initWithFile(exportDir);
|
|
||||||
for (let dir of attachPath.split("/")) targetFile.append(dir);
|
for (let dir of attachPath.split("/")) targetFile.append(dir);
|
||||||
|
|
||||||
// First, check that we have not gone lower than exportDir in the hierarchy
|
// First, check that we have not gone lower than exportDir in the hierarchy
|
||||||
|
|
|
@ -1717,9 +1717,7 @@ Zotero.Utilities.Internal.executeAppleScript = new function() {
|
||||||
|
|
||||||
return function(script, block) {
|
return function(script, block) {
|
||||||
if(_osascriptFile === undefined) {
|
if(_osascriptFile === undefined) {
|
||||||
_osascriptFile = Components.classes["@mozilla.org/file/local;1"].
|
_osascriptFile = Zotero.File.pathToFile('/usr/bin/osascript');
|
||||||
createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
_osascriptFile.initWithPath("/usr/bin/osascript");
|
|
||||||
if(!_osascriptFile.exists()) _osascriptFile = false;
|
if(!_osascriptFile.exists()) _osascriptFile = false;
|
||||||
}
|
}
|
||||||
if(_osascriptFile) {
|
if(_osascriptFile) {
|
||||||
|
|
|
@ -1010,7 +1010,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||||
Zotero.debug(e);
|
Zotero.debug(e);
|
||||||
Zotero.debug("Launching via executable failed -- passing to loadUrl()");
|
Zotero.debug("Launching via executable failed -- passing to loadUrl()");
|
||||||
|
|
||||||
// If nsILocalFile.launch() isn't available and the fallback
|
// If nsIFile.launch() isn't available and the fallback
|
||||||
// executable doesn't exist, we just let the Firefox external
|
// executable doesn't exist, we just let the Firefox external
|
||||||
// helper app window handle it
|
// helper app window handle it
|
||||||
var nsIFPH = Components.classes["@mozilla.org/network/protocol;1?name=file"]
|
var nsIFPH = Components.classes["@mozilla.org/network/protocol;1?name=file"]
|
||||||
|
@ -1080,9 +1080,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||||
}
|
}
|
||||||
var path = Zotero.Prefs.get(pref);
|
var path = Zotero.Prefs.get(pref);
|
||||||
|
|
||||||
var exec = Components.classes["@mozilla.org/file/local;1"]
|
let exec = Zotero.File.pathToFile(path);
|
||||||
.createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
exec.initWithPath(path);
|
|
||||||
if (!exec.exists()) {
|
if (!exec.exists()) {
|
||||||
throw ("Fallback executable not found -- check extensions.zotero." + pref + " in about:config");
|
throw ("Fallback executable not found -- check extensions.zotero." + pref + " in about:config");
|
||||||
}
|
}
|
||||||
|
|
|
@ -4214,10 +4214,9 @@ var ZoteroPane = new function()
|
||||||
file.reveal();
|
file.reveal();
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
// On platforms that don't support nsILocalFile.reveal() (e.g. Linux),
|
// On platforms that don't support nsIFile.reveal() (e.g. Linux),
|
||||||
// launch the parent directory
|
// launch the parent directory
|
||||||
var parent = file.parent.QueryInterface(Components.interfaces.nsILocalFile);
|
Zotero.launchFile(file.parent);
|
||||||
Zotero.launchFile(parent);
|
|
||||||
}
|
}
|
||||||
Zotero.Notifier.trigger('open', 'file', attachment.id);
|
Zotero.Notifier.trigger('open', 'file', attachment.id);
|
||||||
};
|
};
|
||||||
|
|
|
@ -612,9 +612,7 @@ ZoteroCommandLineHandler.prototype = {
|
||||||
// Wait to handle things that require the UI until after it's loaded
|
// Wait to handle things that require the UI until after it's loaded
|
||||||
Zotero.uiReadyPromise
|
Zotero.uiReadyPromise
|
||||||
.then(function () {
|
.then(function () {
|
||||||
var file = Components.classes["@mozilla.org/file/local;1"].
|
var file = Zotero.File.pathToFile(param);
|
||||||
createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
file.initWithPath(param);
|
|
||||||
|
|
||||||
if(file.leafName.substr(-4).toLowerCase() === ".csl"
|
if(file.leafName.substr(-4).toLowerCase() === ".csl"
|
||||||
|| file.leafName.substr(-8).toLowerCase() === ".csl.txt") {
|
|| file.leafName.substr(-8).toLowerCase() === ".csl.txt") {
|
||||||
|
|
|
@ -2284,7 +2284,7 @@ function ServerHandler(server)
|
||||||
this._server = server;
|
this._server = server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A FileMap object containing the set of path->nsILocalFile mappings for
|
* A FileMap object containing the set of path->nsIFile mappings for
|
||||||
* all directory mappings set in the server (e.g., "/" for /var/www/html/,
|
* all directory mappings set in the server (e.g., "/" for /var/www/html/,
|
||||||
* "/foo/bar/" for /local/path/, and "/foo/bar/baz/" for /local/path2).
|
* "/foo/bar/" for /local/path/, and "/foo/bar/baz/" for /local/path2).
|
||||||
*
|
*
|
||||||
|
@ -2717,7 +2717,7 @@ ServerHandler.prototype =
|
||||||
*
|
*
|
||||||
* @param metadata : Request
|
* @param metadata : Request
|
||||||
* the Request for which a response is being generated
|
* the Request for which a response is being generated
|
||||||
* @param file : nsILocalFile
|
* @param file : nsIFile
|
||||||
* the file which is to be sent in the response
|
* the file which is to be sent in the response
|
||||||
* @param response : Response
|
* @param response : Response
|
||||||
* the response to which the file should be written
|
* the response to which the file should be written
|
||||||
|
@ -3057,7 +3057,7 @@ ServerHandler.prototype =
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the nsILocalFile which corresponds to the path, as determined using
|
* Returns the nsIFile which corresponds to the path, as determined using
|
||||||
* all registered path->directory mappings and any paths which are explicitly
|
* all registered path->directory mappings and any paths which are explicitly
|
||||||
* overridden.
|
* overridden.
|
||||||
*
|
*
|
||||||
|
@ -3067,7 +3067,7 @@ ServerHandler.prototype =
|
||||||
* when the correct action is the corresponding HTTP error (i.e., because no
|
* when the correct action is the corresponding HTTP error (i.e., because no
|
||||||
* mapping was found for a directory in path, the referenced file doesn't
|
* mapping was found for a directory in path, the referenced file doesn't
|
||||||
* exist, etc.)
|
* exist, etc.)
|
||||||
* @returns nsILocalFile
|
* @returns nsIFile
|
||||||
* the file to be sent as the response to a request for the path
|
* the file to be sent as the response to a request for the path
|
||||||
*/
|
*/
|
||||||
_getFileForPath: function(path)
|
_getFileForPath: function(path)
|
||||||
|
@ -3432,11 +3432,11 @@ ServerHandler.prototype =
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps absolute paths to files on the local file system (as nsILocalFiles).
|
* Maps absolute paths to files on the local file system (as nsIFiles).
|
||||||
*/
|
*/
|
||||||
function FileMap()
|
function FileMap()
|
||||||
{
|
{
|
||||||
/** Hash which will map paths to nsILocalFiles. */
|
/** Hash which will map paths to nsIFiles. */
|
||||||
this._map = {};
|
this._map = {};
|
||||||
}
|
}
|
||||||
FileMap.prototype =
|
FileMap.prototype =
|
||||||
|
@ -3444,12 +3444,12 @@ FileMap.prototype =
|
||||||
// PUBLIC API
|
// PUBLIC API
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps key to a clone of the nsILocalFile value if value is non-null;
|
* Maps key to a clone of the nsIFile value if value is non-null;
|
||||||
* otherwise, removes any extant mapping for key.
|
* otherwise, removes any extant mapping for key.
|
||||||
*
|
*
|
||||||
* @param key : string
|
* @param key : string
|
||||||
* string to which a clone of value is mapped
|
* string to which a clone of value is mapped
|
||||||
* @param value : nsILocalFile
|
* @param value : nsIFile
|
||||||
* the file to map to key, or null to remove a mapping
|
* the file to map to key, or null to remove a mapping
|
||||||
*/
|
*/
|
||||||
put: function(key, value)
|
put: function(key, value)
|
||||||
|
@ -3461,12 +3461,12 @@ FileMap.prototype =
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a clone of the nsILocalFile mapped to key, or null if no such
|
* Returns a clone of the nsIFile mapped to key, or null if no such
|
||||||
* mapping exists.
|
* mapping exists.
|
||||||
*
|
*
|
||||||
* @param key : string
|
* @param key : string
|
||||||
* key to which the returned file maps
|
* key to which the returned file maps
|
||||||
* @returns nsILocalFile
|
* @returns nsIFile
|
||||||
* a clone of the mapped file, or null if no mapping exists
|
* a clone of the mapped file, or null if no mapping exists
|
||||||
*/
|
*/
|
||||||
get: function(key)
|
get: function(key)
|
||||||
|
@ -5330,7 +5330,7 @@ function server(port, basePath)
|
||||||
if (basePath)
|
if (basePath)
|
||||||
{
|
{
|
||||||
var lp = Cc["@mozilla.org/file/local;1"]
|
var lp = Cc["@mozilla.org/file/local;1"]
|
||||||
.createInstance(Ci.nsILocalFile);
|
.createInstance(Ci.nsIFile);
|
||||||
lp.initWithPath(basePath);
|
lp.initWithPath(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1882,9 +1882,7 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
getter._itemsLeft = items.slice();
|
getter._itemsLeft = items.slice();
|
||||||
|
|
||||||
let exportDir = yield getTempDirectory();
|
let exportDir = yield getTempDirectory();
|
||||||
getter._exportFileDirectory = Components.classes["@mozilla.org/file/local;1"]
|
getter._exportFileDirectory = Zotero.File.pathToFile(exportDir);
|
||||||
.createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
getter._exportFileDirectory.initWithPath(exportDir);
|
|
||||||
|
|
||||||
let legacy = getter.legacy = legacyMode[i];
|
let legacy = getter.legacy = legacyMode[i];
|
||||||
let suffix = legacy ? ' in legacy mode' : '';
|
let suffix = legacy ? ' in legacy mode' : '';
|
||||||
|
@ -1988,9 +1986,7 @@ describe("Zotero.Translate.ItemGetter", function() {
|
||||||
if (!linkToURL) {
|
if (!linkToURL) {
|
||||||
// localPath
|
// localPath
|
||||||
assert.isString(attachment.localPath, prefix + 'localPath is set' + suffix);
|
assert.isString(attachment.localPath, prefix + 'localPath is set' + suffix);
|
||||||
let attachmentFile = Components.classes["@mozilla.org/file/local;1"]
|
let attachmentFile = Zotero.File.pathToFile(attachment.localPath);
|
||||||
.createInstance(Components.interfaces.nsILocalFile);
|
|
||||||
attachmentFile.initWithPath(attachment.localPath);
|
|
||||||
assert.isTrue(attachmentFile.exists(), prefix + 'localPath points to a file' + suffix);
|
assert.isTrue(attachmentFile.exists(), prefix + 'localPath points to a file' + suffix);
|
||||||
assert.isTrue(attachmentFile.equals(attachments[j].getFile()), prefix + 'localPath points to the correct file' + suffix);
|
assert.isTrue(attachmentFile.equals(attachments[j].getFile()), prefix + 'localPath points to the correct file' + suffix);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue