Пример #1
0
 public function testDataIsReadInChunks()
 {
     $file = new File('/file');
     $file->setData('1234567');
     $pointer = new FileHandler();
     $pointer->setFile($file);
     $this->assertEquals('12', $pointer->read(2));
     $this->assertEquals(2, $pointer->position());
     $this->assertEquals('345', $pointer->read(3));
     $this->assertEquals(5, $pointer->position());
     $this->assertEquals('67', $pointer->read(10));
     $this->assertEquals(7, $pointer->position());
 }
Пример #2
0
 /**
  * Reads and returns $bytes amount of bytes from stream.
  *
  * @see http://php.net/streamwrapper.stream-read
  *
  * @param int $bytes
  *
  * @return string
  */
 public function stream_read($bytes)
 {
     if (!$this->currently_opened->isOpenedForReading()) {
         return null;
     }
     $data = $this->currently_opened->read($bytes);
     //file access time changes so stat cache needs to be cleared
     clearstatcache();
     return $data;
 }