2016-04-01 05:12:51 +00:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package overseer
|
|
|
|
|
|
|
|
import (
|
2016-04-01 20:37:28 +00:00
|
|
|
"bytes"
|
2016-04-01 05:12:51 +00:00
|
|
|
"fmt"
|
2016-04-01 20:37:28 +00:00
|
|
|
"os"
|
2016-04-01 05:12:51 +00:00
|
|
|
"os/exec"
|
2016-04-01 20:37:28 +00:00
|
|
|
"path/filepath"
|
2016-04-01 05:12:51 +00:00
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
supported = true
|
|
|
|
uid = syscall.Getuid()
|
|
|
|
gid = syscall.Getgid()
|
|
|
|
SIGUSR1 = syscall.SIGTERM
|
|
|
|
SIGUSR2 = syscall.SIGTERM
|
|
|
|
SIGTERM = syscall.SIGTERM
|
|
|
|
)
|
|
|
|
|
|
|
|
func move(dst, src string) error {
|
2016-04-01 20:37:28 +00:00
|
|
|
os.MkdirAll(filepath.Dir(dst), 0755)
|
|
|
|
if err := os.Rename(src, dst); err == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2016-04-01 05:12:51 +00:00
|
|
|
//HACK: we're shelling out to move because windows
|
|
|
|
//throws errors when crossing device boundaryes.
|
|
|
|
// https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/move.mspx?mfr=true
|
|
|
|
cmd := exec.Command("cmd", "/c", `move /y "`+src+`" "`+dst+`"`)
|
|
|
|
if b, err := cmd.CombinedOutput(); err != nil {
|
2016-04-01 20:37:28 +00:00
|
|
|
return fmt.Errorf("%v: %q: %v", cmd.Args, bytes.TrimSpace(b), err)
|
2016-04-01 05:12:51 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2016-04-01 20:37:28 +00:00
|
|
|
|
|
|
|
func chmod(f *os.File, perms os.FileMode) error {
|
|
|
|
_ = f.Chmod(perms)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func chown(f *os.File, uid, gid int) error {
|
|
|
|
_ = f.Chown(uid, gid)
|
|
|
|
return nil
|
|
|
|
}
|