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 |
package cmd |
||||||
|
|
||||||
import ( |
import ( |
||||||
|
"os" |
||||||
"os/exec" |
"os/exec" |
||||||
"syscall" |
"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.
|
// 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) |
// XP.
|
||||||
return cmd.Run() |
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…
Reference in new issue