PHPDaemon\FS\File::read PHP Méthode

read() public méthode

Reads data from file
public read ( integer $length, integer $offset = null, callable $cb = null, integer $pri = EIO_PRI_DEFAULT ) : boolean
$length integer Length
$offset integer Offset
$cb callable Callback
$pri integer Priority
Résultat boolean
    public function read($length, $offset = null, $cb = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!$this->fd) {
            if ($cb) {
                $cb($this, false);
            }
            return false;
        }
        if (!FileSystem::$supported) {
            if ($offset !== null) {
                fseek($this->fd, $length);
            }
            $data = fread($this->fd, $length);
            $cb === null || $cb($this, $data);
            return $data;
        }
        $this->offset += $length;
        eio_read($this->fd, $length, $offset !== null ? $offset : $this->offset, $pri, $cb, $this);
        return true;
    }