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" "os/exec"
) )
func makeLink(oldPath, newPath string) error { func makeLink(srcPath, destPath string) error {
cmd := exec.Command("ln", "-s", oldPath, newPath) cmd := exec.Command("ln", "-s", srcPath, destPath)
return cmd.Run() return cmd.Run()
} }

19
cmd/helper_windows.go

@ -1,20 +1,31 @@
package cmd package cmd
import ( import (
"os"
"os/exec" "os/exec"
"syscall" "syscall"
"github.com/Unknwon/com"
) )
func makeLink(oldPath, newPath string) error { func init() {
// Check if Windows version is XP. }
cmd := exec.Command("cmd", "/c", "mklink", "/j", newPath, oldPath) 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() return cmd.Run()
}
// XP.
os.RemoveAll(destPath)
return com.CopyDir(srcPath, destPath)
} }
func getWindowsVersion() int { func getWindowsVersion() int {
dll := syscall.MustLoadDLL("kernel32.dll") dll := syscall.MustLoadDLL("kernel32.dll")
p := dll.MustFindProc("GetVersion") p := dll.MustFindProc("GetVersion")
v, _, _ := p.Call() v, _, _ := p.Call()
return v return int(byte(v))
} }

Loading…
Cancel
Save