API16

API16:JStreamString/stream seek

From Joomla! Documentation

Revision as of 22:48, 22 March 2010 by Doxiki (talk | contribs) (New page: <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> {{Description:JStreamString/...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

[Edit Descripton]

Template:Description:JStreamString/stream seek

Syntax

stream_seek($offset, $whence)
Parameter Name Default Value Description
$offset
$whence

Defined in

libraries/joomla/filesystem/streams/string.php

Importing

jimport( 'joomla.filesystem.streams.string' );

Source Body

function stream_seek($offset, $whence) {
        //$whence: SEEK_SET, SEEK_CUR, SEEK_END
        if($offset > $this->_len) {
                return false; // we can't seek beyond our len
        }
        switch($whence)
        {
                case SEEK_SET:
                        $this->_pos = $offset;
                        break;
                case SEEK_CUR:
                        if (($this->_pos + $offset) < $this->_len) {
                                $this->_pos += $offset;
                        }
                        else {
                                return false;
                        }
                        break;
                case SEEK_END:
                        $this->_pos = $this->_len - $offset;
                        break;
        }
        return true;
}

[Edit See Also] Template:SeeAlso:JStreamString/stream seek

Examples

<CodeExamplesForm />