Habari\HiEngineParser::stream_seek PHP Метод

stream_seek() публичный Метод

Seek to a specific position within the stream
public stream_seek ( integer $offset, integer $whence ) : boolean
$offset integer The offset from the specified position
$whence integer The position to seek from
Результат boolean true if seek was successful
    function stream_seek($offset, $whence)
    {
        switch ($whence) {
            case SEEK_SET:
                if ($offset < strlen($this->file) && $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($this->file) + $offset >= 0) {
                    $this->position = strlen($this->file) + $offset;
                    return true;
                } else {
                    return false;
                }
                break;
            default:
                return false;
        }
    }