func (fi headerFileInfo) Mode() (mode os.FileMode) {
	mode = os.FileMode(fi.h.Mode).Perm()
	if fi.h.Mode&c_ISUID != 0 {
		mode |= os.ModeSetuid
	}
	if fi.h.Mode&c_ISGID != 0 {
		mode |= os.ModeSetgid
	}
	if fi.h.Mode&c_ISVTX != 0 {
		mode |= os.ModeSticky
	}
	m := os.FileMode(fi.h.Mode) &^ 07777
	if m == c_ISDIR {
		mode |= os.ModeDir
	}
	if m == c_ISFIFO {
		mode |= os.ModeNamedPipe
	}
	if m == c_ISLNK {
		mode |= os.ModeSymlink
	}
	if m == c_ISBLK {
		mode |= os.ModeDevice
	}
	if m == c_ISCHR {
		mode |= os.ModeDevice
		mode |= os.ModeCharDevice
	}
	if m == c_ISSOCK {
		mode |= os.ModeSocket
	}
	switch fi.h.Typeflag {
	case TypeSymlink:
		mode |= os.ModeSymlink
	case TypeChar:
		mode |= os.ModeDevice
		mode |= os.ModeCharDevice
	case TypeBlock:
		mode |= os.ModeDevice
	case TypeDir:
		mode |= os.ModeDir
	case TypeFifo:
		mode |= os.ModeNamedPipe
	}
	return mode
}
Mode returns the permission and mode bits for the headerFileInfo.
package tar
import (
	"bytes"
	"errors"
	"fmt"
	"os"
	"path"
	"time"
)
const (
	blockSize = 512
	TypeReg           = '0'     
	TypeRegA          = '\x00'  
	TypeLink          = '1'     
	TypeSymlink       = '2'     
	TypeChar          = '3'     
	TypeBlock         = '4'     
	TypeDir           = '5'     
	TypeFifo          = '6'     
	TypeCont          = '7'     
	TypeXHeader       = 'x'     
	TypeXGlobalHeader = 'g'     
	TypeGNULongName   = 'L'     
	TypeGNULongLink   = 'K'     
	TypeGNUSparse     = 'S'     
)
type Header struct {
	Name       string     
	Mode       int64      
	Uid        int        
	Gid        int        
	Size       int64      
	ModTime    time.Time  
	Typeflag   byte       
	Linkname   string     
	Uname      string     
	Gname      string     
	Devmajor   int64      
	Devminor   int64      
	AccessTime time.Time  
	ChangeTime time.Time  
	Xattrs     map[string]string
}
const (
	fileNameSize       = 100  
	fileNamePrefixSize = 155  
)
func (h *Header) FileInfo() os.FileInfo {
	return headerFileInfo{h}
}
type headerFileInfo struct {
	h *Header
}
func (fi headerFileInfo) Size() int64        { return fi.h.Size }
func (fi headerFileInfo) IsDir() bool        { return fi.Mode().IsDir() }
func (fi headerFileInfo) ModTime() time.Time { return fi.h.ModTime }
func (fi headerFileInfo) Sys() interface{}   { return fi.h }
func (fi headerFileInfo) Name() string {
	if fi.IsDir() {
		return path.Base(path.Clean(fi.h.Name))
	}
	return path.Base(fi.h.Name)
}