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.

29 lines
518 B

package cmd
import (
"os"
"os/exec"
"syscall"
"github.com/Unknwon/com"
)
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()
}
// 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 int(byte(v))
}