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

Method AppFilesInDir

cf/appfiles/app_files.go:30–66  ·  view source on GitHub ↗
(dir string)

Source from the content-addressed store, hash-verified

28type ApplicationFiles struct{}
29
30func (appfiles ApplicationFiles) AppFilesInDir(dir string) ([]models.AppFileFields, error) {
31 appFiles := []models.AppFileFields{}
32
33 fullDirPath, toplevelErr := filepath.Abs(dir)
34 if toplevelErr != nil {
35 return appFiles, toplevelErr
36 }
37
38 toplevelErr = appfiles.WalkAppFiles(fullDirPath, func(fileName string, fullPath string) error {
39 fileInfo, err := os.Lstat(fullPath)
40 if err != nil {
41 return err
42 }
43
44 appFile := models.AppFileFields{
45 Path: filepath.ToSlash(fileName),
46 Size: fileInfo.Size(),
47 }
48
49 if fileInfo.IsDir() {
50 appFile.Sha1 = "0"
51 appFile.Size = 0
52 } else {
53 sha, err := appfiles.shaFile(fullPath)
54 if err != nil {
55 return err
56 }
57 appFile.Sha1 = sha
58 }
59
60 appFiles = append(appFiles, appFile)
61
62 return nil
63 })
64
65 return appFiles, toplevelErr
66}
67
68func (appfiles ApplicationFiles) shaFile(fullPath string) (string, error) {
69 hash := sha1.New()

Callers

nothing calls this directly

Calls 4

WalkAppFilesMethod · 0.95
shaFileMethod · 0.95
SizeMethod · 0.80
IsDirMethod · 0.80

Tested by

no test coverage detected