public function AmazonS3StreamWrapper::stream_seek in AmazonS3 7
Support for fseek().
Parameters
int $offset: The byte offset to got to.
string $whence: SEEK_SET, SEEK_CUR, or SEEK_END.
Return value
bool TRUE on success.
Overrides StreamWrapperInterface::stream_seek
See also
http://php.net/manual/en/streamwrapper.stream-seek.php
File
- ./
AmazonS3StreamWrapper.inc, line 572 - Drupal stream wrapper implementation for Amazon S3
Class
- AmazonS3StreamWrapper
- @file Drupal stream wrapper implementation for Amazon S3
Code
public function stream_seek($offset, $whence) {
switch ($whence) {
case SEEK_CUR:
// Set position to current location plus $offset.
$new_position = $this->position + $offset;
break;
case SEEK_END:
// Set position to eof plus $offset.
$new_position = $this->objectSize + $offset;
break;
case SEEK_SET:
default:
// Set position equal to $offset.
$new_position = $offset;
break;
}
$ret = $new_position >= 0 && $new_position <= $this->objectSize;
if ($ret) {
$this->position = $new_position;
}
return $ret;
}