Exemplo n.º 1
0
	/**
	 * read block to file
	 */
	protected function readCache() {
		// cache should always be empty string when this function is called
		// don't try to fill the cache when trying to write at the end of the unencrypted file when it coincides with new block
		if ($this->cache === '' && !($this->position === $this->unencryptedSize && ($this->position % $this->unencryptedBlockSize) === 0)) {
			// Get the data from the file handle
			$data = parent::stream_read($this->util->getBlockSize());
			$this->cache = $this->encryptionModule->decrypt($data);
		}
	}
Exemplo n.º 2
0
 /**
  * read block to file
  */
 protected function readCache()
 {
     // cache should always be empty string when this function is called
     // don't try to fill the cache when trying to write at the end of the unencrypted file when it coincides with new block
     if ($this->cache === '' && !($this->position === $this->unencryptedSize && $this->position % $this->unencryptedBlockSize === 0)) {
         // Get the data from the file handle
         $data = parent::stream_read($this->util->getBlockSize());
         $position = (int) floor($this->position / $this->unencryptedBlockSize);
         $numberOfChunks = (int) ($this->unencryptedSize / $this->unencryptedBlockSize);
         if ($numberOfChunks === $position) {
             $position .= 'end';
         }
         $this->cache = $this->encryptionModule->decrypt($data, $position);
     }
 }