fix Cmd and CopyFile

This commit is contained in:
josc146 2023-05-31 16:27:43 +08:00
parent 2f5a7d2d51
commit b03b00419b
2 changed files with 11 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import (
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings"
"time" "time"
) )
@ -100,6 +101,11 @@ func (a *App) CopyFile(src string, dst string) error {
} }
defer sourceFile.Close() defer sourceFile.Close()
err = os.MkdirAll(dst[:strings.LastIndex(dst, "/")], 0755)
if err != nil {
return err
}
destFile, err := os.Create(dst) destFile, err := os.Create(dst)
if err != nil { if err != nil {
return err return err

View File

@ -15,6 +15,11 @@ import (
) )
func Cmd(args ...string) (string, error) { func Cmd(args ...string) (string, error) {
path, err := filepath.Abs(args[0])
if err != nil {
return "", err
}
args[0] = path
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
_, err := os.Stat("cmd-helper.bat") _, err := os.Stat("cmd-helper.bat")
if err != nil { if err != nil {