func (bdeb *DebWriter) writeFromFile(aw *ar.Writer, filename string) error { finf, err := os.Stat(filename) if err != nil { return err } hdr, err := ar.FileInfoHeader(finf) if err != nil { return err } if err := aw.WriteHeader(hdr); err != nil { return err } fi, err := os.Open(filename) if err != nil { return err } if _, err := io.Copy(aw, fi); err != nil { return err } err = fi.Close() if err != nil { return err } return nil }
func (bdeb *DebWriter) writeBytes(aw *ar.Writer, filename string, bytes []byte) error { hdr := &ar.Header{ Name: filename, Size: int64(len(bytes))} if err := aw.WriteHeader(hdr); err != nil { return err } if _, err := aw.Write(bytes); err != nil { return err } return nil }