private function Reader::extractData in Drupal 7
Parameters
string $fileName e.g. '/path/file.phar' or 'compress.zlib:///path/file.phar':
Return value
array
1 call to Reader::extractData()
- Reader::resolveContainer in misc/
typo3/ phar-stream-wrapper/ src/ Phar/ Reader.php
File
- misc/
typo3/ phar-stream-wrapper/ src/ Phar/ Reader.php, line 87
Class
Namespace
TYPO3\PharStreamWrapper\PharCode
private function extractData($fileName) {
$stubContent = null;
$manifestContent = null;
$manifestLength = null;
$resource = fopen($fileName, 'r');
if (!is_resource($resource)) {
throw new ReaderException(sprintf('Resource %s could not be opened', $fileName), 1547902055);
}
while (!feof($resource)) {
$line = fgets($resource);
// stop reading file when manifest can be extracted
if ($manifestLength !== null && $manifestContent !== null && strlen($manifestContent) >= $manifestLength) {
break;
}
$manifestPosition = strpos($line, '__HALT_COMPILER();');
// first line contains start of manifest
if ($stubContent === null && $manifestContent === null && $manifestPosition !== false) {
$stubContent = substr($line, 0, $manifestPosition - 1);
$manifestContent = preg_replace('#^.*__HALT_COMPILER\\(\\);(?>[ \\n]\\?>(?>\\r\\n|\\n)?)?#', '', $line);
$manifestLength = $this
->resolveManifestLength($manifestContent);
// line contains start of stub
}
elseif ($stubContent === null) {
$stubContent = $line;
// line contains start of manifest
}
elseif ($manifestContent === null && $manifestPosition !== false) {
$manifestContent = preg_replace('#^.*__HALT_COMPILER\\(\\);(?>[ \\n]\\?>(?>\\r\\n|\\n)?)?#', '', $line);
$manifestLength = $this
->resolveManifestLength($manifestContent);
// manifest has been started (thus is cannot be stub anymore), add content
}
elseif ($manifestContent !== null) {
$manifestContent .= $line;
$manifestLength = $this
->resolveManifestLength($manifestContent);
// stub has been started (thus cannot be manifest here, yet), add content
}
elseif ($stubContent !== null) {
$stubContent .= $line;
}
}
fclose($resource);
return array(
'stubContent' => $stubContent,
'manifestContent' => $manifestContent,
'manifestLength' => $manifestLength,
);
}