func (tr *Reader) Next() (*Header, error) {
	var hdr *Header
	if tr.err == nil {
		tr.skipUnread()
	}
	if tr.err != nil {
		return hdr, tr.err
	}
	hdr = tr.readHeader()
	if hdr == nil {
		return hdr, tr.err
	}
	// Check for PAX/GNU header.
	switch hdr.Typeflag {
	case TypeXHeader:
		//  PAX extended header
		headers, err := parsePAX(tr)
		if err != nil {
			return nil, err
		}
		// We actually read the whole file,
		// but this skips alignment padding
		tr.skipUnread()
		hdr = tr.readHeader()
		if hdr == nil {
			return hdr, tr.err
		}
		mergePAX(hdr, headers)

		// Check for a PAX format sparse file
		sp, err := tr.checkForGNUSparsePAXHeaders(hdr, headers)
		if err != nil {
			tr.err = err
			return nil, err
		}
		if sp != nil {
			// Current file is a PAX format GNU sparse file.
			// Set the current file reader to a sparse file reader.
			tr.curr = &sparseFileReader{rfr: tr.curr.(*regFileReader), sp: sp, tot: hdr.Size}
		}
		return hdr, nil
	case TypeGNULongName:
		// We have a GNU long name header. Its contents are the real file name.
		realname, err := ioutil.ReadAll(tr)
		if err != nil {
			return nil, err
		}
		hdr, err := tr.Next()
		hdr.Name = cString(realname)
		return hdr, err
	case TypeGNULongLink:
		// We have a GNU long link header.
		realname, err := ioutil.ReadAll(tr)
		if err != nil {
			return nil, err
		}
		hdr, err := tr.Next()
		hdr.Linkname = cString(realname)
		return hdr, err
	}
	return hdr, tr.err
}
// Next advances to the next entry in the tar archive.
Next advances to the next entry in the tar archive.
// Next advances to the next entry in the tar archive .
func (tr *Reader) Next() (*Header, error) {
	var hdr *Header
	if tr.err == nil {
		tr.skipUnread()
	}
	if tr.err != nil {
		return hdr, tr.err
	}
	hdr = tr.readHeader()
	if hdr == nil {
		return hdr, tr.err
	}
	switch hdr.Typeflag {
	case TypeXHeader:
		headers, err := parsePAX(tr)
		if err != nil {
			return nil, err
		}
		tr.skipUnread()
		hdr = tr.readHeader()
		if hdr == nil {
			return hdr, tr.err
		}
		mergePAX(hdr, headers)
		sp, err := tr.checkForGNUSparsePAXHeaders(hdr, headers)
		if err != nil {
			tr.err = err
			return nil, err
		}
		if sp != nil {
			tr.curr = &sparseFileReader{rfr: tr.curr.(*regFileReader), sp: sp, tot: hdr.Size}
		}
		return hdr, nil
	case TypeGNULongName:
		realname, err := ioutil.ReadAll(tr)
		if err != nil {
			return nil, err
		}
		hdr, err := tr.Next()
		hdr.Name = cString(realname)
		return hdr, err
	case TypeGNULongLink:
		realname, err := ioutil.ReadAll(tr)
		if err != nil {
			return nil, err
		}
		hdr, err := tr.Next()
		hdr.Linkname = cString(realname)
		return hdr, err
	}
	return hdr, tr.err
}
func ( tr * Reader ) Next ( ) ( * Header , error ) { var hdr * Header if tr . err == nil { tr . skipUnread ( ) } if tr . err != nil { return hdr , tr . err } hdr = tr . readHeader ( ) if hdr == nil { return hdr , tr . err } switch hdr . Typeflag { case TypeXHeader : headers , err := parsePAX ( tr ) if err != nil { return nil , err } tr . skipUnread ( ) hdr = tr . readHeader ( ) if hdr == nil { return hdr , tr . err } mergePAX ( hdr , headers ) sp , err := tr . checkForGNUSparsePAXHeaders ( hdr , headers ) if err != nil { tr . err = err return nil , err } if sp != nil { tr . curr = & sparseFileReader { rfr : tr . curr . ( * regFileReader ) , sp : sp , tot : hdr . Size } } return hdr , nil case TypeGNULongName : realname , err := ioutil . ReadAll ( tr ) if err != nil { return nil , err } hdr , err := tr . Next ( ) hdr . Name = cString ( realname ) return hdr , err case TypeGNULongLink : realname , err := ioutil . ReadAll ( tr ) if err != nil { return nil , err } hdr , err := tr . Next ( ) hdr . Linkname = cString ( realname ) return hdr , err } return hdr , tr . err }
Next advances to the next entry in the tar archive.
Next advances to the next entry in the tar archive .
// Check for PAX/GNU header. //  PAX extended header // We actually read the whole file, // but this skips alignment padding // Check for a PAX format sparse file // Current file is a PAX format GNU sparse file. // Set the current file reader to a sparse file reader. // We have a GNU long name header. Its contents are the real file name. // We have a GNU long link header.