MCPcopy
hub / github.com/Tencent/CodeAnalysis / List

Method List

tools/owl/scan/scanner.go:191–222  ·  view source on GitHub ↗

List returns all files under the specified path to calculate the signature

()

Source from the content-addressed store, hash-verified

189
190// List returns all files under the specified path to calculate the signature
191func (s *Scanner) List() ([]*Result, error) {
192 res := make([]*Result, 0)
193 if IsFile(s.Path) {
194 md5, err := Md5(s.Path)
195 if err != nil {
196 return nil, err
197 }
198 res = append(res, &Result{
199 Index: 1,
200 Path: s.Path,
201 Code: md5,
202 })
203 return res, nil
204 }
205
206 if files, err := Files(s.Path); err != nil {
207 return nil, err
208 } else {
209 for i, v := range files {
210 if md5, err := Md5(v); err != nil {
211 return nil, err
212 } else {
213 res = append(res, &Result{
214 Index: i + 1,
215 Path: v,
216 Code: md5,
217 })
218 }
219 }
220 }
221 return res, nil
222}
223
224// HexDump convert path content to hexadecimal
225func (s *Scanner) HexDump() (string, error) {

Callers 2

md5.goFile · 0.80
TestScannerFunction · 0.80

Calls 3

IsFileFunction · 0.85
Md5Function · 0.85
FilesFunction · 0.85

Tested by 1

TestScannerFunction · 0.64