code: function getLocalFileFromNativePathOrUrl(aPathOrUrl) {
    if (aPathOrUrl.substring(0,7) == "file://") {
      // if this is a URL, get the file from that
      let ioSvc = Cc["@mozilla.org/network/io-service;1"]
                     .getService(Ci.nsIIOService);
  
      // XXX it's possible that using a null char-set here is bad
      const fileUrl = ioSvc.newURI(aPathOrUrl, null, null)
                           .QueryInterface(Ci.nsIFileURL);
      return fileUrl.file.clone().QueryInterface(Ci.nsILocalFile);
    } else {
      // if it's a pathname, create the nsILocalFile directly
      var f = new nsLocalFile(aPathOrUrl);
      return f;
    }
  }
docs: Get a local file from a native path or URL
  
  @param {string} aPathOrUrl
  Native path or URL of the file
  @see http://mxr.mozilla.org/mozilla-central/source/toolkit/mozapps/downloads/content/downloads.js#1309