You are here

private function Reader::determineFileTypeByHeader in Drupal 7

In case ext-fileinfo is not present only the relevant types 'application/x-gzip' and 'application/x-bzip2' are resolved.

Return value

string

1 call to Reader::determineFileTypeByHeader()
Reader::determineFileType in misc/typo3/phar-stream-wrapper/src/Phar/Reader.php

File

misc/typo3/phar-stream-wrapper/src/Phar/Reader.php, line 173

Class

Reader

Namespace

TYPO3\PharStreamWrapper\Phar

Code

private function determineFileTypeByHeader() {
  $resource = fopen($this->fileName, 'r');
  if (!is_resource($resource)) {
    throw new ReaderException(sprintf('Resource %s could not be opened', $this->fileName), 1557753055);
  }
  $header = fgets($resource, 4);
  fclose($resource);
  $mimeType = '';
  if (strpos($header, "BZh") === 0) {
    $mimeType = 'application/x-bzip2';
  }
  elseif (strpos($header, "") === 0) {
    $mimeType = 'application/x-gzip';
  }
  return $mimeType;
}