47 lines
975 B
Go
47 lines
975 B
Go
package reply
|
||
|
||
import (
|
||
"aiweek/option"
|
||
"io"
|
||
"log"
|
||
"os"
|
||
)
|
||
|
||
// 加载宏
|
||
func excludeMacros() []string {
|
||
macros := option.UDESK_MACROS
|
||
return macros
|
||
}
|
||
|
||
func CopyFile(srcPath, destPath string) error {
|
||
// 打开源文件
|
||
src, err := os.Open(srcPath)
|
||
if err != nil {
|
||
log.Printf("打开源文件失败,错误是:%v", err)
|
||
return err
|
||
}
|
||
defer src.Close()
|
||
|
||
// 创建目标文件(这将自动创建任何必需的目录)
|
||
dest, err := os.Create(destPath)
|
||
if err != nil {
|
||
log.Printf("创建目标文件失败,错误是:%v", err)
|
||
return err
|
||
}
|
||
defer dest.Close()
|
||
|
||
// 复制文件内容
|
||
if _, err = io.Copy(dest, src); err != nil {
|
||
log.Printf("复制文件内容失败,错误是:%v", err)
|
||
return err
|
||
}
|
||
|
||
// 确保目标文件被写入磁盘
|
||
if err := dest.Sync(); err != nil {
|
||
log.Printf("写入磁盘失败,错误是:%v", err)
|
||
return err
|
||
}
|
||
defer log.Printf("复制文件到volume目录完成!错误是:%v", err)
|
||
return err
|
||
}
|