title: How do you convert a local URI to path?
body: <p>How do you convert a local (filesystem) URI to path?<br>
  It can be done with <code>nsIIOService</code> + <code>newURI()</code> + <code>QueryInterface(Components.interfaces.nsIFileURL)</code> + <code>file.path</code> but that seems like a long way.<br>
  Is there a shorter way?</p>
  
  <p>Here is an example code:</p>
  
  <pre><code>var aFileURL = 'file:///C:/path-to-local-file/root.png';
  var ios = Components.classes["@mozilla.org/network/io-service;1"]
                .getService(Components.interfaces.nsIIOService);
  var url = ios.newURI(aFileURL, null, null); // url is a nsIURI
  
  // file is a nsIFile    
  var file = url.QueryInterface(Components.interfaces.nsIFileURL).file;
  
  console.log(file.path); // "C:\path-to-local-file\root.png"
  </code></pre>