1 system.tar.inc private Archive_Tar::_tarRecToSize($tar_size)

Convert Tar record size to actual size

Parameters

string $tar_size:

Return value

size of tar record in bytes:

File

core/modules/system/system.tar.inc, line 1836

Class

Archive_Tar

Code

private function _tarRecToSize($tar_size) 
 {
  /*
   * First byte of size has a special meaning if bit 7 is set.
   *
   * Bit 7 indicates base-256 encoding if set.
   * Bit 6 is the sign bit.
   * Bits 5:0 are most significant value bits.
   */
  $ch = ord($tar_size[0]);
  if ($ch & 0x80) {
    // Full 12-bytes record is required.
    $rec_str = $tar_size . "\x00";

    $size = ($ch & 0x40) ? -1 : 0;
    $size = ($size << 6) | ($ch & 0x3f);

    for ($num_ch = 1; $num_ch < 12; ++$num_ch) {
      $size = ($size * 256) + ord($rec_str[$num_ch]);
    }

    return $size;

  }
  else {
    return OctDec(trim($tar_size));
  }
}