MCPcopy Create free account
hub / github.com/LanceLRQ/deer-executor / FindInZip

Function FindInZip

common/persistence/problems/utils.go:76–96  ·  view source on GitHub ↗

FindInZip 搜索zip内的文件并打开(精确匹配)

(zipArchive *zip.ReadCloser, fileName string)

Source from the content-addressed store, hash-verified

74
75// FindInZip 搜索zip内的文件并打开(精确匹配)
76func FindInZip(zipArchive *zip.ReadCloser, fileName string) (*io.ReadCloser, *zip.File, error) {
77 var fileResult io.ReadCloser
78 finded := false
79 var fileInfo *zip.File
80 err := WalkZip(zipArchive, func(file *zip.File) error {
81 fileInfo = file
82 if fileName == file.Name {
83 finded = true
84 var err error
85 fileResult, err = file.Open()
86 if err != nil {
87 return err
88 }
89 }
90 return nil
91 })
92 if !finded {
93 return nil, nil, NewFileNotFoundError(fileName)
94 }
95 return &fileResult, fileInfo, err
96}

Callers 3

ReadProblemInfoZipFunction · 0.85
ReadProblemGPGInfoZipFunction · 0.85

Calls 2

WalkZipFunction · 0.85
NewFileNotFoundErrorFunction · 0.85

Tested by

no test coverage detected