* This file is part of the ManageWP Worker plugin.
* (c) ManageWP LLC <contact@managewp.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
class MWP_IncrementalBackup_FileReader
private $chunkByteSize = 4096;
public function getChunkByteSize()
return $this->chunkByteSize;
* @param int $chunkByteSize
public function setChunkByteSize($chunkByteSize)
$this->chunkByteSize = $chunkByteSize;
* @param string $realPath
public function readFileContents($realPath, $offset = 0, $limit = 0)
if (!file_exists($realPath)) {
$handle = fopen($realPath, "rb");
$limit = filesize($realPath) - $offset;
$chunkSize = $limit > $this->chunkByteSize ? $this->chunkByteSize : $limit;
$limit = $limit - $chunkSize;
$contentLength = $contentLength + $chunkSize;
$contents = fread($handle, $chunkSize);
$buffer = $buffer.$contents;
return array($buffer, $contentLength);