B2G/gecko/toolkit/mozapps/update/test/shared.js
/**
 * Reads text from a file and returns the string.
 *
 * @param  aFile
 *         The file to read from.
 * @return The string of text read from the file.
 */
Reads text from a file and returns the string.
@param  aFile
The file to read from.
@return The string of text read from the file.
Reads text from a file and returns the string . @param aFile The file to read from . @return The string of text read from the file .
function readFile(aFile) {
  var fis = AUS_Cc["@mozilla.org/network/file-input-stream;1"].
            createInstance(AUS_Ci.nsIFileInputStream);
  if (!aFile.exists())
    return null;
  fis.init(aFile, MODE_RDONLY, PERMS_FILE, 0);
  var sis = AUS_Cc["@mozilla.org/scriptableinputstream;1"].
            createInstance(AUS_Ci.nsIScriptableInputStream);
  sis.init(fis);
  var text = sis.read(sis.available());
  sis.close();
  return text;
}
function readFile ( aFile ) { var fis = AUS_Cc [ "@mozilla.org/network/file-input-stream;1" ] . createInstance ( AUS_Ci . nsIFileInputStream ) ; if ( ! aFile . exists ( ) ) return null ; fis . init ( aFile , MODE_RDONLY , PERMS_FILE , 0 ) ; var sis = AUS_Cc [ "@mozilla.org/scriptableinputstream;1" ] . createInstance ( AUS_Ci . nsIScriptableInputStream ) ; sis . init ( fis ) ; var text = sis . read ( sis . available ( ) ) ; sis . close ( ) ; return text ; }
Reads text from a file and returns the string.
Reads text from a file and returns the string .