Using stream_get_contents in file_get_contents implementation + close handle

This commit is contained in:
Thomas Müller 2015-04-02 16:18:10 +02:00
parent ff16e3dbff
commit 8991272269
1 changed files with 7 additions and 12 deletions

View File

@ -112,24 +112,19 @@ class Encryption extends Wrapper {
*/ */
public function file_get_contents($path) { public function file_get_contents($path) {
$data = null;
$encryptionModule = $this->getEncryptionModule($path); $encryptionModule = $this->getEncryptionModule($path);
if ($encryptionModule) { if ($encryptionModule) {
$handle = $this->fopen($path, "r");
$handle = $this->fopen($path, 'r'); if (!$handle) {
return false;
if (is_resource($handle)) {
while (!feof($handle)) {
$data .= fread($handle, $this->util->getBlockSize());
} }
} $data = stream_get_contents($handle);
} else { fclose($handle);
$data = $this->storage->file_get_contents($path);
}
return $data; return $data;
} }
return $this->storage->file_get_contents($path);
}
/** /**
* see http://php.net/manual/en/function.file_put_contents.php * see http://php.net/manual/en/function.file_put_contents.php