// FileInfoHeader creates a populated Header from fi.
// Compared to archive pkg this function fills in more information.
// Also, regardless of Go version, this function fills file type bits (e.g. hdr.Mode |= modeISDIR),
// which have been deleted since Go 1.9 archive/tar.
FileInfoHeader creates a populated Header from fi.
Compared to archive pkg this function fills in more information.
Also, regardless of Go version, this function fills file type bits ,
which have been deleted since Go 1.9 archive/tar.
// FileInfoHeader creates a populated Header from fi . // Compared to archive pkg this function fills in more information . // Also regardless of Go version this function fills file type bits ( e . g . hdr . Mode | = modeISDIR ) // which have been deleted since Go 1 . 9 archive / tar .
func FileInfoHeader(name string, fi os.FileInfo, link string) (*tar.Header, error) {
        hdr, err := tar.FileInfoHeader(fi, link)
        if err != nil {
                return nil, err
        }
        hdr.Mode = fillGo18FileTypeBits(int64(chmodTarEntry(os.FileMode(hdr.Mode))), fi)
        name, err = canonicalTarName(name, fi.IsDir())
        if err != nil {
                return nil, fmt.Errorf("tar: cannot canonicalize path: %v", err)
        }
        hdr.Name = name
        if err := setHeaderForSpecialDevice(hdr, name, fi.Sys()); err != nil {
                return nil, err
        }
        return hdr, nil
}
func FileInfoHeader ( name string , fi os . FileInfo , link string ) ( * tar . Header , error ) { hdr , err := tar . FileInfoHeader ( fi , link ) if err != nil { return nil , err } hdr . Mode = fillGo18FileTypeBits ( int64 ( chmodTarEntry ( os . FileMode ( hdr . Mode ) ) ) , fi ) name , err = canonicalTarName ( name , fi . IsDir ( ) ) if err != nil { return nil , fmt . Errorf ( " " , err ) } hdr . Name = name if err := setHeaderForSpecialDevice ( hdr , name , fi . Sys ( ) ) ; err != nil { return nil , err } return hdr , nil }
FileInfoHeader creates a populated Header from fi.
FileInfoHeader creates a populated Header from fi .