Bug 1375125 - Fix errors caused by mechanical replacement. r?froydnj draft
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Sat, 05 Aug 2017 08:21:55 +0900
changeset 641143 d4c31501a0590bdb4bb840bcdc6583badb7e711f
parent 641142 639444a0a19ba572eea85ad9e185eeac6ff3e9ff
child 641144 724dd494ed0558e6b552948b1b97a450354ceb3d
push id72449
push userVYV03354@nifty.ne.jp
push dateSat, 05 Aug 2017 22:48:23 +0000
reviewersfroydnj
bugs1375125
milestone57.0a1
Bug 1375125 - Fix errors caused by mechanical replacement. r?froydnj MozReview-Commit-ID: 1kOvLdeCJiR
addon-sdk/source/lib/sdk/io/fs.js
layout/tools/layout-debug/ui/content/layoutdebug.js
toolkit/components/filepicker/content/filepicker.js
xpcom/tests/unit/test_home.js
--- a/addon-sdk/source/lib/sdk/io/fs.js
+++ b/addon-sdk/source/lib/sdk/io/fs.js
@@ -13,17 +13,17 @@ lazyRequire(this, "../timers", "setTimeo
 lazyRequire(this, "./stream", "Stream", "InputStream", "OutputStream");
 lazyRequire(this, "../event/core", "emit", "on");
 lazyRequire(this, "./buffer", "Buffer");
 
 const { ns } = require("../core/namespace");
 const { Class } = require("../core/heritage");
 
 
-const nsIFile = CC("@mozilla.org/file/local;1", "nsIFile",
+const LocalFile = CC("@mozilla.org/file/local;1", "nsIFile",
                         "initWithPath");
 const FileOutputStream = CC("@mozilla.org/network/file-output-stream;1",
                             "nsIFileOutputStream", "init");
 const FileInputStream = CC("@mozilla.org/network/file-input-stream;1",
                            "nsIFileInputStream", "init");
 const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
                              "nsIBinaryInputStream", "setInputStream");
 const BinaryOutputStream = CC("@mozilla.org/binaryoutputstream;1",
@@ -105,17 +105,17 @@ function toArray(enumerator) {
 }
 
 function getFileName(file) {
   return file.QueryInterface(Ci.nsIFile).leafName;
 }
 
 
 function remove(path, recursive) {
-  let fd = new nsIFile(path)
+  let fd = new LocalFile(path)
   if (fd.exists()) {
     fd.remove(recursive || false);
   }
   else {
     throw FSError("remove", "ENOENT", 34, path);
   }
 }
 
@@ -251,17 +251,17 @@ const WriteStream = Class({
 });
 exports.WriteStream = WriteStream;
 exports.createWriteStream = function createWriteStream(path, options) {
   return new WriteStream(path, options);
 };
 
 const Stats = Class({
   initialize: function initialize(path) {
-    let file = new nsIFile(path);
+    let file = new LocalFile(path);
     if (!file.exists()) throw FSError("stat", "ENOENT", 34, path);
     nsIFile(this, file);
   },
   isDirectory: function() {
     return nsIFile(this).isDirectory();
   },
   isFile: function() {
     return nsIFile(this).isFile();
@@ -353,35 +353,35 @@ function Async(wrapped) {
   }
 }
 
 
 /**
  * Synchronous rename(2)
  */
 function renameSync(oldPath, newPath) {
-  let source = new nsIFile(oldPath);
-  let target = new nsIFile(newPath);
+  let source = new LocalFile(oldPath);
+  let target = new LocalFile(newPath);
   if (!source.exists()) throw FSError("rename", "ENOENT", 34, oldPath);
   return source.moveTo(target.parent, target.leafName);
 };
 exports.renameSync = renameSync;
 
 /**
  * Asynchronous rename(2). No arguments other than a possible exception are
  * given to the completion callback.
  */
 var rename = Async(renameSync);
 exports.rename = rename;
 
 /**
  * Test whether or not the given path exists by checking with the file system.
  */
 function existsSync(path) {
-  return new nsIFile(path).exists();
+  return new LocalFile(path).exists();
 }
 exports.existsSync = existsSync;
 
 var exists = Async(existsSync);
 exports.exists = exists;
 
 /**
  * Synchronous ftruncate(2).
@@ -442,17 +442,17 @@ var lchown = Async(lchown);
 exports.lchown = lchown;
 
 /**
  * Synchronous chmod(2).
  */
 function chmodSync (path, mode) {
   let file;
   try {
-    file = new nsIFile(path);
+    file = new LocalFile(path);
   } catch(e) {
     throw FSError("chmod", "ENOENT", 34, path);
   }
 
   file.permissions = Mode(mode);
 }
 exports.chmodSync = chmodSync;
 /**
@@ -553,32 +553,32 @@ exports.symlinkSync = symlinkSync;
  */
 var symlink = Async(symlinkSync);
 exports.symlink = symlink;
 
 /**
  * Synchronous readlink(2). Returns the resolved path.
  */
 function readlinkSync(path) {
-  return new nsIFile(path).target;
+  return new LocalFile(path).target;
 };
 exports.readlinkSync = readlinkSync;
 
 /**
  * Asynchronous readlink(2). The callback gets two arguments
  * `(error, resolvedPath)`.
  */
 var readlink = Async(readlinkSync);
 exports.readlink = readlink;
 
 /**
  * Synchronous realpath(2). Returns the resolved path.
  */
 function realpathSync(path) {
-  return new nsIFile(path).path;
+  return new LocalFile(path).path;
 };
 exports.realpathSync = realpathSync;
 
 /**
  * Asynchronous realpath(2). The callback gets two arguments
  * `(err, resolvedPath)`.
  */
 var realpath = Async(realpathSync);
@@ -610,17 +610,17 @@ exports.rmdirSync = rmdirSync;
 var rmdir = Async(rmdirSync);
 exports.rmdir = rmdir;
 
 /**
  * Synchronous mkdir(2).
  */
 function mkdirSync(path, mode) {
   try {
-    return nsIFile(path).create(DIRECTORY_TYPE, Mode(mode));
+    return LocalFile(path).create(DIRECTORY_TYPE, Mode(mode));
   } catch (error) {
     // Adjust exception thorw to match ones thrown by node.
     if (error.name === "NS_ERROR_FILE_ALREADY_EXISTS") {
       let { fileName, lineNumber } = error;
       error = FSError("mkdir", "EEXIST", 47, path, fileName, lineNumber);
     }
     throw error;
   }
@@ -635,17 +635,17 @@ var mkdir = Async(mkdirSync);
 exports.mkdir = mkdir;
 
 /**
  * Synchronous readdir(3). Returns an array of filenames excluding `"."` and
  * `".."`.
  */
 function readdirSync(path) {
   try {
-    return toArray(new nsIFile(path).directoryEntries).map(getFileName);
+    return toArray(new LocalFile(path).directoryEntries).map(getFileName);
   }
   catch (error) {
     // Adjust exception thorw to match ones thrown by node.
     if (error.name === "NS_ERROR_FILE_TARGET_DOES_NOT_EXIST" ||
         error.name === "NS_ERROR_FILE_NOT_FOUND")
     {
       let { fileName, lineNumber } = error;
       error = FSError("readdir", "ENOENT", 34, path, fileName, lineNumber);
@@ -689,17 +689,17 @@ exports.closeSync = closeSync;
 var close = Async(closeSync);
 exports.close = close;
 
 /**
  * Synchronous open(2).
  */
 function openSync(aPath, aFlag, aMode) {
   let [ fd, flags, mode, file ] =
-      [ { path: aPath }, Flags(aFlag), Mode(aMode), nsIFile(aPath) ];
+      [ { path: aPath }, Flags(aFlag), Mode(aMode), LocalFile(aPath) ];
 
   nsIFile(fd, file);
 
   // If trying to open file for just read that does not exists
   // need to throw exception as node does.
   if (!file.exists() && !isWritable(flags))
     throw FSError("open", "ENOENT", 34, aPath);
 
--- a/layout/tools/layout-debug/ui/content/layoutdebug.js
+++ b/layout/tools/layout-debug/ui/content/layoutdebug.js
@@ -298,17 +298,16 @@ RTestIndexList.prototype = {
   mLDB_Root : null,
   mNC_Child : null,
   mNC_Name : null
 }
 
 const nsIFileInputStream = Components.interfaces.nsIFileInputStream;
 const nsILineInputStream = Components.interfaces.nsILineInputStream;
 const nsIFile = Components.interfaces.nsIFile;
-const nsIFile = Components.interfaces.nsIFile;
 const nsIFileURL = Components.interfaces.nsIFileURL;
 const nsIIOService = Components.interfaces.nsIIOService;
 const nsILayoutRegressionTester = Components.interfaces.nsILayoutRegressionTester;
 
 const NS_LOCAL_FILE_CONTRACTID = "@mozilla.org/file/local;1";
 const IO_SERVICE_CONTRACTID = "@mozilla.org/network/io-service;1";
 const NS_LOCALFILEINPUTSTREAM_CONTRACTID =
           "@mozilla.org/network/file-input-stream;1";
--- a/toolkit/components/filepicker/content/filepicker.js
+++ b/toolkit/components/filepicker/content/filepicker.js
@@ -7,17 +7,16 @@
 const nsIFilePicker       = Components.interfaces.nsIFilePicker;
 const nsIProperties       = Components.interfaces.nsIProperties;
 const NS_DIRECTORYSERVICE_CONTRACTID = "@mozilla.org/file/directory_service;1";
 const NS_IOSERVICE_CONTRACTID = "@mozilla.org/network/io-service;1";
 const nsIFileView = Components.interfaces.nsIFileView;
 const NS_FILEVIEW_CONTRACTID = "@mozilla.org/filepicker/fileview;1";
 const nsITreeView = Components.interfaces.nsITreeView;
 const nsIFile = Components.interfaces.nsIFile;
-const nsIFile = Components.interfaces.nsIFile;
 const NS_LOCAL_FILE_CONTRACTID = "@mozilla.org/file/local;1";
 const NS_PROMPTSERVICE_CONTRACTID = "@mozilla.org/embedcomp/prompt-service;1";
 
 var sfile = Components.classes[NS_LOCAL_FILE_CONTRACTID].createInstance(nsIFile);
 var retvals;
 var filePickerMode;
 var homeDir;
 var treeView;
--- a/xpcom/tests/unit/test_home.js
+++ b/xpcom/tests/unit/test_home.js
@@ -1,14 +1,14 @@
 var Ci = Components.interfaces;
 var Cc = Components.classes;
 
 const CWD = do_get_cwd();
 function checkOS(os) {
-  const nsILocalFile_ = "nsIFile" + os;
+  const nsILocalFile_ = "nsILocalFile" + os;
   return nsILocalFile_ in Components.interfaces &&
          CWD instanceof Components.interfaces[nsILocalFile_];
 }
 
 const isWin = checkOS("Win");
 
 function run_test() {
   var envVar = isWin ? "USERPROFILE" : "HOME";