public static function readfileChunked($path, $cb, $chunkcb, $pri = EIO_PRI_DEFAULT)
{
$cb = CallbackWrapper::forceWrap($cb);
if (!FileSystem::$supported) {
$chunkcb($path, $r = readfile($path));
$cb($r !== false);
return;
}
FileSystem::open($path, 'r!', function ($file) use($path, $cb, $chunkcb, $pri) {
if (!$file) {
$cb($path, false);
return;
}
$file->readAllChunked($cb, $chunkcb, $pri);
}, null, $pri);
}
/** * Read request body from the file given in REQUEST_BODY_FILE parameter * @return boolean Success */ public function readBodyFile() { if (!isset($this->attrs->server['REQUEST_BODY_FILE'])) { return false; } FileSystem::readfileChunked($this->attrs->server['REQUEST_BODY_FILE'], function ($file, $success) { $this->attrs->inputDone = true; if ($this->sleepTime === 0) { $this->wakeup(); } }, function ($file, $chunk) { // readed chunk $this->stdin($chunk); }); return true; }