func (tr *Reader) readOldGNUSparseMap(header []byte) []sparseEntry {
	isExtended := header[oldGNUSparseMainHeaderIsExtendedOffset] != 0
	spCap := oldGNUSparseMainHeaderNumEntries
	if isExtended {
		spCap += oldGNUSparseExtendedHeaderNumEntries
	}
	sp := make([]sparseEntry, 0, spCap)
	s := slicer(header[oldGNUSparseMainHeaderOffset:])

	// Read the four entries from the main tar header
	for i := 0; i < oldGNUSparseMainHeaderNumEntries; i++ {
		offset := tr.octal(s.next(oldGNUSparseOffsetSize))
		numBytes := tr.octal(s.next(oldGNUSparseNumBytesSize))
		if tr.err != nil {
			tr.err = ErrHeader
			return nil
		}
		if offset == 0 && numBytes == 0 {
			break
		}
		sp = append(sp, sparseEntry{offset: offset, numBytes: numBytes})
	}

	for isExtended {
		// There are more entries. Read an extension header and parse its entries.
		sparseHeader := make([]byte, blockSize)
		if _, tr.err = io.ReadFull(tr.r, sparseHeader); tr.err != nil {
			return nil
		}
		isExtended = sparseHeader[oldGNUSparseExtendedHeaderIsExtendedOffset] != 0
		s = slicer(sparseHeader)
		for i := 0; i < oldGNUSparseExtendedHeaderNumEntries; i++ {
			offset := tr.octal(s.next(oldGNUSparseOffsetSize))
			numBytes := tr.octal(s.next(oldGNUSparseNumBytesSize))
			if tr.err != nil {
				tr.err = ErrHeader
				return nil
			}
			if offset == 0 && numBytes == 0 {
				break
			}
			sp = append(sp, sparseEntry{offset: offset, numBytes: numBytes})
		}
	}
	return sp
}
// readOldGNUSparseMap reads the sparse map as stored in the old GNU sparse format.
// The sparse map is stored in the tar header if it's small enough. If it's larger than four entries,
// then one or more extension headers are used to store the rest of the sparse map.
readOldGNUSparseMap reads the sparse map as stored in the old GNU sparse format.
The sparse map is stored in the tar header if it's small enough. If it's larger than four entries,
then one or more extension headers are used to store the rest of the sparse map.
// readOldGNUSparseMap reads the sparse map as stored in the old GNU sparse format . // The sparse map is stored in the tar header if it ' s small enough . If it ' s larger than four entries // then one or more extension headers are used to store the rest of the sparse map .
func (tr *Reader) readOldGNUSparseMap(header []byte) []sparseEntry {
	isExtended := header[oldGNUSparseMainHeaderIsExtendedOffset] != 0
	spCap := oldGNUSparseMainHeaderNumEntries
	if isExtended {
		spCap += oldGNUSparseExtendedHeaderNumEntries
	}
	sp := make([]sparseEntry, 0, spCap)
	s := slicer(header[oldGNUSparseMainHeaderOffset:])
	for i := 0; i < oldGNUSparseMainHeaderNumEntries; i++ {
		offset := tr.octal(s.next(oldGNUSparseOffsetSize))
		numBytes := tr.octal(s.next(oldGNUSparseNumBytesSize))
		if tr.err != nil {
			tr.err = ErrHeader
			return nil
		}
		if offset == 0 && numBytes == 0 {
			break
		}
		sp = append(sp, sparseEntry{offset: offset, numBytes: numBytes})
	}
	for isExtended {
		sparseHeader := make([]byte, blockSize)
		if _, tr.err = io.ReadFull(tr.r, sparseHeader); tr.err != nil {
			return nil
		}
		isExtended = sparseHeader[oldGNUSparseExtendedHeaderIsExtendedOffset] != 0
		s = slicer(sparseHeader)
		for i := 0; i < oldGNUSparseExtendedHeaderNumEntries; i++ {
			offset := tr.octal(s.next(oldGNUSparseOffsetSize))
			numBytes := tr.octal(s.next(oldGNUSparseNumBytesSize))
			if tr.err != nil {
				tr.err = ErrHeader
				return nil
			}
			if offset == 0 && numBytes == 0 {
				break
			}
			sp = append(sp, sparseEntry{offset: offset, numBytes: numBytes})
		}
	}
	return sp
}
func ( tr * Reader ) readOldGNUSparseMap ( header [ ] byte ) [ ] sparseEntry { isExtended := header [ oldGNUSparseMainHeaderIsExtendedOffset ] != 0 spCap := oldGNUSparseMainHeaderNumEntries if isExtended { spCap += oldGNUSparseExtendedHeaderNumEntries } sp := make ( [ ] sparseEntry , 0 , spCap ) s := slicer ( header [ oldGNUSparseMainHeaderOffset : ] ) for i := 0 ; i < oldGNUSparseMainHeaderNumEntries ; i ++ { offset := tr . octal ( s . next ( oldGNUSparseOffsetSize ) ) numBytes := tr . octal ( s . next ( oldGNUSparseNumBytesSize ) ) if tr . err != nil { tr . err = ErrHeader return nil } if offset == 0 && numBytes == 0 { break } sp = append ( sp , sparseEntry { offset : offset , numBytes : numBytes } ) } for isExtended { sparseHeader := make ( [ ] byte , blockSize ) if _ , tr . err = io . ReadFull ( tr . r , sparseHeader ) ; tr . err != nil { return nil } isExtended = sparseHeader [ oldGNUSparseExtendedHeaderIsExtendedOffset ] != 0 s = slicer ( sparseHeader ) for i := 0 ; i < oldGNUSparseExtendedHeaderNumEntries ; i ++ { offset := tr . octal ( s . next ( oldGNUSparseOffsetSize ) ) numBytes := tr . octal ( s . next ( oldGNUSparseNumBytesSize ) ) if tr . err != nil { tr . err = ErrHeader return nil } if offset == 0 && numBytes == 0 { break } sp = append ( sp , sparseEntry { offset : offset , numBytes : numBytes } ) } } return sp }
readOldGNUSparseMap reads the sparse map as stored in the old GNU sparse format.
readOldGNUSparseMap reads the sparse map as stored in the old GNU sparse format .
// Read the four entries from the main tar header // There are more entries. Read an extension header and parse its entries.