MCPcopy Index your code
hub / github.com/cloudfoundry/multiapps-cli-plugin / copyContent

Function copyContent

util/archive_builder.go:121–142  ·  view source on GitHub ↗
(sourceDirectory string, elementsPaths map[string]string, targetLocation string)

Source from the content-addressed store, hash-verified

119}
120
121func copyContent(sourceDirectory string, elementsPaths map[string]string, targetLocation string) error {
122 for name, path := range elementsPaths {
123 if path != "" {
124 sourceLocation := filepath.Join(sourceDirectory, path)
125 filesInSourceInfo, err := os.Stat(sourceLocation)
126 if err != nil {
127 return fmt.Errorf("Error building MTA Archive: file path %s not found", sourceLocation)
128 }
129 destinationLocation := filepath.Join(targetLocation, name, filepath.Base(path))
130 if filesInSourceInfo.IsDir() {
131 err = copyDirectory(sourceLocation, destinationLocation)
132 } else {
133 os.MkdirAll(filepath.Dir(destinationLocation), os.ModePerm)
134 err = copyFile(sourceLocation, destinationLocation)
135 }
136 if err != nil {
137 return err
138 }
139 }
140 }
141 return nil
142}
143
144func copyDirectory(src, dest string) error {
145 var err error

Callers 1

BuildMethod · 0.85

Calls 4

copyDirectoryFunction · 0.85
copyFileFunction · 0.85
StatMethod · 0.80
IsDirMethod · 0.80

Tested by

no test coverage detected