diff --git a/cmd/helper.go b/cmd/helper.go index aa80fc17d..bd7c6f52e 100644 --- a/cmd/helper.go +++ b/cmd/helper.go @@ -7,7 +7,7 @@ import ( "os/exec" ) -func makeLink(oldPath, newPath string) error { - cmd := exec.Command("ln", "-s", oldPath, newPath) +func makeLink(srcPath, destPath string) error { + cmd := exec.Command("ln", "-s", srcPath, destPath) return cmd.Run() } diff --git a/cmd/helper_windows.go b/cmd/helper_windows.go index 20f9da6f1..291b30a91 100644 --- a/cmd/helper_windows.go +++ b/cmd/helper_windows.go @@ -1,20 +1,31 @@ package cmd import ( + "os" "os/exec" "syscall" + + "github.com/Unknwon/com" ) -func makeLink(oldPath, newPath string) error { +func init() { +} + +func makeLink(srcPath, destPath string) error { // Check if Windows version is XP. + if getWindowsVersion() >= 6 { + cmd := exec.Command("cmd", "/c", "mklink", "/j", destPath, srcPath) + return cmd.Run() + } - cmd := exec.Command("cmd", "/c", "mklink", "/j", newPath, oldPath) - return cmd.Run() + // XP. + os.RemoveAll(destPath) + return com.CopyDir(srcPath, destPath) } func getWindowsVersion() int { dll := syscall.MustLoadDLL("kernel32.dll") p := dll.MustFindProc("GetVersion") v, _, _ := p.Call() - return v + return int(byte(v)) }