// Package winapi is the Windows Win32 binding layer for Keel's OS ports. // The syscall-bound code lives in windows-tagged files; this untagged file // holds the pure path logic so it builds and is tested on every platform. package winapi import "strings" // ClassFromImagePath derives the on-task class identity from a process image // path: the base file name with any trailing ".exe" removed (case-insensitive), // lowercased. It is the Windows analog of an X11 WM_CLASS. It parses both `\` // and `/` separators so it is correct regardless of the host OS running the // test. Returns "" for an empty path. func ClassFromImagePath(p string) string { if i := strings.LastIndexAny(p, `\/`); i >= 0 { p = p[i+1:] } const exeSuffix = ".exe" if len(p) >= len(exeSuffix) && strings.EqualFold(p[len(p)-len(exeSuffix):], exeSuffix) { p = p[:len(p)-len(exeSuffix)] } return strings.ToLower(p) }