PackageManager just because
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
672 B

package Filesystem
import (
"io/fs"
"io/ioutil"
"os"
"path/filepath"
)
func CopyFile(src, dest string) error {
var (
input []byte
fileInfo fs.FileInfo
srcBasePath string
destBasePath string
e error
)
srcBasePath = filepath.Dir(src)
destBasePath = filepath.Dir(dest)
fileInfo, e = os.Stat(srcBasePath)
if e != nil {
return e
}
e = os.MkdirAll(destBasePath, fileInfo.Mode())
if e != nil {
return e
}
fileInfo, e = os.Stat(src)
if e != nil {
return e
}
input, e = ioutil.ReadFile(src)
if e != nil {
return e
}
e = ioutil.WriteFile(dest, input, fileInfo.Mode())
if e != nil {
return e
}
return nil
}