MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / copyDir

Function copyDir

cli/cmd/init/local.go:82–114  ·  view source on GitHub ↗

** * 拷贝文件夹,同时拷贝文件夹中的文件 * @param srcPath 需要拷贝的文件夹路径 * @param destPath 拷贝到的位置 */

(srcPath string, destPath string)

Source from the content-addressed store, hash-verified

80 * @param destPath 拷贝到的位置
81 */
82func copyDir(srcPath string, destPath string) error {
83 //检测目录正确性
84 if srcInfo, err := os.Stat(srcPath); err != nil {
85 return err
86 } else {
87 if !srcInfo.IsDir() {
88 common.SmartIDELog.Debug("srcPath不是一个正确的目录!")
89 return errors.New("srcPath不是一个正确的目录!")
90 }
91 }
92 if destInfo, err := os.Stat(destPath); err != nil {
93 return err
94 } else {
95 if !destInfo.IsDir() {
96 common.SmartIDELog.Debug("destInfo不是一个正确的目录!")
97 return errors.New("destInfo不是一个正确的目录!")
98 }
99 }
100 err := filepath.Walk(srcPath, func(path string, f os.FileInfo, err error) error {
101 if f == nil {
102 return err
103 }
104 if !f.IsDir() {
105 path := strings.Replace(path, "\\", "/", -1)
106 srcPath = strings.Replace(srcPath, "\\", "/", -1)
107 destPath = strings.Replace(destPath, "\\", "/", -1)
108 destNewPath := strings.Replace(path, srcPath, destPath, -1)
109 copyFile(path, destNewPath)
110 }
111 return nil
112 })
113 return err
114}
115
116// 生成目录并拷贝文件
117func copyFile(src, dest string) (w int64, err error) {

Callers 1

CopyTemplateToCurrentDirFunction · 0.70

Calls 2

DebugMethod · 0.80
copyFileFunction · 0.70

Tested by

no test coverage detected