mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-24 15:38:12 +02:00
macOS : JEAN_HOME utilisateur, RAM detectee, PATH Homebrew depuis le Finder
- /etc/jean n'est pas ecrivable par une app lancee depuis le Finder -> repli sur ~/Library/Application Support/jean (sauf sudo jean install) - /api/ram lisait /proc/meminfo uniquement : ajout sysctl+vm_stat (macOS) et GlobalMemoryStatusEx (Windows, qui ne remontait rien non plus) - PATH herite du Finder complete avec Homebrew/MacPorts : sans ca cmake, git et brew sont invisibles pour la compilation du backend
This commit is contained in:
1 parent
89cbb50fcf
commit
a1b0cc0c58
4 files changed
+158
-26
No files matched your search
@@ -368,3 +368,25 @@ func cudaPathEnv(toolkitDir string) []string {
|
||||
func newShellCmd(ctx context.Context, command string) *exec.Cmd {
|
||||
return hideCmd(exec.CommandContext(ctx, "cmd", "/C", command))
|
||||
}
|
||||
|
||||
// ramUsageMB renvoie (utilisée, totale) en Mo pour /api/ram (GlobalMemoryStatusEx).
|
||||
func ramUsageMB() (used, total int) {
|
||||
var m struct {
|
||||
dwLength uint32
|
||||
dwMemoryLoad uint32
|
||||
ullTotalPhys uint64
|
||||
ullAvailPhys uint64
|
||||
ullTotalPageFile uint64
|
||||
ullAvailPageFile uint64
|
||||
ullTotalVirtual uint64
|
||||
ullAvailVirtual uint64
|
||||
ullAvailExtendedVirtual uint64
|
||||
}
|
||||
m.dwLength = uint32(unsafe.Sizeof(m))
|
||||
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
||||
if r, _, _ := kernel32.NewProc("GlobalMemoryStatusEx").Call(uintptr(unsafe.Pointer(&m))); r == 0 {
|
||||
return 0, 0
|
||||
}
|
||||
const mb = 1024 * 1024
|
||||
return int((m.ullTotalPhys - m.ullAvailPhys) / mb), int(m.ullTotalPhys / mb)
|
||||
}
|
||||
Reference in new issue
Block a user