⬗ (Osu! Background Manager) A little utility to replace, retrieve or remove backgrounds for every beatmap in your osu! folder ⬖
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.
 
 

32 lines
732 B

package util
import (
"errors"
"fmt"
"io"
"os"
)
// opens given files, copies one into another
func CopyFile(srcPath, dstPath string) error {
// open for reading (source)
srcFile, err := os.Open(srcPath)
if err != nil {
return errors.New(fmt.Sprintf("Could not open src file : %s", err))
}
defer srcFile.Close()
// open for writing (destination) (create file, if it does not exist already)
dstFile, err := os.OpenFile(dstPath, os.O_WRONLY|os.O_CREATE, os.ModePerm)
if err != nil {
return errors.New(fmt.Sprintf("Could not open dst file : %s", err))
}
defer dstFile.Close()
_, err = io.Copy(dstFile, srcFile)
if err != nil {
return errors.New(fmt.Sprintf("Could not copy file : %s", err))
}
return nil
}