MCPcopy Index your code
hub / github.com/cortexlabs/cortex / CopyDirOverwrite

Function CopyDirOverwrite

pkg/lib/files/files.go:940–969  ·  view source on GitHub ↗
(src string, dest string, ignoreFns ...IgnoreFn)

Source from the content-addressed store, hash-verified

938}
939
940func CopyDirOverwrite(src string, dest string, ignoreFns ...IgnoreFn) error {
941 srcRelFilePaths, err := ListDirRecursive(src, true, ignoreFns...)
942 if err != nil {
943 return err
944 }
945
946 if _, err := CreateDirIfMissing(dest); err != nil {
947 return err
948 }
949 createdDirs := strset.New(dest)
950
951 for _, srcRelFilePath := range srcRelFilePaths {
952 srcFilePath := filepath.Join(src, srcRelFilePath)
953 destFilePath := filepath.Join(dest, srcRelFilePath)
954
955 destFileDir := filepath.Dir(destFilePath)
956 if !createdDirs.Has(destFileDir) {
957 if _, err := CreateDirIfMissing(destFileDir); err != nil {
958 return err
959 }
960 createdDirs.Add(destFileDir)
961 }
962
963 if err := CopyFileOverwrite(srcFilePath, destFilePath); err != nil {
964 return err
965 }
966 }
967
968 return nil
969}
970
971func CopyRecursiveShell(src string, dest string) error {
972 cleanSrc, err := EscapeTilde(src)

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
ListDirRecursiveFunction · 0.85
CreateDirIfMissingFunction · 0.85
CopyFileOverwriteFunction · 0.85
HasMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected