MCPcopy Index your code
hub / github.com/commitdev/zero / copyBinFiles

Function copyBinFiles

internal/generate/generate_modules.go:211–245  ·  view source on GitHub ↗
(binTypeFiles []*fileConfig)

Source from the content-addressed store, hash-verified

209}
210
211func copyBinFiles(binTypeFiles []*fileConfig) {
212 for _, binFile := range binTypeFiles {
213 source := binFile.source
214 dest := binFile.destination
215
216 // create dir
217 outputDirPath, _ := path.Split(dest)
218 err := fs.CreateDirs(outputDirPath)
219 if err != nil {
220 flog.Errorf("Error creating directory '%s': %v", source, err)
221 }
222
223 // create refs to src and dest
224 from, err := os.Open(source)
225 if err != nil {
226 flog.Errorf("Error opening file to read '%s' : %v", source, err)
227 }
228 defer from.Close()
229
230 to, err := os.OpenFile(dest, os.O_RDWR|os.O_CREATE, binFile.modeBits)
231 if err != nil {
232 log.Fatal(err)
233 flog.Errorf("Error creating file '%s': %v", dest, err)
234 }
235 defer to.Close()
236
237 // copy file
238 _, err = io.Copy(to, from)
239 if err != nil {
240 flog.Errorf("Error copying file '%s' : %v", source, err)
241 } else {
242 flog.Successf("Finished copying file : %s", dest)
243 }
244 }
245}

Callers 1

GenerateFunction · 0.85

Calls 3

CreateDirsFunction · 0.92
ErrorfFunction · 0.92
SuccessfFunction · 0.92

Tested by

no test coverage detected