func (tr *Reader) checkForGNUSparsePAXHeaders(hdr *Header, headers map[string]string) ([]sparseEntry, error) {
	var sparseFormat string

	// Check for sparse format indicators
	major, majorOk := headers[paxGNUSparseMajor]
	minor, minorOk := headers[paxGNUSparseMinor]
	sparseName, sparseNameOk := headers[paxGNUSparseName]
	_, sparseMapOk := headers[paxGNUSparseMap]
	sparseSize, sparseSizeOk := headers[paxGNUSparseSize]
	sparseRealSize, sparseRealSizeOk := headers[paxGNUSparseRealSize]

	// Identify which, if any, sparse format applies from which PAX headers are set
	if majorOk && minorOk {
		sparseFormat = major + "." + minor
	} else if sparseNameOk && sparseMapOk {
		sparseFormat = "0.1"
	} else if sparseSizeOk {
		sparseFormat = "0.0"
	} else {
		// Not a PAX format GNU sparse file.
		return nil, nil
	}

	// Check for unknown sparse format
	if sparseFormat != "0.0" && sparseFormat != "0.1" && sparseFormat != "1.0" {
		return nil, nil
	}

	// Update hdr from GNU sparse PAX headers
	if sparseNameOk {
		hdr.Name = sparseName
	}
	if sparseSizeOk {
		realSize, err := strconv.ParseInt(sparseSize, 10, 0)
		if err != nil {
			return nil, ErrHeader
		}
		hdr.Size = realSize
	} else if sparseRealSizeOk {
		realSize, err := strconv.ParseInt(sparseRealSize, 10, 0)
		if err != nil {
			return nil, ErrHeader
		}
		hdr.Size = realSize
	}

	// Set up the sparse map, according to the particular sparse format in use
	var sp []sparseEntry
	var err error
	switch sparseFormat {
	case "0.0", "0.1":
		sp, err = readGNUSparseMap0x1(headers)
	case "1.0":
		sp, err = readGNUSparseMap1x0(tr.curr)
	}
	return sp, err
}
// checkForGNUSparsePAXHeaders checks the PAX headers for GNU sparse headers. If they are found, then
// this function reads the sparse map and returns it. Unknown sparse formats are ignored, causing the file to
// be treated as a regular file.
checkForGNUSparsePAXHeaders checks the PAX headers for GNU sparse headers. If they are found, then
this function reads the sparse map and returns it. Unknown sparse formats are ignored, causing the file to
be treated as a regular file.
// checkForGNUSparsePAXHeaders checks the PAX headers for GNU sparse headers . If they are found then // this function reads the sparse map and returns it . Unknown sparse formats are ignored causing the file to // be treated as a regular file .
func (tr *Reader) checkForGNUSparsePAXHeaders(hdr *Header, headers map[string]string) ([]sparseEntry, error) {
	var sparseFormat string
	major, majorOk := headers[paxGNUSparseMajor]
	minor, minorOk := headers[paxGNUSparseMinor]
	sparseName, sparseNameOk := headers[paxGNUSparseName]
	_, sparseMapOk := headers[paxGNUSparseMap]
	sparseSize, sparseSizeOk := headers[paxGNUSparseSize]
	sparseRealSize, sparseRealSizeOk := headers[paxGNUSparseRealSize]
	if majorOk && minorOk {
		sparseFormat = major + "." + minor
	} else if sparseNameOk && sparseMapOk {
		sparseFormat = "0.1"
	} else if sparseSizeOk {
		sparseFormat = "0.0"
	} else {
		return nil, nil
	}
	if sparseFormat != "0.0" && sparseFormat != "0.1" && sparseFormat != "1.0" {
		return nil, nil
	}
	if sparseNameOk {
		hdr.Name = sparseName
	}
	if sparseSizeOk {
		realSize, err := strconv.ParseInt(sparseSize, 10, 0)
		if err != nil {
			return nil, ErrHeader
		}
		hdr.Size = realSize
	} else if sparseRealSizeOk {
		realSize, err := strconv.ParseInt(sparseRealSize, 10, 0)
		if err != nil {
			return nil, ErrHeader
		}
		hdr.Size = realSize
	}
	var sp []sparseEntry
	var err error
	switch sparseFormat {
	case "0.0", "0.1":
		sp, err = readGNUSparseMap0x1(headers)
	case "1.0":
		sp, err = readGNUSparseMap1x0(tr.curr)
	}
	return sp, err
}
func ( tr * Reader ) checkForGNUSparsePAXHeaders ( hdr * Header , headers map [ string ] string ) ( [ ] sparseEntry , error ) { var sparseFormat string major , majorOk := headers [ paxGNUSparseMajor ] minor , minorOk := headers [ paxGNUSparseMinor ] sparseName , sparseNameOk := headers [ paxGNUSparseName ] _ , sparseMapOk := headers [ paxGNUSparseMap ] sparseSize , sparseSizeOk := headers [ paxGNUSparseSize ] sparseRealSize , sparseRealSizeOk := headers [ paxGNUSparseRealSize ] if majorOk && minorOk { sparseFormat = major + " " + minor } else if sparseNameOk && sparseMapOk { sparseFormat = " " } else if sparseSizeOk { sparseFormat = " " } else { return nil , nil } if sparseFormat != " " && sparseFormat != " " && sparseFormat != " " { return nil , nil } if sparseNameOk { hdr . Name = sparseName } if sparseSizeOk { realSize , err := strconv . ParseInt ( sparseSize , 10 , 0 ) if err != nil { return nil , ErrHeader } hdr . Size = realSize } else if sparseRealSizeOk { realSize , err := strconv . ParseInt ( sparseRealSize , 10 , 0 ) if err != nil { return nil , ErrHeader } hdr . Size = realSize } var sp [ ] sparseEntry var err error switch sparseFormat { case " " , " " : sp , err = readGNUSparseMap0x1 ( headers ) case " " : sp , err = readGNUSparseMap1x0 ( tr . curr ) } return sp , err }
checkForGNUSparsePAXHeaders checks the PAX headers for GNU sparse headers.
checkForGNUSparsePAXHeaders checks the PAX headers for GNU sparse headers .
// Check for sparse format indicators // Identify which, if any, sparse format applies from which PAX headers are set // Not a PAX format GNU sparse file. // Check for unknown sparse format // Update hdr from GNU sparse PAX headers // Set up the sparse map, according to the particular sparse format in use