B2G/gecko/toolkit/components/places/tests/head_common.js
/**
 * Reads the data from the specified nsIFile.
 *
 * @param aFile
 *        The nsIFile to read from.
 * @return an array of bytes.
 */
Reads the data from the specified nsIFile.
@param aFile
The nsIFile to read from.
@return an array of bytes.
Reads the data from the specified nsIFile . @param aFile The nsIFile to read from . @return an array of bytes .
function readFileData(aFile) {
  let inputStream = Cc["@mozilla.org/network/file-input-stream;1"].
                    createInstance(Ci.nsIFileInputStream);
  inputStream.init(aFile, 0x01, -1, null);
  let size  = inputStream.available();
  let bytes = readInputStreamData(inputStream);
  if (size != bytes.length) {
    throw "Didn't read expected number of bytes";
  }
  return bytes;
}
function readFileData ( aFile ) { let inputStream = Cc [ "@mozilla.org/network/file-input-stream;1" ] . createInstance ( Ci . nsIFileInputStream ) ; inputStream . init ( aFile , 0x01 , - 1 , null ) ; let size = inputStream . available ( ) ; let bytes = readInputStreamData ( inputStream ) ; if ( size != bytes . length ) { throw "Didn't read expected number of bytes" ; } return bytes ; }
Reads the data from the specified nsIFile.
Reads the data from the specified nsIFile .
// init the stream as RD_ONLY, -1 == default permissions. // Check the returned size versus the expected size.