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

Function copyDirectory

util/archive_builder.go:144–175  ·  view source on GitHub ↗
(src, dest string)

Source from the content-addressed store, hash-verified

142}
143
144func copyDirectory(src, dest string) error {
145 var err error
146 var filesInDestinationInfo []os.DirEntry
147 var sourceInfo os.FileInfo
148
149 if sourceInfo, err = os.Stat(src); err != nil {
150 return err
151 }
152
153 if err = os.MkdirAll(dest, sourceInfo.Mode()); err != nil {
154 return err
155 }
156
157 if filesInDestinationInfo, err = os.ReadDir(src); err != nil {
158 return err
159 }
160 for _, fd := range filesInDestinationInfo {
161 srcfp := path.Join(src, fd.Name())
162 dstfp := path.Join(dest, fd.Name())
163
164 if fd.IsDir() {
165 if err = copyDirectory(srcfp, dstfp); err != nil {
166 return err
167 }
168 } else {
169 if err = copyFile(srcfp, dstfp); err != nil {
170 return err
171 }
172 }
173 }
174 return nil
175}
176
177func copyFile(src, dest string) error {
178 fileFrom, err := os.Open(src)

Callers 1

copyContentFunction · 0.85

Calls 5

copyFileFunction · 0.85
StatMethod · 0.80
ModeMethod · 0.80
IsDirMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected