MCPcopy
hub / github.com/cubefs/cubefs / copyFolder

Function copyFolder

deploy/cmd/transform.go:52–96  ·  view source on GitHub ↗
(sourcePath, destinationPath string)

Source from the content-addressed store, hash-verified

50var _ = copyFolder
51
52func copyFolder(sourcePath, destinationPath string) error {
53 err := filepath.Walk(sourcePath, func(path string, info os.FileInfo, err error) error {
54 if err != nil {
55 return err
56 }
57
58 relativePath, err := filepath.Rel(sourcePath, path)
59 if err != nil {
60 return err
61 }
62
63 destinationFilePath := filepath.Join(destinationPath, relativePath)
64
65 if info.IsDir() {
66 err := os.MkdirAll(destinationFilePath, info.Mode())
67 if err != nil {
68 return err
69 }
70 } else {
71 sourceFile, err := os.Open(path)
72 if err != nil {
73 return err
74 }
75 defer sourceFile.Close()
76
77 destinationFile, err := os.Create(destinationFilePath)
78 if err != nil {
79 return err
80 }
81 defer destinationFile.Close()
82
83 _, err = io.Copy(destinationFile, sourceFile)
84 if err != nil {
85 return err
86 }
87 }
88
89 return nil
90 })
91 if err != nil {
92 return err
93 }
94
95 return nil
96}
97
98func createRemoteFolder(nodeUser, node, folderPath string) error {
99 cmdStr := "mkdir -p " + folderPath

Callers

nothing calls this directly

Calls 7

JoinMethod · 0.65
OpenMethod · 0.65
CloseMethod · 0.65
CreateMethod · 0.65
CopyMethod · 0.65
IsDirMethod · 0.45
ModeMethod · 0.45

Tested by

no test coverage detected