FOF30\Utils\Buffer::stream_seek PHP Method

stream_seek() public method

The read write position updates in response to $offset and $whence
See also: streamWrapper::stream_seek
Since: 11.1
public stream_seek ( integer $offset, integer $whence ) : boolean
$offset integer The offset in bytes
$whence integer Position the offset is added to Options are SEEK_SET, SEEK_CUR, and SEEK_END
return boolean True if updated
    public function stream_seek($offset, $whence)
    {
        switch ($whence) {
            case SEEK_SET:
                if ($offset < strlen(static::$buffers[$this->name]) && $offset >= 0) {
                    $this->position = $offset;
                    return true;
                } else {
                    return false;
                }
                break;
            case SEEK_CUR:
                if ($offset >= 0) {
                    $this->position += $offset;
                    return true;
                } else {
                    return false;
                }
                break;
            case SEEK_END:
                if (strlen(static::$buffers[$this->name]) + $offset >= 0) {
                    $this->position = strlen(static::$buffers[$this->name]) + $offset;
                    return true;
                } else {
                    return false;
                }
                break;
            default:
                return false;
        }
    }