// AppendToTar is a helper function for add a physical file to tar
AppendToTar is a helper function for add a physical file to tar
// AppendToTar is a helper function for add a physical file to tar
func AppendToTar(tw *tar.Writer, fullPath, tarPath string) (err error) {
	var (
		f   *os.File
		st  os.FileInfo
		hdr *tar.Header
	)
	if f, err = os.Open(fullPath); err != nil {
		return err
	}
	defer f.Close()
	if st, err = f.Stat(); err != nil {
		return
	}
	if hdr, err = tar.FileInfoHeader(st, tarPath); err != nil {
		return
	}
	hdr.Name = tarPath
	if err = tw.WriteHeader(hdr); err != nil {
		return
	}
	_, err = io.Copy(tw, io.LimitReader(f, st.Size()))
	return
}
func AppendToTar ( tw * tar . Writer , fullPath , tarPath string ) ( err error ) { var ( f * os . File st os . FileInfo hdr * tar . Header ) if f , err = os . Open ( fullPath ) ; err != nil { return err } defer f . Close ( ) if st , err = f . Stat ( ) ; err != nil { return } if hdr , err = tar . FileInfoHeader ( st , tarPath ) ; err != nil { return } hdr . Name = tarPath if err = tw . WriteHeader ( hdr ) ; err != nil { return } _ , err = io . Copy ( tw , io . LimitReader ( f , st . Size ( ) ) ) return }
AppendToTar is a helper function for add a physical file to tar
AppendToTar is a helper function for add a physical file to tar