lib/magento/Archive/Tar.php
protected function _parseHeader(&$pointer)
    {
        $firstLine = fread($pointer, 512);

        if (strlen($firstLine)<512){
            return false;
        }

        $fmt = self::_getFormatParseHeader();
        $header = unpack ($fmt, $firstLine);

        $header['mode']=$header['mode']+0;
        $header['uid']=octdec($header['uid']);
        $header['gid']=octdec($header['gid']);
        $header['size']=octdec($header['size']);
        $header['mtime']=octdec($header['mtime']);
        $header['checksum']=octdec($header['checksum']);

        if ($header['type'] == "5") {
            $header['size'] = 0;
        }

        $checksum = 0;
        $firstLine = substr_replace($firstLine, '        ', 148, 8);
        for ($i = 0; $i < 512; $i++) {
            $checksum += ord(substr($firstLine, $i, 1));
        }

        $isUstar = 'ustar' == strtolower(substr($header['magic'], 0, 5));

        $checksumOk = $header['checksum'] == $checksum;
        if (isset($header['name']) && $checksumOk) {
            if ($header['name'] == '././@LongLink' && $header['type'] == 'L') {
                $realName = substr(fread($pointer, floor(($header['size'] + 512 - 1) / 512) * 512), 0, $header['size']);
                $headerMain = $this->_parseHeader($pointer);
                $headerMain['name'] = $realName;
                return $headerMain;
            } else {
                if ($header['size']>0) {
                    $header['data'] = substr(fread($pointer, floor(($header['size'] + 512 - 1) / 512) * 512), 0, $header['size']);
                } else {
                    $header['data'] = '';
                }
                return $header;
            }
        }
        return false;
    }
protected function _parseHeader(&$pointer)
    {
        $firstLine = fread($pointer, 512);

        if (strlen($firstLine)<512){
            return false;
        }

        $fmt = self::_getFormatParseHeader();
        $header = unpack ($fmt, $firstLine);

        $header['mode']=$header['mode']+0;
        $header['uid']=octdec($header['uid']);
        $header['gid']=octdec($header['gid']);
        $header['size']=octdec($header['size']);
        $header['mtime']=octdec($header['mtime']);
        $header['checksum']=octdec($header['checksum']);

        if ($header['type'] == "5") {
            $header['size'] = 0;
        }

        $checksum = 0;
        $firstLine = substr_replace($firstLine, '        ', 148, 8);
        for ($i = 0; $i < 512; $i++) {
            $checksum += ord(substr($firstLine, $i, 1));
        }

        $isUstar = 'ustar' == strtolower(substr($header['magic'], 0, 5));

        $checksumOk = $header['checksum'] == $checksum;
        if (isset($header['name']) && $checksumOk) {
            if ($header['name'] == '././@LongLink' && $header['type'] == 'L') {
                $realName = substr(fread($pointer, floor(($header['size'] + 512 - 1) / 512) * 512), 0, $header['size']);
                $headerMain = $this->_parseHeader($pointer);
                $headerMain['name'] = $realName;
                return $headerMain;
            } else {
                if ($header['size']>0) {
                    $header['data'] = substr(fread($pointer, floor(($header['size'] + 512 - 1) / 512) * 512), 0, $header['size']);
                } else {
                    $header['data'] = '';
                }
                return $header;
            }
        }
        return false;
    }
protected function _parseHeader ( & $ pointer ) { $ firstLine = fread ( $ pointer , 512 ) ; if ( strlen ( $ firstLine ) < 512 ) { return false ; } $ fmt = self :: _getFormatParseHeader ( ) ; $ header = unpack ( $ fmt , $ firstLine ) ; $ header [ 'mode' ] = $ header [ 'mode' ] + 0 ; $ header [ 'uid' ] = octdec ( $ header [ 'uid' ] ) ; $ header [ 'gid' ] = octdec ( $ header [ 'gid' ] ) ; $ header [ 'size' ] = octdec ( $ header [ 'size' ] ) ; $ header [ 'mtime' ] = octdec ( $ header [ 'mtime' ] ) ; $ header [ 'checksum' ] = octdec ( $ header [ 'checksum' ] ) ; if ( $ header [ 'type' ] == "5" ) { $ header [ 'size' ] = 0 ; } $ checksum = 0 ; $ firstLine = substr_replace ( $ firstLine , '        ' , 148 , 8 ) ; for ( $ i = 0 ; $ i < 512 ; $ i ++ ) { $ checksum += ord ( substr ( $ firstLine , $ i , 1 ) ) ; } $ isUstar = 'ustar' == strtolower ( substr ( $ header [ 'magic' ] , 0 , 5 ) ) ; $ checksumOk = $ header [ 'checksum' ] == $ checksum ; if ( isset ( $ header [ 'name' ] ) && $ checksumOk ) { if ( $ header [ 'name' ] == '././@LongLink' && $ header [ 'type' ] == 'L' ) { $ realName = substr ( fread ( $ pointer , floor ( ( $ header [ 'size' ] + 512 - 1 ) / 512 ) * 512 ) , 0 , $ header [ 'size' ] ) ; $ headerMain = $ this -> _parseHeader ( $ pointer ) ; $ headerMain [ 'name' ] = $ realName ; return $ headerMain ; } else { if ( $ header [ 'size' ] > 0 ) { $ header [ 'data' ] = substr ( fread ( $ pointer , floor ( ( $ header [ 'size' ] + 512 - 1 ) / 512 ) * 512 ) , 0 , $ header [ 'size' ] ) ; } else { $ header [ 'data' ] = '' ; } return $ header ; } } return false ; }
Get header from TAR string and unpacked it by format.

@deprecated after 1.7.0.0
@param resource $pointer
@return string
Get header from TAR string and unpacked it by format .