Example #1
0
 /**
  * @inheritdoc
  */
 public function truncate($size)
 {
     if (!$this->stream->isAccessible()) {
         throw new Exception\IOException('Invalid stream resource');
     }
     if (!@ftruncate($this->stream->getResource(), $size)) {
         throw new Exception\IOException('Unexpected result of operation');
     }
     return $this;
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function read($length = 1)
 {
     if (!$this->stream->isAccessible()) {
         throw new Exception\IOException('Invalid stream resource');
     }
     $data = @fread($this->stream->getResource(), $length);
     if (false === $data) {
         throw new Exception\IOException('Unexpected result of operation');
     }
     return $data;
 }