for safety image v1.0 #14
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
"path/filepath"
|
||||
"os"
|
||||
"io"
|
||||
)
|
||||
|
||||
// 分离文件名与扩展名(包含.)
|
||||
@ -62,4 +63,18 @@ func ListDir(dir string) []string {
|
||||
}
|
||||
names, _ := f.Readdirnames(0)
|
||||
return names
|
||||
}
|
||||
|
||||
func CopyFile(srcName, dstName string) (written int64, err error) {
|
||||
src, err := os.Open(srcName)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer src.Close()
|
||||
dst, err := os.OpenFile(dstName, os.O_WRONLY|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer dst.Close()
|
||||
return io.Copy(dst, src)
|
||||
}
|
Reference in New Issue
Block a user