fread method

int fread(
  1. List<int> ptr,
  2. int size,
  3. int count,
  4. FILE stream,
)

Reads an array of count elements, each one with a size of size bytes, from the stream.

Implementation

int fread(List<int> ptr, int size, int count, FILE stream) {
  try {
    int bytesToRead = size * count;
    int bytesRead = stream._raf.readIntoSync(ptr, 0, bytesToRead);
    if (bytesRead == 0 && bytesToRead > 0) {
      stream._isEOF = true;
    }
    return bytesRead ~/ size;
  } catch (e) {
    return 0;
  }
}