mirror of https://github.com/gogits/gogs.git
Unknown
11 years ago
2 changed files with 17 additions and 6 deletions
@ -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…
Reference in new issue