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

Function copyDir

cli/cmd/new/newLocal.go:146–178  ·  view source on GitHub ↗

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

(srcPath string, destPath string)

Source from the content-addressed store, hash-verified

144 * @param destPath 拷贝到的位置
145 */
146func copyDir(srcPath string, destPath string) error {
147 //检测目录正确性
148 if srcInfo, err := os.Stat(srcPath); err != nil {
149 return err
150 } else {
151 if !srcInfo.IsDir() {
152 common.SmartIDELog.Debug("srcPath不是一个正确的目录!")
153 return errors.New("srcPath不是一个正确的目录!")
154 }
155 }
156 if destInfo, err := os.Stat(destPath); err != nil {
157 return err
158 } else {
159 if !destInfo.IsDir() {
160 common.SmartIDELog.Debug("destInfo不是一个正确的目录!")
161 return errors.New("destInfo不是一个正确的目录!")
162 }
163 }
164 err := filepath.Walk(srcPath, func(path string, f os.FileInfo, err error) error {
165 if f == nil {
166 return err
167 }
168 if !f.IsDir() {
169 path := strings.Replace(path, "\\", "/", -1)
170 srcPath = strings.Replace(srcPath, "\\", "/", -1)
171 destPath = strings.Replace(destPath, "\\", "/", -1)
172 destNewPath := strings.Replace(path, srcPath, destPath, -1)
173 copyFile(path, destNewPath)
174 }
175 return nil
176 })
177 return err
178}
179
180// 生成目录并拷贝文件
181func 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