B2G/gecko/toolkit/components/osfile/osfile_shared_front.jsm
/**
   * Read bytes from this file to an existing buffer.
   *
   * Note that, by default, this function may perform several I/O
   * operations to ensure that the buffer is as full as possible.
   *
   * @param {Typed Array | C pointer} buffer The buffer in which to
   * store the bytes. The buffer must be large enough to
   * accomodate |bytes| bytes.
   * @param {*=} options Optionally, an object that may contain the
   * following fields:
   * - {number} bytes The number of |bytes| to write from the buffer. If
   * unspecified, this is |buffer.byteLength|. Note that |bytes| is required
   * if |buffer| is a C pointer.
   *
   * @return {number} The number of bytes actually read, which may be
   * less than |bytes| if the file did not contain that many bytes left.
   */
Read bytes from this file to an existing buffer.
Note that, by default, this function may perform several I/O
operations to ensure that the buffer is as full as possible.

@param {Typed Array | C pointer} buffer The buffer in which to
store the bytes. The buffer must be large enough to
accomodate |bytes| bytes.
@param {*=} options Optionally, an object that may contain the
following fields:
- {number} bytes The number of |bytes| to write from the buffer. If
unspecified, this is |buffer.byteLength|. Note that |bytes| is required
if |buffer| is a C pointer.

@return {number} The number of bytes actually read, which may be
less than |bytes| if the file did not contain that many bytes left.
Read bytes from this file to an existing buffer . Note that by default this function may perform several I / O operations to ensure that the buffer is as full as possible . @param { Typed Array | C pointer } buffer The buffer in which to store the bytes . The buffer must be large enough to accomodate |bytes| bytes . @param { * = } options Optionally an object that may contain the following fields : - { number } bytes The number of |bytes| to write from the buffer . If unspecified this is |buffer . byteLength| . Note that |bytes| is required if |buffer| is a C pointer . @return { number } The number of bytes actually read which may be less than |bytes| if the file did not contain that many bytes left .
function readTo(buffer, options) {
    options = options || noOptions;
    let {ptr, bytes} = AbstractFile.normalizeToPointer(buffer, options.bytes);
    let pos = 0;
    while (pos < bytes) {
      let chunkSize = this._read(ptr, bytes - pos, options);
      if (chunkSize == 0) {
        break;
      }
      pos += chunkSize;
      ptr = exports.OS.Shared.offsetBy(ptr, chunkSize);
    }
    return pos;
  }
function readTo ( buffer , options ) { options = options || noOptions ; let { ptr , bytes } = AbstractFile . normalizeToPointer ( buffer , options . bytes ) ; let pos = 0 ; while ( pos < bytes ) { let chunkSize = this . _read ( ptr , bytes - pos , options ) ; if ( chunkSize == 0 ) { break ; } pos += chunkSize ; ptr = exports . OS . Shared . offsetBy ( ptr , chunkSize ) ; } return pos ; }
Read bytes from this file to an existing buffer.
Read bytes from this file to an existing buffer .