MCPcopy Create free account
hub / github.com/Illusionna/LocalTransfer / CopyFile

Function CopyFile

utils.go:778–802  ·  view source on GitHub ↗
(src, dst string)

Source from the content-addressed store, hash-verified

776
777
778func CopyFile(src, dst string) error {
779 if _, err := os.Stat(dst); err == nil {
780 // 如果目标文件已经存在, 则不允许覆盖.
781 return err
782 }
783
784 source_file, err := os.Open(src)
785 if err != nil {
786 return err
787 }
788 defer source_file.Close()
789
790 if err := os.MkdirAll(filepath.Dir(dst), os.ModePerm); err != nil {
791 return err
792 }
793
794 destination_file, err := os.Create(dst)
795 if err != nil {
796 return err
797 }
798 defer destination_file.Close()
799
800 _, err = io.Copy(destination_file, source_file)
801 return err
802}
803
804
805func CopyDirectory(src, dst string) error {

Callers 2

CopyDirectoryFunction · 0.85
CopySelectedFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected