MCPcopy
hub / github.com/cloudfoundry/cli / Zip

Method Zip

cf/appfiles/zipper.go:28–53  ·  view source on GitHub ↗
(dirOrZipFilePath string, targetFile *os.File)

Source from the content-addressed store, hash-verified

26type ApplicationZipper struct{}
27
28func (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
55func (zipper ApplicationZipper) IsZipFile(name string) bool {
56 f, err := os.Open(name)

Callers

nothing calls this directly

Calls 4

IsZipFileMethod · 0.95
writeZipFileFunction · 0.85
CloseMethod · 0.65
SeekMethod · 0.45

Tested by

no test coverage detected