protected function getRealPath(string $file) : string
{
if (!\file_exists($file)) {
throw new \Error('File not found: ' . $file);
}
if (\strpos($file, $this->session['dir']) === 0) {
$x = Binary::safeStrlen($this->session['dir']);
return Binary::safeSubstr($file, $x + 1);
} elseif ($file[0] !== DIRECTORY_SEPARATOR) {
return $file;
} else {
throw new \Error('File path is outside the root directory: ' . $file);
}
}