MCPcopy
hub / github.com/nektos/act / CopyDir

Function CopyDir

pkg/common/file.go:37–73  ·  view source on GitHub ↗

CopyDir recursive copy of directory

(source string, dest string)

Source from the content-addressed store, hash-verified

35
36// CopyDir recursive copy of directory
37func CopyDir(source string, dest string) (err error) {
38 // get properties of source dir
39 sourceinfo, err := os.Stat(source)
40 if err != nil {
41 return err
42 }
43
44 // create dest dir
45
46 err = os.MkdirAll(dest, sourceinfo.Mode())
47 if err != nil {
48 return err
49 }
50
51 objects, err := os.ReadDir(source)
52
53 for _, obj := range objects {
54 sourcefilepointer := source + "/" + obj.Name()
55
56 destinationfilepointer := dest + "/" + obj.Name()
57
58 if obj.IsDir() {
59 // create sub-directories - recursively
60 err = CopyDir(sourcefilepointer, destinationfilepointer)
61 if err != nil {
62 fmt.Println(err)
63 }
64 } else {
65 // perform copy
66 err = CopyFile(sourcefilepointer, destinationfilepointer)
67 if err != nil {
68 fmt.Println(err)
69 }
70 }
71 }
72 return err
73}

Callers

nothing calls this directly

Calls 4

CopyFileFunction · 0.85
ModeMethod · 0.80
NameMethod · 0.80
IsDirMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…