Esempio n. 1
0
 /**
  * call stream_seek() from parent class
  *
  * @param integer $position
  * @return bool
  */
 protected function parentStreamSeek($position)
 {
     return parent::stream_seek($position);
 }
Esempio n. 2
0
 public function stream_seek($offset, $whence = SEEK_SET)
 {
     $return = false;
     switch ($whence) {
         case SEEK_SET:
             if ($offset < $this->unencryptedSize && $offset >= 0) {
                 $newPosition = $offset;
             }
             break;
         case SEEK_CUR:
             if ($offset >= 0) {
                 $newPosition = $offset + $this->position;
             }
             break;
         case SEEK_END:
             if ($this->unencryptedSize + $offset >= 0) {
                 $newPosition = $this->unencryptedSize + $offset;
             }
             break;
         default:
             return $return;
     }
     $newFilePosition = floor($newPosition / $this->unencryptedBlockSize) * $this->util->getBlockSize() + $this->util->getHeaderSize();
     $oldFilePosition = parent::stream_tell();
     if (parent::stream_seek($newFilePosition)) {
         parent::stream_seek($oldFilePosition);
         $this->flush();
         parent::stream_seek($newFilePosition);
         $this->position = $newPosition;
         $return = true;
     }
     return $return;
 }