You are here

private function TarArchiveReader::readLongHeader in Backup and Migrate 8.4

Read a tar file header block for files with long names.

Parameters

$header:

Return value

array

Throws

\BackupMigrate\Core\Exception\BackupMigrateException

1 call to TarArchiveReader::readLongHeader()
TarArchiveReader::readHeader in lib/backup_migrate_core/src/Service/TarArchiveReader.php
Read a tar file header block.

File

lib/backup_migrate_core/src/Service/TarArchiveReader.php, line 342

Class

TarArchiveReader
Class TarArchiveReader.

Namespace

BackupMigrate\Core\Service

Code

private function readLongHeader($header) {
  $filename = '';
  $filesize = $header['size'];
  $n = floor($header['size'] / 512);
  for ($i = 0; $i < $n; $i++) {
    $content = $this->archive
      ->readBytes(512);
    $filename .= $content;
  }
  if ($header['size'] % 512 != 0) {
    $content = $this->archive
      ->readBytes(512);
    $filename .= $content;
  }
  $filename = rtrim(substr($filename, 0, $filesize), "\0");

  // Read the next header.
  $data = $this->archive
    ->readBytes(512);
  $header = $this
    ->readHeader($data, $header);
  $header['filename'] = $filename;
  return $header;
}