B2G/gecko/toolkit/mozapps/extensions/XPIProvider.jsm
/**
   * Reads a directory linked to in a file.
   *
   * @param   file
   *          The file containing the directory path
   * @return  An nsIFile object representing the linked directory.
   */
Reads a directory linked to in a file.
@param   file
The file containing the directory path
@return  An nsIFile object representing the linked directory.
Reads a directory linked to in a file . @param file The file containing the directory path @return An nsIFile object representing the linked directory .
function DirInstallLocation__readDirectoryFromFile(aFile) {
    let fis = Cc["@mozilla.org/network/file-input-stream;1"].
              createInstance(Ci.nsIFileInputStream);
    fis.init(aFile, -1, -1, false);
    let line = { value: "" };
    if (fis instanceof Ci.nsILineInputStream)
      fis.readLine(line);
    fis.close();
    if (line.value) {
      let linkedDirectory = Cc["@mozilla.org/file/local;1"].
                            createInstance(Ci.nsIFile);
      try {
        linkedDirectory.initWithPath(line.value);
      }
      catch (e) {
        linkedDirectory.setRelativeDescriptor(aFile.parent, line.value);
      }
      if (!linkedDirectory.exists()) {
        WARN("File pointer " + aFile.path + " points to " + linkedDirectory.path +
             " which does not exist");
        return null;
      }
      if (!linkedDirectory.isDirectory()) {
        WARN("File pointer " + aFile.path + " points to " + linkedDirectory.path +
             " which is not a directory");
        return null;
      }
      return linkedDirectory;
    }
    WARN("File pointer " + aFile.path + " does not contain a path");
    return null;
  }
function DirInstallLocation__readDirectoryFromFile ( aFile ) { let fis = Cc [ "@mozilla.org/network/file-input-stream;1" ] . createInstance ( Ci . nsIFileInputStream ) ; fis . init ( aFile , - 1 , - 1 , false ) ; let line = { value : "" } ; if ( fis instanceof Ci . nsILineInputStream ) fis . readLine ( line ) ; fis . close ( ) ; if ( line . value ) { let linkedDirectory = Cc [ "@mozilla.org/file/local;1" ] . createInstance ( Ci . nsIFile ) ; try { linkedDirectory . initWithPath ( line . value ) ; } catch ( e ) { linkedDirectory . setRelativeDescriptor ( aFile . parent , line . value ) ; } if ( ! linkedDirectory . exists ( ) ) { WARN ( "File pointer " + aFile . path + " points to " + linkedDirectory . path + " which does not exist" ) ; return null ; } if ( ! linkedDirectory . isDirectory ( ) ) { WARN ( "File pointer " + aFile . path + " points to " + linkedDirectory . path + " which is not a directory" ) ; return null ; } return linkedDirectory ; } WARN ( "File pointer " + aFile . path + " does not contain a path" ) ; return null ; }
Reads a directory linked to in a file.
Reads a directory linked to in a file .