WriteZipEntry writes content to a zip file entry.
(zipw *zip.Writer, filename string, content []byte, password string)
| 23 | |
| 24 | // WriteZipEntry writes content to a zip file entry. |
| 25 | func WriteZipEntry(zipw *zip.Writer, filename string, content []byte, password string) error { |
| 26 | fh := CreateZipFileHeader(filename, password) |
| 27 | writer, err := zipw.CreateHeader(fh) |
| 28 | if err != nil { |
| 29 | return errors.Wrapf(err, "failed to create zip entry for %s", filename) |
| 30 | } |
| 31 | if _, err := writer.Write(content); err != nil { |
| 32 | return errors.Wrapf(err, "failed to write zip entry for %s", filename) |
| 33 | } |
| 34 | return nil |
| 35 | } |
| 36 | |
| 37 | // CreateZipWriter creates a zip writer for the given writer with a file header. |
| 38 | func CreateZipWriter(zipw *zip.Writer, filename string, password string) (io.Writer, error) { |
no test coverage detected