MCPcopy Index your code
hub / github.com/devspace-sh/devspace / moveFile

Function moveFile

pkg/devspace/plugin/plugin.go:410–432  ·  view source on GitHub ↗
(sourcePath, destPath string)

Source from the content-addressed store, hash-verified

408}
409
410func moveFile(sourcePath, destPath string) error {
411 inputFile, err := os.Open(sourcePath)
412 if err != nil {
413 return fmt.Errorf("couldn't open source file: %s", err)
414 }
415 outputFile, err := os.Create(destPath)
416 if err != nil {
417 inputFile.Close()
418 return fmt.Errorf("couldn't open dest file: %s", err)
419 }
420 defer outputFile.Close()
421 _, err = io.Copy(outputFile, inputFile)
422 inputFile.Close()
423 if err != nil {
424 return fmt.Errorf("writing to output file failed: %s", err)
425 }
426 // The copy was successful, so now delete the original file
427 err = os.Remove(sourcePath)
428 if err != nil {
429 return fmt.Errorf("failed removing original file: %s", err)
430 }
431 return nil
432}

Callers 1

installMethod · 0.85

Calls 4

CloseMethod · 0.65
CopyMethod · 0.65
RemoveMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected