func addArFile(now time.Time, w *ar.Writer, name string, body []byte) error { hdr := ar.Header{ Name: name, Size: int64(len(body)), Mode: 0644, ModTime: now, } if err := w.WriteHeader(&hdr); err != nil { return fmt.Errorf("cannot write file header: %v", err) } _, err := w.Write(body) return err }
// FIXME: this should move into the "ar" library itself func addDataToAr(arWriter *ar.Writer, filename string, data []byte) error { size := int64(len(data)) hdr := &ar.Header{ Name: filename, ModTime: time.Now(), Mode: 0644, Size: size, } arWriter.WriteHeader(hdr) _, err := arWriter.Write([]byte(data)) if err != nil { return err } return nil }