API16:JStream/seek
From Joomla! Documentation
Description
Seek the file Note: the return value is different to that of fseek
Syntax
seek($offset, $whence=SEEK_SET)
| Parameter Name | Default Value | Description |
|---|---|---|
| $offset | Offset to use when seeking | |
| $whence | SEEK_SET | Seek mode to use |
Returns
boolean True on success, false on failure
Defined in
libraries/joomla/filesystem/stream.php
Importing
jimport( 'joomla.filesystem.stream' );
Source Body
function seek($offset, $whence=SEEK_SET)
{
if(!$this->_fh)
{
$this->setError(JText::_('File not open'));
return false;
}
$retval = false;
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
switch($this->processingmethod)
{
case 'gz':
$res = gzseek($this->_fh, $offset, $whence);
break;
case 'bz':
case 'f':
default:
$res = fseek($this->_fh, $offset, $whence);
break;
}
// seek, interestingly returns 0 on success or -1 on failure
if($res == -1) {
$this->setError($php_errormsg);
} else {
$retval = true;
}
// restore error tracking to what it was before
ini_set('track_errors',$track_errors);
// return the result
return $retval;
}
Examples
Code Examples