PHPDaemon\FS\File::readAllChunked PHP Method

readAllChunked() public method

Reads file chunk-by-chunk
public readAllChunked ( callable $cb = null, callable $chunkcb = null, integer $pri = EIO_PRI_DEFAULT ) : resource | false
$cb callable Callback
$chunkcb callable Callback of chunk
$pri integer Priority
return resource | false
    public function readAllChunked($cb = null, $chunkcb = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!$this->fd) {
            if ($cb) {
                $cb($this, false);
            }
            return false;
        }
        return $this->statRefresh(function ($file, $stat) use($cb, $chunkcb, $pri) {
            if (!$stat) {
                $cb($file, false);
                return;
            }
            $offset = 0;
            $size = $stat['size'];
            eio_read($file->fd, min($file->chunkSize, $size), $offset, $pri, $this->readAllChunkedGenHandler($cb, $chunkcb, $size, $offset, $pri), $file);
        }, $pri);
    }