Browse Source

Added support for XP

pull/103/head
Unknown 11 years ago
parent
commit
78ac398317
  1. 4
      cmd/helper.go
  2. 19
      cmd/helper_windows.go

4
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()
}

19
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))
}

Loading…
Cancel
Save