/** * Copies a specified number of bytes from one stream to another. * * @param Stream $source Source stream * @param int $count Number of bytes * * @return int Number of bytes copied. */ public function copyFrom(Stream $source, $count) { $maxBufSize = 0xf000; if ($count == 0) { $source->position = 0; $count = $source->size; } $result = $count; $bufSize = $count > $maxBufSize ? $maxBufSize : $count; while ($count != 0) { $n = $count > $bufSize ? $bufSize : $count; $source->readBuffer($buffer, $n); $this->writeBuffer($buffer, $n); $count -= $n; } return $result; }