-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall_windows.go
85 lines (75 loc) · 1.92 KB
/
install_windows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// +build windows
package linux_installer
// This code is unused & untested!! (And probably completely unnecessary...)
import (
"errors"
"log"
"os"
"os/exec"
"path/filepath"
"syscall"
"unsafe"
"golang.org/x/sys/windows"
)
func osFileWriteAccess(path string) (success bool) {
testPath := syscall.StringToUTF16Ptr(filepath.Join(path, ".test"))
_, err := windows.CreateFile(
testPath,
windows.GENERIC_WRITE|windows.GENERIC_READ,
0,
nil,
windows.CREATE_NEW,
windows.FILE_ATTRIBUTE_HIDDEN,
0,
)
if err == nil {
windows.DeleteFile(testPath)
return true
} else {
return false
}
}
func osDiskSpace(path string) (availableBytes int64) {
win32 := syscall.MustLoadDLL("kernel32.dll")
getDiskFreeSpace := win32.MustFindProc("GetDiskFreeSpaceExW")
getDiskFreeSpace.Call(
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(path))),
uintptr(0),
uintptr(0),
uintptr(unsafe.Pointer(&availableBytes)),
)
return
}
func osCreateLauncherEntry(variables VariableMap) (desktopFilepath string, err error) {
return
}
func osCreateUninstaller(uninstallerFileList []string, variables VariableMap) error {
return nil
}
func osRunHookIfExists(scriptFile string, installPath string) (err error) {
if _, err = os.Stat(scriptFile + ".bat"); os.IsNotExist(err) {
return
}
out, err := exec.Command(scriptFile+".bat", installPath).Output()
log.Println("hook output:\n", string(out[:]))
if err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
return errors.New(string(exitErr.Stderr))
} else {
return err
}
}
return err
}
func osShowRawErrorDialog(message string) (err error) { return }
// osExecVE emulates Linux execve in that it starts a new process and then terminates
// the current one (and thus never returns).
func osExecVE(cmd string, args []string) {
_, _, err := syscall.StartProcess(cmd, args, nil)
if err != nil {
log.Println("execve error:", err.Error())
os.Exit(1)
} else {
os.Exit(0)
}
}