PHPDaemon\FS\File::readAll PHP Method

readAll() public method

Reads whole file
public readAll ( callable $cb, integer $pri = EIO_PRI_DEFAULT ) : boolean
$cb callable Callback
$pri integer Priority
return boolean Success
    public function readAll($cb, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!$this->fd) {
            if ($cb) {
                $cb($this, false);
            }
            return false;
        }
        $this->statRefresh(function ($file, $stat) use($cb, $pri) {
            if (!$stat) {
                if ($cb) {
                    $cb($file, false);
                }
                return;
            }
            $offset = 0;
            $buf = '';
            $size = $stat['size'];
            eio_read($file->fd, min($file->chunkSize, $size), 0, $pri, $this->readAllGenHandler($cb, $size, $offset, $pri, $buf), $file);
        }, $pri);
        return true;
    }