(dirOrZipFilePath string, targetFile *os.File)
| 26 | type ApplicationZipper struct{} |
| 27 | |
| 28 | func (zipper ApplicationZipper) Zip(dirOrZipFilePath string, targetFile *os.File) error { |
| 29 | if zipper.IsZipFile(dirOrZipFilePath) { |
| 30 | zipFile, err := os.Open(dirOrZipFilePath) |
| 31 | if err != nil { |
| 32 | return err |
| 33 | } |
| 34 | defer zipFile.Close() |
| 35 | |
| 36 | _, err = io.Copy(targetFile, zipFile) |
| 37 | if err != nil { |
| 38 | return err |
| 39 | } |
| 40 | } else { |
| 41 | err := writeZipFile(dirOrZipFilePath, targetFile) |
| 42 | if err != nil { |
| 43 | return err |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | _, err := targetFile.Seek(0, os.SEEK_SET) |
| 48 | if err != nil { |
| 49 | return err |
| 50 | } |
| 51 | |
| 52 | return nil |
| 53 | } |
| 54 | |
| 55 | func (zipper ApplicationZipper) IsZipFile(name string) bool { |
| 56 | f, err := os.Open(name) |
nothing calls this directly
no test coverage detected