public function write($data, $cb = null, $offset = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!$this->fd) {
            if ($cb) {
                $cb($this, false);
            }
            return false;
        }
        if ($data === '') {
            if ($cb) {
                $cb($this, 0);
            }
            return false;
        }
        if (!FileSystem::$supported) {
            if ($offset !== null) {
                fseek($data, $offset);
            }
            $r = fwrite($this->fd, $data);
            if ($cb) {
                $cb($this, $r);
            }
            return false;
        }
        if ($cb !== null) {
            $this->onWriteOnce->push($cb);
        }
        $l = mb_orig_strlen($data);
        if ($offset === null) {
            $offset = $this->offset;
            $this->offset += $l;
        }
        $this->writing = true;
        $res = eio_write(
            $this->fd,
            $data,
            $l,
            $offset,
            $pri,
            function ($file, $result) {
                $this->writing = false;
                $this->onWriteOnce->executeAll($file, $result);
            },
            $this
        );
        return $res;
    }
public function write($data, $cb = null, $offset = null, $pri = EIO_PRI_DEFAULT)
    {
        $cb = CallbackWrapper::forceWrap($cb);
        if (!$this->fd) {
            if ($cb) {
                $cb($this, false);
            }
            return false;
        }
        if ($data === '') {
            if ($cb) {
                $cb($this, 0);
            }
            return false;
        }
        if (!FileSystem::$supported) {
            if ($offset !== null) {
                fseek($data, $offset);
            }
            $r = fwrite($this->fd, $data);
            if ($cb) {
                $cb($this, $r);
            }
            return false;
        }
        if ($cb !== null) {
            $this->onWriteOnce->push($cb);
        }
        $l = mb_orig_strlen($data);
        if ($offset === null) {
            $offset = $this->offset;
            $this->offset += $l;
        }
        $this->writing = true;
        $res = eio_write(
            $this->fd,
            $data,
            $l,
            $offset,
            $pri,
            function ($file, $result) {
                $this->writing = false;
                $this->onWriteOnce->executeAll($file, $result);
            },
            $this
        );
        return $res;
    }
public function write ( $ data , $ cb = null , $ offset = null , $ pri = EIO_PRI_DEFAULT ) { $ cb = CallbackWrapper :: forceWrap ( $ cb ) ; if ( ! $ this -> fd ) { if ( $ cb ) { $ cb ( $ this , false ) ; } return false ; } if ( $ data === '' ) { if ( $ cb ) { $ cb ( $ this , 0 ) ; } return false ; } if ( ! FileSystem :: $ supported ) { if ( $ offset !== null ) { fseek ( $ data , $ offset ) ; } $ r = fwrite ( $ this -> fd , $ data ) ; if ( $ cb ) { $ cb ( $ this , $ r ) ; } return false ; } if ( $ cb !== null ) { $ this -> onWriteOnce -> push ( $ cb ) ; } $ l = mb_orig_strlen ( $ data ) ; if ( $ offset === null ) { $ offset = $ this -> offset ; $ this -> offset += $ l ; } $ this -> writing = true ; $ res = eio_write ( $ this -> fd , $ data , $ l , $ offset , $ pri , function ( $ file , $ result ) { $ this -> writing = false ; $ this -> onWriteOnce -> executeAll ( $ file , $ result ) ; } , $ this ) ; return $ res ; }
Writes data to file
@param  string $data Data
@param  callable $cb Callback
@param  integer $offset Offset
@param  integer $pri Priority
@return resource|false
Writes data to file