MCPcopy Create free account
hub / github.com/code-scan/Goal / UnZip

Function UnZip

Gfile/file.go:37–66  ·  view source on GitHub ↗
(src string, dst string)

Source from the content-addressed store, hash-verified

35 return true
36}
37func UnZip(src string, dst string) {
38 if CheckExist(dst) == false {
39 os.MkdirAll(dst, 0777)
40 }
41 read, err := zip.OpenReader(src)
42 if err != nil {
43 fmt.Println(err)
44 return
45 }
46 for _, file := range read.Reader.File {
47 p := path.Join(dst, file.Name)
48 if file.FileInfo().IsDir() {
49 fmt.Println("[C] ", p)
50 _ = os.MkdirAll(p, file.FileInfo().Mode())
51 continue
52 }
53 r, err := file.Open()
54 if err != nil {
55 continue
56 }
57 defer r.Close()
58 outFile, err := os.Create(p)
59 if err != nil {
60 continue
61 }
62 fmt.Println("[W] ", p)
63 defer outFile.Close()
64 _, _ = io.Copy(outFile, r)
65 }
66}
67
68func GetFileList(dir string) interface{} {
69 dirList := []map[string]interface{}{}

Callers

nothing calls this directly

Calls 2

CheckExistFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected